changeset 28515:49f4d7814760 stable

find help for not-yet-loaded classdef methods defined in @DIR files. * cdef-method.h, cdef-method.cc (cdef_method::get_doc_string, (cdef_method::cdef_method_rep::get_doc_string): New methods. * ov-classdef.cc (octave_classdef_meta::doc_string): Use find_method to lookup classdef method definition instead of instead of get_method. If method is defined, use cdef_method::get_doc_string to access doc string.
author John W. Eaton <jwe@octave.org>
date Mon, 29 Jun 2020 15:01:27 -0400
parents fab862fedf85
children 70d155283f33 627da618dcc4
files libinterp/octave-value/cdef-method.cc libinterp/octave-value/cdef-method.h libinterp/octave-value/ov-classdef.cc
diffstat 3 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/cdef-method.cc	Fri May 29 10:57:04 2020 -0400
+++ b/libinterp/octave-value/cdef-method.cc	Mon Jun 29 15:01:27 2020 -0400
@@ -190,6 +190,16 @@
             : false);
   }
 
+  std::string
+  cdef_method::cdef_method_rep::get_doc_string (void)
+  {
+    check_method ();
+
+    octave_function *fcn = function.function_value ();
+
+    return fcn ? fcn->doc_string () : "";
+  }
+
   bool
   cdef_method::cdef_method_rep::check_access (void) const
   {
--- a/libinterp/octave-value/cdef-method.h	Fri May 29 10:57:04 2020 -0400
+++ b/libinterp/octave-value/cdef-method.h	Mon Jun 29 15:01:27 2020 -0400
@@ -73,6 +73,8 @@
 
       void set_function (const octave_value& fcn) { function = fcn; }
 
+      std::string get_doc_string (void);
+
       bool check_access (void) const;
 
       bool is_external (void) const { return ! dispatch_type.empty (); }
@@ -190,6 +192,11 @@
       return get_rep ()->get_function ();
     }
 
+    std::string get_doc_string (void)
+    {
+      return get_rep ()->get_doc_string ();
+    }
+
     bool is_constructor (void) const
     {
       return get_rep ()->is_constructor ();
--- a/libinterp/octave-value/ov-classdef.cc	Fri May 29 10:57:04 2020 -0400
+++ b/libinterp/octave-value/ov-classdef.cc	Mon Jun 29 15:01:27 2020 -0400
@@ -437,15 +437,10 @@
       if (meth_name.empty ())
         return cls.doc_string ();
 
-      octave_value ov_meth = cls.get_method (meth_name);
+      octave::cdef_method cdef_meth = cls.find_method (meth_name);
 
-      if (ov_meth.is_defined ())
-        {
-          octave_function *fcn = ov_meth.function_value ();
-
-          if (fcn)
-            return fcn->doc_string ();
-        }
+      if (cdef_meth.ok ())
+        return cdef_meth.get_doc_string ();
     }
 
   return "";