changeset 28434:48c1e8d88ea2 stable

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.
author John W. Eaton <jwe@octave.org>
date Fri, 01 May 2020 12:54:30 -0400
parents d05a4194f1ad
children 76a9f31540e3
files libinterp/corefcn/fcn-info.cc libinterp/corefcn/fcn-info.h
diffstat 2 files changed, 40 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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);