diff src/ov-class.cc @ 10926:f687bd17ce21

fix field assignment from private class methods
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 31 Aug 2010 08:04:05 +0200
parents 89f4d7e294cc
children 3a778233e4fb
line wrap: on
line diff
--- a/src/ov-class.cc	Mon Aug 30 19:03:25 2010 -0400
+++ b/src/ov-class.cc	Tue Aug 31 08:04:05 2010 +0200
@@ -116,10 +116,10 @@
     }
 }
 
-static std::string
-get_current_method_class (void)
+std::string
+octave_class::get_current_method_class (void)
 {
-  std::string retval;
+  std::string retval = class_name ();
 
   octave_function *fcn = octave_call_stack::current ();
 
@@ -256,12 +256,15 @@
   // Find the class in which this method resides before attempting to access
   // the requested field.
 
-  octave_base_value *obvp
-    = method_class.empty () ? 0 : find_parent_class (method_class);
+  octave_base_value *obvp = find_parent_class (method_class);
 
-  octave_map my_map;
+  if (obvp == 0)
+    {
+      error ("malformed class");
+      return retval;
+    }
 
-  my_map = obvp ? obvp->map_value () : map;
+  octave_map my_map = (obvp == this) ? obvp->map_value () : map;
 
   std::string nm = idx(0).string_value ();