diff src/ov-typeinfo.cc @ 2926:66ef74ee5d9f

[project @ 1997-05-05 03:20:52 by jwe]
author jwe
date Mon, 05 May 1997 03:40:21 +0000
parents 05926e1b367d
children 38de16594cb4
line wrap: on
line diff
--- a/src/ov-typeinfo.cc	Sat May 03 21:24:19 1997 +0000
+++ b/src/ov-typeinfo.cc	Mon May 05 03:40:21 1997 +0000
@@ -56,13 +56,28 @@
 template class Array<type_conv_fcn>;
 template class Array2<type_conv_fcn>;
 
+bool
+octave_value_typeinfo::instance_ok (void)
+{
+  bool retval = true;
+  if (! instance)
+    instance = new octave_value_typeinfo ();
+
+  if (! instance)
+    {
+      ::error ("unable to create value type info object!");
+
+      retval = false;
+    }
+
+  return retval;
+}
+
 int
 octave_value_typeinfo::register_type (const string& name)
 {
-  if (! instance)
-    instance = new octave_value_typeinfo ();
-
-  return instance->do_register_type (name);
+  return (instance_ok ())
+    ? instance->do_register_type (name) : -1;
 }
 
 bool
@@ -70,10 +85,8 @@
 					   int t1, int t2,
 					   binary_op_fcn f)
 {
-  if (! instance)
-    instance = new octave_value_typeinfo ();
-
-  return instance->do_register_binary_op (op, t1, t2, f);
+  return (instance_ok ())
+    ? instance->do_register_binary_op (op, t1, t2, f) : false;
 }
 
 bool
@@ -81,30 +94,24 @@
 					   int t_lhs, int t_rhs,
 					   assign_op_fcn f)
 {
-  if (! instance)
-    instance = new octave_value_typeinfo ();
-
-  return instance->do_register_assign_op (op, t_lhs, t_rhs, f);
+  return (instance_ok ())
+    ? instance->do_register_assign_op (op, t_lhs, t_rhs, f) : -1;
 }
 
 bool
 octave_value_typeinfo::register_pref_assign_conv (int t_lhs, int t_rhs,
 						  int t_result) 
 {
-  if (! instance)
-    instance = new octave_value_typeinfo ();
-
-  return instance->do_register_pref_assign_conv (t_lhs, t_rhs, t_result);
+  return (instance_ok ())
+    ? instance->do_register_pref_assign_conv (t_lhs, t_rhs, t_result) : false;
 }
 
 bool
 octave_value_typeinfo::register_widening_op (int t, int t_result,
 					     type_conv_fcn f)
 {
-  if (! instance)
-    instance = new octave_value_typeinfo ();
-
-  return instance->do_register_widening_op (t, t_result, f);
+  return (instance_ok ())
+    ? instance->do_register_widening_op (t, t_result, f) : false;
 }
 
 int