changeset 26594:088b8a2dcb06 stable

use @CLASS name when searching for @CLASS/METHOD (bug #55501) * help.cc (help_system::which): Return early if name is empty. * symtab.h, symtab.cc (symbol_table::find_function): Handle empty argument case with a separate function. (symbol_table::find_function (const std::string&)): New function. Handle @CLASS/FUNCTION case by forwarding to find_method. Otherwise, call existing find_function method with empty args.
author John W. Eaton <jwe@octave.org>
date Tue, 22 Jan 2019 07:45:08 -0500
parents 7f58079955b3
children a7d56e0a5c8c ee21e2bf3e50
files libinterp/corefcn/help.cc libinterp/corefcn/symtab.cc libinterp/corefcn/symtab.h
diffstat 3 files changed, 42 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc	Mon Jan 21 22:07:16 2019 -0800
+++ b/libinterp/corefcn/help.cc	Tue Jan 22 07:45:08 2019 -0500
@@ -237,14 +237,17 @@
   {
     std::string file;
 
-    type = "";
+    if (name.empty ())
+      return file;
 
-    symbol_table& symtab = m_interpreter.get_symbol_table ();
-
-    octave_value val = symtab.find_function (name);
+    type = "";
 
     if (name.find_first_of ('.') == std::string::npos)
       {
+        symbol_table& symtab = m_interpreter.get_symbol_table ();
+
+        octave_value val = symtab.find_function (name);
+
         if (val.is_defined ())
           {
             octave_function *fcn = val.function_value ();
--- a/libinterp/corefcn/symtab.cc	Mon Jan 21 22:07:16 2019 -0800
+++ b/libinterp/corefcn/symtab.cc	Tue Jan 22 07:45:08 2019 -0500
@@ -401,6 +401,27 @@
     return octave_value ();
   }
 
+  octave_value symbol_table::find_function (const std::string& name)
+  {
+    if (name.empty ())
+      return octave_value ();
+
+    if (name[0] == '@')
+      {
+        size_t pos = name.find_first_of ('/');
+
+        if (pos == std::string::npos)
+          return octave_value ();
+
+        std::string method = name.substr (pos+1);
+        std::string dispatch_type = name.substr (1, pos-1);
+
+        return find_method (method, dispatch_type);
+      }
+    else
+      return find_function (name, ovl ());
+  }
+
   octave_value
   symbol_table::find_function (const std::string& name,
                                const octave_value_list& args)
--- a/libinterp/corefcn/symtab.h	Mon Jan 21 22:07:16 2019 -0800
+++ b/libinterp/corefcn/symtab.h	Tue Jan 22 07:45:08 2019 -0500
@@ -212,9 +212,21 @@
     fcn_table_find (const std::string& name,
                     const octave_value_list& args = octave_value_list ());
 
+    // If NAME is of the form @CLASS/FUNCTION, call
+    //
+    //   find_method (FUNCTION, CLASS)
+    //
+    // otherwise call
+    //
+    //   function_function (NAME, ovl ())
+
+    octave_value find_function (const std::string& name);
+
+    // NAME should just be function name; dispatch type determined
+    // from types of ARGS.
+
     octave_value
-    find_function (const std::string& name,
-                   const octave_value_list& args = octave_value_list ());
+    find_function (const std::string& name, const octave_value_list& args);
 
     octave_value find_user_function (const std::string& name)
     {