diff libinterp/octave-value/cdef-class.cc @ 26950:fbb318c371db

methods: return classdef constructors in list (bug #55858) * cdev-class.h, cdef-class.cc (cdef_class::get_methods, cdef_class::get_method_map, cdef_class:cdef_class_rep::get_methods, cdef_class::cdef_class_rep::get_methods_map): New parameter, INCLUDE_CTOR. (cdef_class::cdef_class_rep::find_methods): New parameter, INCLUDE_CTOR. If TRUE, return class constructor in the list. * ov-classdef.cc (Fmethods): Call get_method_map with INCLUDE_CTOR parameter set to true.
author John W. Eaton <jwe@octave.org>
date Wed, 20 Mar 2019 16:20:10 +0000
parents 71724787d972
children de826e69a5ea
line wrap: on
line diff
--- a/libinterp/octave-value/cdef-class.cc	Wed Mar 20 03:54:24 2019 +0000
+++ b/libinterp/octave-value/cdef-class.cc	Wed Mar 20 16:20:10 2019 +0000
@@ -284,11 +284,11 @@
   }
 
   Cell
-  cdef_class::cdef_class_rep::get_methods (void)
+  cdef_class::cdef_class_rep::get_methods (bool include_ctor)
   {
     std::map<std::string,cdef_method> meths;
 
-    find_methods (meths, false);
+    find_methods (meths, false, include_ctor);
 
     Cell c (meths.size (), 1);
 
@@ -301,19 +301,19 @@
   }
 
   std::map<std::string, cdef_method>
-  cdef_class::cdef_class_rep::get_method_map (bool only_inherited)
+  cdef_class::cdef_class_rep::get_method_map (bool only_inherited,
+                                              bool include_ctor)
   {
     std::map<std::string, cdef_method> methods;
 
-    find_methods (methods, only_inherited);
+    find_methods (methods, only_inherited, include_ctor);
 
     return methods;
   }
 
   void
-  cdef_class::cdef_class_rep::find_methods (std::map<std::string,
-                                            cdef_method>& meths,
-                                            bool only_inherited)
+  cdef_class::cdef_class_rep::find_methods (std::map<std::string, cdef_method>& meths,
+                                            bool only_inherited, bool include_ctor)
   {
     load_all_methods ();
 
@@ -321,7 +321,7 @@
 
     for (it = method_map.begin (); it != method_map.end (); ++it)
       {
-        if (! it->second.is_constructor ())
+        if (include_ctor || ! it->second.is_constructor ())
           {
             std::string nm = it->second.get_name ();
 
@@ -349,7 +349,7 @@
       {
         cdef_class cls = lookup_class (super_classes(i));
 
-        cls.get_rep ()->find_methods (meths, true);
+        cls.get_rep ()->find_methods (meths, true, false);
       }
   }