Mercurial > hg > octave-lyh
diff src/ov-class.cc @ 9156:b2b8ed43b922
ov-class.cc: don't dispatch subsref or subsasgn when called from builtin
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 27 Apr 2009 14:22:15 -0400 |
parents | d8f9588c6ba1 |
children | 23af5910e5f5 |
line wrap: on
line diff
--- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -96,6 +96,8 @@ static std::string get_current_method_class (void) { + std::string retval; + // FIXME -- is there a better way to do this? octave_function *fcn = octave_call_stack::current (); @@ -103,9 +105,10 @@ size_t ipos = my_dir.find_last_of ("@"); - assert (ipos != std::string::npos); + if (ipos != std::string::npos) + retval = my_dir.substr (ipos+1); - return my_dir.substr (ipos+1); + return retval; } static void @@ -235,7 +238,8 @@ // Find the class in which this method resides before attempting to access // the requested field. - octave_base_value *obvp = find_parent_class (method_class); + octave_base_value *obvp + = method_class.empty () ? 0 : find_parent_class (method_class); Octave_map my_map; @@ -258,6 +262,20 @@ return retval; } +static bool +called_from_builtin (void) +{ + octave_function *fcn = octave_call_stack::caller (); + + // FIXME -- we probably need a better check here, or some other + // mechanism to avoid overloaded functions when builtin is used. + // For example, what if someone overloads the builtin function? + // Also, are there other places where using builtin is not properly + // avoiding dispatch? + + return (fcn && fcn->name () == "builtin"); +} + octave_value_list octave_class::subsref (const std::string& type, const std::list<octave_value_list>& idx, @@ -265,7 +283,7 @@ { octave_value_list retval; - if (in_class_method ()) + if (in_class_method () || called_from_builtin ()) { // FIXME -- this block of code is the same as the body of // octave_struct::subsref. Maybe it could be shared instead of @@ -383,7 +401,7 @@ { octave_value retval; - if (! in_class_method ()) + if (! (in_class_method () || called_from_builtin ())) { octave_value meth = symbol_table::find_method ("subsasgn", class_name ());