# HG changeset patch # User Jaroslav Hajek # Date 1248416000 -7200 # Node ID 0c7d84a65386ebd9ca84c53e740b9f5e0a4a9392 # Parent f9fb8c1a8e45add106efab5da93857154863c996 allow taking handles of methods with no base overload diff -r f9fb8c1a8e45 -r 0c7d84a65386 src/ChangeLog --- a/src/ChangeLog Thu Jul 23 18:04:49 2009 -0400 +++ b/src/ChangeLog Fri Jul 24 08:13:20 2009 +0200 @@ -1,3 +1,13 @@ +2009-07-24 Jaroslav Hajek + + * load-path.cc (load_path::do_any_class_method): New method. + * load-path.h (load_path::do_any_class_method): New method decl. + (load_path::any_class_method): New method. + * ov-fcn-handle.cc (octave_fcn_handle::do_multi_index_op): Support + calls without non-overloaded base function. + (make_fcn_handle): Support creation without non-overloaded base + function. + 2009-07-23 Shai Ayal * DLD-FUNCTIONS/fltk_backend.cc (plot_window::pixel2axes_or_ca): diff -r f9fb8c1a8e45 -r 0c7d84a65386 src/load-path.cc --- a/src/load-path.cc Thu Jul 23 18:04:49 2009 -0400 +++ b/src/load-path.cc Fri Jul 24 08:13:20 2009 +0200 @@ -1091,6 +1091,28 @@ return retval; } +bool +load_path::do_any_class_method (const std::string& meth) const +{ + bool retval = false; + + // update (); + + for (const_method_map_iterator q = method_map.begin (); + q != method_map.end (); q++) + { + const fcn_map_type& m = q->second; + + if (m.find (meth) != m.end ()) + { + retval = true; + break; + } + } + + return retval; +} + std::string load_path::do_find_file (const std::string& file) const { diff -r f9fb8c1a8e45 -r 0c7d84a65386 src/load-path.h --- a/src/load-path.h Thu Jul 23 18:04:49 2009 -0400 +++ b/src/load-path.h Fri Jul 24 08:13:20 2009 +0200 @@ -108,6 +108,12 @@ ? instance->do_methods (class_name) : std::list (); } + static bool any_class_method (const std::string& meth) + { + return instance_ok () + ? instance->do_any_class_method (meth) : false; + } + static std::string find_fcn (const std::string& fcn, std::string& dir_name) { return instance_ok () @@ -479,6 +485,8 @@ std::list do_methods (const std::string& class_name) const; + bool do_any_class_method (const std::string& meth) const; + std::string do_find_file (const std::string& file) const; std::string do_find_dir (const std::string& dir) const; diff -r f9fb8c1a8e45 -r 0c7d84a65386 src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Thu Jul 23 18:04:49 2009 -0400 +++ b/src/ov-fcn-handle.cc Fri Jul 24 08:13:20 2009 +0200 @@ -122,7 +122,8 @@ { octave_value_list retval; - out_of_date_check (fcn); + if (fcn.is_defined ()) + out_of_date_check (fcn); if (disp.get () && ! args.empty ()) { @@ -155,6 +156,13 @@ if (ovfcn.is_defined ()) retval = ovfcn.do_multi_index_op (nargout, args); + else if (fcn.is_undefined ()) + { + if (ddt.empty ()) + ddt = args(0).class_name (); + + error ("no %s method to handle class %s", nm.c_str (), ddt.c_str ()); + } else error ("invalid function handle"); } @@ -1429,15 +1437,32 @@ } } + bool handle_ok = false; octave_value f = symbol_table::find_function (tnm); + + if (f.is_undefined ()) + { + if (load_path::any_class_method (tnm)) + handle_ok = true; + else + { + load_path::update (); + if (load_path::any_class_method (tnm)) + handle_ok = true; + } + } + else + handle_ok = true; + octave_function *fptr = f.is_defined () ? f.function_value () : 0; - if (fptr) + + if (handle_ok) { // If it's a subfunction, private function, or class constructor, // we want no dispatch. - if (fptr->is_nested_function () || fptr->is_private_function () - || fptr->is_class_constructor ()) + if (fptr && (fptr->is_nested_function () || fptr->is_private_function () + || fptr->is_class_constructor ())) retval = octave_value (new octave_fcn_handle (f, tnm)); else {