# HG changeset patch # User John W. Eaton # Date 1588352070 14400 # Node ID 48c1e8d88ea253a93dbd0ce1b0f31554c55303a8 # Parent d05a4194f1adfe6ad749399ad25defe46fe0a00c new functions for finding scoped functions and class methods * fcn-info.h, fcn-info.cc (fcn_info::find_scoped_function): New function. (fcn_info::fcn_info_rep::find_scoped_function): New function, extracted from fcn_info::fcn_info_rep::xfind. (fcn_info::fcn_info_rep::find_method (const octave_value_list&)): New function, extracted from fcn_info::fcn_info_rep::xfind. (fcn_info::fcn_info_rep::xfind): Use new find_scoped_function and find_method functions. diff -r d05a4194f1ad -r 48c1e8d88ea2 libinterp/corefcn/fcn-info.cc --- a/libinterp/corefcn/fcn-info.cc Wed Apr 15 23:14:06 2020 -0400 +++ b/libinterp/corefcn/fcn-info.cc Fri May 01 12:54:30 2020 -0400 @@ -625,11 +625,8 @@ } octave_value - fcn_info::fcn_info_rep::xfind (const symbol_scope& search_scope, - const octave_value_list& args) + fcn_info::fcn_info_rep::find_scoped_function (const symbol_scope& search_scope) { - // Subfunction, local function, or private function. - if (search_scope) { // Subfunction. @@ -697,17 +694,41 @@ } } - // Class methods. + return octave_value (); + } + octave_value + fcn_info::fcn_info_rep::find_method (const octave_value_list& args) + { if (! args.empty ()) { std::string dispatch_type = get_dispatch_type (args); - octave_value fcn = find_method (dispatch_type); + return find_method (dispatch_type); + } + + return octave_value (); + } + + octave_value + fcn_info::fcn_info_rep::xfind (const symbol_scope& search_scope, + const octave_value_list& args) + { + // Subfunction, local function, or private function. - if (fcn.is_defined ()) - return fcn; - } + octave_value fcn; + + fcn = find_scoped_function (search_scope); + + if (fcn.is_defined ()) + return fcn; + + // Class methods. + + fcn = find_method (args); + + if (fcn.is_defined ()) + return fcn; // Class constructors. The class name and function name are the same. @@ -745,7 +766,7 @@ // Autoload? - octave_value fcn = find_autoload (); + fcn = find_autoload (); if (fcn.is_defined ()) return fcn; diff -r d05a4194f1ad -r 48c1e8d88ea2 libinterp/corefcn/fcn-info.h --- a/libinterp/corefcn/fcn-info.h Wed Apr 15 23:14:06 2020 -0400 +++ b/libinterp/corefcn/fcn-info.h Fri May 01 12:54:30 2020 -0400 @@ -89,8 +89,12 @@ octave_value builtin_find (const symbol_scope& search_scope); + octave_value find_scoped_function (const symbol_scope& search_scope); + octave_value find_method (const std::string& dispatch_type); + octave_value find_method (const octave_value_list& args); + octave_value find_autoload (void); octave_value find_package (void); @@ -255,6 +259,11 @@ return m_rep->builtin_find (search_scope); } + octave_value find_scoped_function (const symbol_scope& search_scope) + { + return m_rep->find_scoped_function (search_scope); + } + octave_value find_method (const std::string& dispatch_type) const { return m_rep->find_method (dispatch_type);