changeset 7056:2002804df782

[project @ 2007-10-24 00:32:44 by jwe]
author jwe
date Wed, 24 Oct 2007 00:32:44 +0000
parents 3e4dab6a136c
children c344920f9e9d
files src/ChangeLog src/graphics.cc src/graphics.h.in src/mxarray.h.in src/ov-base.h
diffstat 5 files changed, 51 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,24 @@
 2007-10-23  John W. Eaton  <jwe@octave.org>
 
+	* graphics.cc (is_handle (const graphics_handle&)): New function.
+	(gh_manager::do_free, reparent, base_properties::set_parent,
+	properties::get_title, properties::get_xlabel,
+	properties::get_ylabel, properties::get_zlabel,
+	properties::remove_child, make_graphics_object, F__go_figure__,
+	F__go_delete__, __go_axes_init__): Call OK on graphics handle
+	object instead of relying on implicit conversion operator.
+	* graphics.h.in (graphics_handle::operator double ()): Delete.
+	(graphics_handle::operator bool ()): Delete.
+	(gh_manager::do_handle_list, gh_manager::do_figure_handle_list,
+	base_properties::adopt): Call VALUE on graphics handle object
+	instead of relying on implicit conversion operator.
+
+	* ov-base.h (DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA): Call
+	DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2 with "( )" as arg list
+	instead of "()".
+
+	* mxarray.h.in (mxClassID): Delete trailing comma in enum decl.
+
 	* symtab.h (symbol_table::symbol_table): Reduce default table size
 	to 64.
 
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -461,7 +461,7 @@
 void
 gh_manager::do_free (const graphics_handle& h)
 {
-  if (h)
+  if (h.ok ())
     {
       if (h.value () != 0)
 	{
@@ -523,7 +523,7 @@
     {
       h = gh_manager::lookup (val);
 
-      if (h)
+      if (h.ok ())
 	{
 	  graphics_object obj = gh_manager::get_object (h);
 	  
@@ -576,6 +576,12 @@
 }
 
 static bool
+is_handle (const graphics_handle& h)
+{
+  return h.ok ();
+}
+
+static bool
 is_handle (double val)
 {
   graphics_handle h = gh_manager::lookup (val);
@@ -709,7 +715,7 @@
     {
       new_parent = gh_manager::lookup (tmp);
 
-      if (new_parent)
+      if (new_parent.ok ())
 	{
 	  graphics_object parent_obj = gh_manager::get_object (parent);
 
@@ -1374,7 +1380,7 @@
 graphics_handle
 axes::properties::get_title (void) const
 {
-  if (! title)
+  if (! title.ok ())
     title = gh_manager::make_graphics_handle ("text", __myhandle__);
 
   return title;
@@ -1383,7 +1389,7 @@
 graphics_handle
 axes::properties::get_xlabel (void) const
 {
-  if (! xlabel)
+  if (! xlabel.ok ())
     xlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
 
   return xlabel;
@@ -1392,7 +1398,7 @@
 graphics_handle
 axes::properties::get_ylabel (void) const
 {
-  if (! ylabel)
+  if (! ylabel.ok ())
     ylabel = gh_manager::make_graphics_handle ("text", __myhandle__);
 
   return ylabel;
@@ -1401,7 +1407,7 @@
 graphics_handle
 axes::properties::get_zlabel (void) const
 {
-  if (! zlabel)
+  if (! zlabel.ok ())
     zlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
 
   return zlabel;
@@ -1592,13 +1598,13 @@
 void
 axes::properties::remove_child (const graphics_handle& h)
 {
-  if (title && h == title)
+  if (title.ok () && h == title)
     title = gh_manager::make_graphics_handle ("text", __myhandle__);
-  else if (xlabel && h == xlabel)
+  else if (xlabel.ok () && h == xlabel)
     xlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
-  else if (ylabel && h == ylabel)
+  else if (ylabel.ok () && h == ylabel)
     ylabel = gh_manager::make_graphics_handle ("text", __myhandle__);
-  else if (zlabel && h == zlabel)
+  else if (zlabel.ok () && h == zlabel)
     zlabel = gh_manager::make_graphics_handle ("text", __myhandle__);
   else
     base_properties::remove_child (h);
@@ -2651,7 +2657,7 @@
     {
       graphics_handle parent = gh_manager::lookup (val);
 
-      if (parent)
+      if (parent.ok ())
 	{
 	  graphics_handle h
 	    = gh_manager::make_graphics_handle (go_name, parent);
@@ -2710,7 +2716,7 @@
 	      else
 		error ("__go_figure__: invalid figure number");
 
-	      if (! error_state && h)
+	      if (! error_state && h.ok ())
 		{
 		  adopt (0, h);
 
@@ -2813,7 +2819,7 @@
 	{
 	  h = gh_manager::lookup (val);
 
-	  if (h)
+	  if (h.ok ())
 	    {
 	      graphics_object obj = gh_manager::get_object (h);
 
@@ -2867,7 +2873,7 @@
 	{
 	  h = gh_manager::lookup (val);
 
-	  if (h)
+	  if (h.ok ())
 	    {
 	      graphics_object obj = gh_manager::get_object (h);
 
--- a/src/graphics.h.in
+++ b/src/graphics.h.in
@@ -464,8 +464,6 @@
 
   ~graphics_handle (void) { }
 
-  operator double (void) const { return val; }
-
   double value (void) const { return val; }
 
   octave_value as_octave_value (void) const
@@ -501,8 +499,6 @@
 
   bool ok (void) const { return ! xisnan (val); }
 
-  operator bool () const { return ok (); }
-
 private:
   double val;
 };
@@ -579,7 +575,7 @@
   {
     octave_idx_type n = children.numel ();
     children.resize (1, n+1);
-    children(n) = h;
+    children(n) = h.value ();
   }
 
   void set_parent (const octave_value& val);
@@ -1913,7 +1909,10 @@
     Matrix retval (1, handle_map.size ());
     octave_idx_type i = 0;
     for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++)
-      retval(i++) = p->first;
+      {
+	graphics_handle h = p->first;
+	retval(i++) = h.value ();
+      }
     return retval;
   }
 
@@ -1924,7 +1923,10 @@
     for (const_figure_list_iterator p = figure_list.begin ();
 	 p != figure_list.end ();
 	 p++)
-      retval(i++) = *p;
+      {
+	graphics_handle h = *p;
+	retval(i++) = h.value ();
+      }
     return retval;
   }
 
--- a/src/mxarray.h.in
+++ b/src/mxarray.h.in
@@ -71,7 +71,7 @@
     mxUINT32_CLASS,
     mxINT64_CLASS,
     mxUINT64_CLASS,
-    mxFUNCTION_CLASS,
+    mxFUNCTION_CLASS
   }
   mxClassID;
 
--- a/src/ov-base.h
+++ b/src/ov-base.h
@@ -61,7 +61,7 @@
 // T_ID is the type id of struct objects, set by register_type().
 // T_NAME is the type name of struct objects.
 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA \
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2()
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2 ( )
 
 #define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA \
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(virtual)