GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
cdef-manager.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2012-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "cdef-manager.h"
31 #include "cdef-utils.h"
32 #include "interpreter.h"
33 #include "ov-classdef.h"
34 
35 namespace octave
36 {
37  static octave_value
38  make_fcn_handle (octave_builtin::fcn ff, const std::string& nm)
39  {
40  octave_value fcn (new octave_builtin (ff, nm));
41 
42  return octave_value (new octave_fcn_handle (fcn));
43  }
44 
45  static octave_value_list
46  class_get_properties (const octave_value_list& args, int /* nargout */)
47  {
49 
50  if (args.length () == 1 && args(0).type_name () == "object")
51  {
52  cdef_class cls (to_cdef (args(0)));
53 
54  retval(0) = cls.get_properties ();
55  }
56 
57  return retval;
58  }
59 
60  static octave_value_list
61  class_get_methods (const octave_value_list& args, int /* nargout */)
62  {
64 
65  if (args.length () == 1 && args(0).type_name () == "object")
66  {
67  cdef_class cls (to_cdef (args(0)));
68 
69  retval(0) = cls.get_methods ();
70  }
71 
72  return retval;
73  }
74 
75  static octave_value_list
76  class_get_superclasses (const octave_value_list& args, int /* nargout */)
77  {
79 
80  if (args.length () == 1 && args(0).type_name () == "object"
81  && args(0).class_name () == "meta.class")
82  {
83  cdef_class cls (to_cdef (args(0)));
84 
85  Cell classes = cls.get ("SuperClasses").cell_value ();
86 
87  retval(0) = to_ov (lookup_classes (classes));
88  }
89 
90  return retval;
91  }
92 
93  static octave_value_list
94  class_get_inferiorclasses (const octave_value_list& args, int /* nargout */)
95  {
97 
98  if (args.length () == 1 && args(0).type_name () == "object"
99  && args(0).class_name () == "meta.class")
100  {
101  cdef_class cls (to_cdef (args(0)));
102 
103  Cell classes = cls.get ("InferiorClasses").cell_value ();
104 
105  retval(0) = to_ov (lookup_classes (classes));
106  }
107 
108  return retval;
109  }
110 
111  static octave_value_list
112  class_fromName (const octave_value_list& args, int /* nargout */)
113  {
115 
116  if (args.length () != 1)
117  error ("fromName: invalid number of parameters");
118 
119  std::string name = args(0).xstring_value ("fromName: CLASS_NAME must be a string");
120 
121  retval(0) = to_ov (lookup_class (name, false));
122 
123  return retval;
124  }
125 
126  static octave_value_list
127  class_fevalStatic (const octave_value_list& args, int nargout)
128  {
129  if (args.length () <= 1 || args(0).type_name () != "object")
130  error ("fevalStatic: first argument must be a meta.class object");
131 
132  cdef_class cls (to_cdef (args(0)));
133 
134  std::string meth_name = args(1).xstring_value ("fevalStatic: method name must be a string");
135 
136  cdef_method meth = cls.find_method (meth_name);
137 
138  if (! meth.ok ())
139  error ("fevalStatic: method not found: %s", meth_name.c_str ());
140 
141  if (! meth.is_static ())
142  error ("fevalStatic: method '%s' is not static", meth_name.c_str ());
143 
144  return meth.execute (args.splice (0, 2), nargout, true, "fevalStatic");
145  }
146 
147  static octave_value_list
148  class_getConstant (const octave_value_list& args, int /* nargout */)
149  {
151 
152  if (args.length () != 2 || args(0).type_name () != "object"
153  || args(0).class_name () != "meta.class")
154  error ("getConstant: first argument must be a meta.class object");
155 
156  cdef_class cls = to_cdef (args(0));
157 
158  std::string prop_name = args(1).xstring_value ("getConstant: property name must be a string");
159 
160  cdef_property prop = cls.find_property (prop_name);
161 
162  if (! prop.ok ())
163  error ("getConstant: property not found: %s",
164  prop_name.c_str ());
165 
166  if (! prop.is_constant ())
167  error ("getConstant: property '%s' is not constant",
168  prop_name.c_str ());
169 
170  retval(0) = prop.get_value (true, "getConstant");
171 
172  return retval;
173  }
174 
175 #define META_CLASS_CMP(OP, CLSA, CLSB, FUN) \
176  static octave_value_list \
177  class_ ## OP (const octave_value_list& args, int /* nargout */) \
178  { \
179  octave_value_list retval; \
180  \
181  if (args.length () != 2 \
182  || args(0).type_name () != "object" \
183  || args(1).type_name () != "object" \
184  || args(0).class_name () != "meta.class" \
185  || args(1).class_name () != "meta.class") \
186  error (#OP ": invalid arguments"); \
187  \
188  cdef_class clsa = to_cdef (args(0)); \
189  \
190  cdef_class clsb = to_cdef (args(1)); \
191  \
192  retval(0) = FUN (CLSA, CLSB); \
193  \
194  return retval; \
195  }
196 
198  META_CLASS_CMP (le, clsb, clsa, is_superclass)
200  META_CLASS_CMP (ge, clsa, clsb, is_superclass)
201  META_CLASS_CMP (eq, clsa, clsb, operator==)
202  META_CLASS_CMP (ne, clsa, clsb, operator!=)
203 
204  static octave_value_list
205  property_get_defaultvalue (const octave_value_list& args, int /* nargout */)
206  {
208 
209  if (args.length () == 1 && args(0).type_name () == "object")
210  {
211  cdef_property prop (to_cdef (args(0)));
212 
213  retval(0) = prop.get ("DefaultValue");
214 
215  if (! retval(0).is_defined ())
216  error_with_id ("Octave:class:NoDefaultDefined",
217  "no default value for property '%s'",
218  prop.get_name ().c_str ());
219  }
220 
221  return retval;
222  }
223 
224  static octave_value_list
225  handle_delete (const octave_value_list& /* args */, int /* nargout */)
226  {
228 
229  // FIXME: implement this. Wait, what is this supposed to do?
230 
231  return retval;
232  }
233 
234  static octave_value_list
235  package_get_classes (const octave_value_list& args, int /* nargout */)
236  {
238 
239  if (args.length () == 1 && args(0).type_name () == "object"
240  && args(0).class_name () == "meta.package")
241  {
242  cdef_package pack (to_cdef (args(0)));
243 
244  retval(0) = pack.get_classes ();
245  }
246 
247  return retval;
248  }
249 
250  static octave_value_list
251  package_get_functions (const octave_value_list& args, int /* nargout */)
252  {
254 
255  if (args.length () == 0 && args(0).type_name () == "object"
256  && args(0).class_name () == "meta.package")
257  {
258  cdef_package pack (to_cdef (args(0)));
259 
260  retval(0) = pack.get_functions ();
261  }
262 
263  return retval;
264  }
265 
266  static octave_value_list
267  package_get_packages (const octave_value_list& args, int /* nargout */)
268  {
270 
271  if (args.length () == 0 && args(0).type_name () == "object"
272  && args(0).class_name () == "meta.package")
273  {
274  cdef_package pack (to_cdef (args(0)));
275 
276  retval(0) = pack.get_packages ();
277  }
278 
279  return retval;
280  }
281 
282  static octave_value_list
284  const octave_value_list& /* args */, int /* nargout */)
285  {
286  std::map<std::string, cdef_package> toplevel_packages;
287 
288  load_path& lp = interp.get_load_path ();
289 
290  std::list<std::string> names = lp.get_all_package_names ();
291 
292  cdef_manager& cdm = interp.get_cdef_manager ();
293 
294  toplevel_packages["meta"] = cdm.find_package ("meta", false, false);
295 
296  for (const auto& nm : names)
297  toplevel_packages[nm] = cdm.find_package (nm, false, true);
298 
299  Cell c (toplevel_packages.size (), 1);
300 
301  int i = 0;
302 
303  for (const auto& nm_pkg : toplevel_packages)
304  c(i++,0) = to_ov (nm_pkg.second);
305 
306  return octave_value_list (octave_value (c));
307  }
308 
309  static octave_value_list
310  package_fromName (const octave_value_list& args, int /* nargout */)
311  {
313 
314  if (args.length () != 1)
315  error ("fromName: invalid number of parameters");
316 
317  std::string name = args(0).xstring_value ("fromName: PACKAGE_NAME must be a string");
318 
319  retval(0) = to_ov (lookup_package (name, false));
320 
321  return retval;
322  }
323 
325  : m_interpreter (interp), m_all_classes (), m_all_packages (),
326  m_meta_class (), m_meta_property (), m_meta_method (),
327  m_meta_package (), m_meta ()
328  {
330 
332 
333  // bootstrap
334  cdef_class tmp_handle = make_class ("handle");
335 
336  m_meta_class = make_meta_class ("meta.class", tmp_handle);
337 
338  tmp_handle.set_class (m_meta_class);
340 
341  // meta classes
342  m_meta_property = make_meta_class ("meta.property", tmp_handle);
343 
344  m_meta_method = make_meta_class ("meta.method", tmp_handle);
345 
346  m_meta_package = make_meta_class ("meta.package", tmp_handle);
347 
348  cdef_class tmp_meta_event
349  = make_meta_class ("meta.event", tmp_handle);
350 
351  cdef_class tmp_meta_dynproperty
352  = make_meta_class ("meta.dynamicproperty", tmp_handle);
353 
354  // meta.class properties
356  (make_attribute (m_meta_class, "Abstract"));
357 
359  (make_attribute (m_meta_class, "ConstructOnLoad"));
360 
362  (make_property (m_meta_class, "ContainingPackage"));
363 
365  (make_property (m_meta_class, "Description"));
366 
368  (make_property (m_meta_class, "DetailedDescription"));
369 
371  (make_property (m_meta_class, "Events"));
372 
374  (make_attribute (m_meta_class, "HandleCompatible"));
375 
377  (make_attribute (m_meta_class, "Hidden"));
378 
380  (make_property (m_meta_class, "InferiorClasses",
382  "meta.class>get.InferiorClasses"),
383  "public", Matrix (), "private"));
384 
386  (make_property (m_meta_class, "Methods",
388  "meta.class>get.Methods"),
389  "public", Matrix (), "private"));
390 
392  (make_property (m_meta_class, "MethodList",
394  "meta.class>get.MethodList"),
395  "public", Matrix (), "private"));
396 
398 
400  (make_property (m_meta_class, "Properties",
402  "meta.class>get.Properties"),
403  "public", Matrix (), "private"));
404 
406  (make_property (m_meta_class, "PropertyList",
408  "meta.class>get.PropertyList"),
409  "public", Matrix (), "private"));
410 
412 
414  (make_property (m_meta_class, "SuperClasses",
416  "meta.class>get.SuperClasses"),
417  "public", Matrix (), "private"));
418 
420  (make_property (m_meta_class, "SuperclassList",
422  "meta.class>get.SuperclassList"),
423  "public", Matrix (), "private"));
424 
425  // FIXME: Matlab supports this property under "SuperclassList".
426  // Octave, however, has supported this under "SuperClassList".
427  // Alias the property. Remove in Octave version 8.1.
429  (make_property (m_meta_class, "SuperClassList",
431  "meta.class>get.SuperclassList"),
432  "public", Matrix (), "private"));
433 
434  // meta.class methods
436  (make_method (m_meta_class, "fromName", class_fromName, "public", true));
437 
439  (make_method (m_meta_class, "fevalStatic", class_fevalStatic, "public",
440  false));
441 
443  (make_method (m_meta_class, "getConstant", class_getConstant, "public",
444  false));
445 
452 
453  // meta.method properties
455  (make_attribute (m_meta_method, "Abstract"));
456 
458  (make_attribute (m_meta_method, "Access"));
459 
461  (make_attribute (m_meta_method, "DefiningClass"));
462 
464  (make_attribute (m_meta_method, "Description"));
465 
467  (make_attribute (m_meta_method, "DetailedDescription"));
468 
470  (make_attribute (m_meta_method, "Hidden"));
471 
473  (make_attribute (m_meta_method, "Name"));
474 
476  (make_attribute (m_meta_method, "Sealed"));
477 
479  (make_attribute (m_meta_method, "Static"));
480 
481  // meta.property properties
483  (make_attribute (m_meta_property, "Name"));
484 
486  (make_attribute (m_meta_property, "Description"));
487 
489  (make_attribute (m_meta_property, "DetailedDescription"));
490 
492  (make_attribute (m_meta_property, "Abstract"));
493 
495  (make_attribute (m_meta_property, "Constant"));
496 
498  (make_attribute (m_meta_property, "GetAccess"));
499 
501  (make_attribute (m_meta_property, "SetAccess"));
502 
504  (make_attribute (m_meta_property, "Dependent"));
505 
507  (make_attribute (m_meta_property, "Transient"));
508 
510  (make_attribute (m_meta_property, "Hidden"));
511 
513  (make_attribute (m_meta_property, "GetObservable"));
514 
516  (make_attribute (m_meta_property, "SetObservable"));
517 
519  (make_attribute (m_meta_property, "GetMethod"));
520 
522  (make_attribute (m_meta_property, "SetMethod"));
523 
525  (make_attribute (m_meta_property, "DefiningClass"));
526 
528  (make_property (m_meta_property, "DefaultValue",
530  "meta.property>get.DefaultValue"),
531  "public", Matrix (), "private"));
532 
534  (make_attribute (m_meta_property, "HasDefault"));
535 
536  // meta.property events
537  // FIXME: add events
538 
539  // handle methods
540 
541  tmp_handle.install_method
542  (make_method (tmp_handle, "delete", handle_delete));
543 
544  // meta.package properties
545 
547  (make_attribute (m_meta_package, "Name"));
548 
550  (make_property (m_meta_package, "ContainingPackage"));
551 
553  (make_property (m_meta_package, "ClassList",
555  "meta.package>get.ClassList"),
556  "public", Matrix (), "private"));
557 
559  (make_property (m_meta_package, "Classes",
561  "meta.package>get.Classes"),
562  "public", Matrix (), "private"));
563 
565  (make_property (m_meta_package, "FunctionList",
567  "meta.package>get.FunctionList"),
568  "public", Matrix (), "private"));
569 
571  (make_property (m_meta_package, "Functions",
573  "meta.package>get.Functions"),
574  "public", Matrix (), "private"));
575 
577  (make_property (m_meta_package, "PackageList",
579  "meta.package>get.PackageList"),
580  "public", Matrix (), "private"));
581 
583  (make_property (m_meta_package, "Packages",
585  "meta.package>get.Packages"),
586  "public", Matrix (), "private"));
587 
590  "public", true));
591 
594  "public", true));
595 
596  // create "meta" package
597  cdef_package package_meta
598  = m_meta
599  = make_package ("meta");
600 
601  package_meta.install_class (m_meta_class, "class");
602  package_meta.install_class (m_meta_property, "property");
603  package_meta.install_class (m_meta_method, "method");
604  package_meta.install_class (m_meta_package, "package");
605  package_meta.install_class (tmp_meta_event, "event");
606  package_meta.install_class (tmp_meta_dynproperty, "dynproperty");
607 
609 
610  // install built-in classes into the symbol table
612  ("meta.class", m_meta_class.get_constructor_function ());
613 
615  ("meta.method", m_meta_method.get_constructor_function ());
616 
618  ("meta.property", m_meta_property.get_constructor_function ());
619 
621  ("meta.package", m_meta_package.get_constructor_function ());
622 
623  // FIXME: meta.event and meta.dynproperty are not implemented
624  // and should not be installed into symbol table.
625 
626  // symtab.install_built_in_function
627  // ("meta.event", tmp_meta_event.get_constructor_function ());
628 
629  // symtab.install_built_in_function
630  // ("meta.dynproperty", tmp_meta_dynproperty.get_constructor_function ());
631  }
632 
633  cdef_class
634  cdef_manager::find_class (const std::string& name, bool error_if_not_found,
635  bool load_if_not_found)
636  {
637  auto it = m_all_classes.find (name);
638 
639  if (it == m_all_classes.end ())
640  {
641  if (load_if_not_found)
642  {
643  octave_value ov_cls;
644 
645  size_t pos = name.rfind ('.');
646 
647  if (pos == std::string::npos)
648  ov_cls = m_interpreter.find (name);
649  else
650  {
651  std::string pack_name = name.substr (0, pos);
652 
653  cdef_package pack = find_package (pack_name, false, true);
654 
655  if (pack.ok ())
656  ov_cls = pack.find (name.substr (pos+1));
657  }
658 
659  if (ov_cls.is_defined ())
660  it = m_all_classes.find (name);
661  }
662  }
663 
664  if (it == m_all_classes.end ())
665  {
666  if (error_if_not_found)
667  error ("class not found: %s", name.c_str ());
668  }
669  else
670  {
671  cdef_class cls = it->second;
672 
673  if (! cls.is_builtin ())
674  cls = lookup_class (cls);
675 
676  if (cls.ok ())
677  return cls;
678  else
679  m_all_classes.erase (it);
680  }
681 
682  return cdef_class ();
683  }
684 
686  cdef_manager::find_method_symbol (const std::string& method_name,
687  const std::string& class_name)
688  {
689  cdef_class cls = find_class (class_name, false, false);
690 
691  if (cls.ok ())
692  {
693  cdef_method meth = cls.find_method (method_name);
694 
695  if (meth.ok ())
696  return octave_value (new octave_classdef_meta (meth));
697  }
698 
699  return octave_value ();
700  }
701 
703  cdef_manager::find_package (const std::string& name, bool error_if_not_found,
704  bool load_if_not_found)
705  {
707 
708  std::map<std::string, cdef_package>::const_iterator it
709  = m_all_packages.find (name);
710 
711  if (it != m_all_packages.end ())
712  {
713  retval = it->second;
714 
715  if (! retval.ok ())
716  error ("invalid package '%s'", name.c_str ());
717  }
718  else
719  {
721 
722  if (load_if_not_found && lp.find_package (name))
723  {
724  size_t pos = name.rfind ('.');
725 
726  if (pos == std::string::npos)
727  retval = make_package (name, "");
728  else
729  {
730  std::string parent_name = name.substr (0, pos);
731 
732  retval = make_package (name, parent_name);
733  }
734  }
735  else if (error_if_not_found)
736  error ("unknown package '%s'", name.c_str ());
737  }
738 
739  return retval;
740  }
741 
743  cdef_manager::find_package_symbol (const std::string& pack_name)
744  {
745  cdef_package pack = find_package (pack_name, false);
746 
747  if (pack.ok ())
748  return octave_value (new octave_classdef_meta (pack));
749 
750  return octave_value ();
751  }
752 
753  cdef_class
754  cdef_manager::make_class (const std::string& name,
755  const std::list<cdef_class>& super_list)
756  {
757  cdef_class cls (name, super_list);
758 
759  cls.set_class (meta_class ());
760 
761  cls.put ("Abstract", false);
762  cls.put ("ConstructOnLoad", false);
763  cls.put ("ContainingPackage", Matrix ());
764  cls.put ("Description", "");
765  cls.put ("DetailedDescription", "");
766  cls.put ("Events", Cell ());
767  cls.put ("Hidden", false);
768  cls.put ("InferiorClasses", Cell ());
769  cls.put ("Methods", Cell ());
770  cls.put ("Properties", Cell ());
771  cls.put ("Sealed", false);
772 
773  if (name == "handle")
774  {
775  cls.put ("HandleCompatible", true);
776  cls.mark_as_handle_class ();
777  }
778  else if (super_list.empty ())
779  {
780  cls.put ("HandleCompatible", false);
781  }
782  else
783  {
784  bool all_handle_compatible = true;
785  bool has_handle_class = false;
786 
787  for (const auto& cl : super_list)
788  {
789  all_handle_compatible = all_handle_compatible
790  && cl.get ("HandleCompatible").bool_value ();
791 
792  has_handle_class = has_handle_class || cl.is_handle_class ();
793  }
794 
795  if (has_handle_class && ! all_handle_compatible)
796  error ("%s: cannot mix handle and non-HandleCompatible classes",
797  name.c_str ());
798 
799  cls.put ("HandleCompatible", all_handle_compatible);
800  if (has_handle_class)
801  cls.mark_as_handle_class ();
802  }
803 
804  if (! name.empty ())
805  register_class (cls);
806 
807  return cls;
808  }
809 
810  cdef_class
811  cdef_manager::make_class (const std::string& name,
812  const cdef_class& super)
813  {
814  return make_class (name, std::list<cdef_class> (1, super));
815  }
816 
817  cdef_class
818  cdef_manager::make_meta_class (const std::string& name,
819  const cdef_class& super)
820  {
821  cdef_class cls = make_class (name, super);
822 
823  cls.put ("Sealed", true);
824  cls.mark_as_meta_class ();
825 
826  return cls;
827  }
828 
830  cdef_manager::make_property (const cdef_class& cls, const std::string& name,
831  const octave_value& get_method,
832  const std::string& get_access,
833  const octave_value& set_method,
834  const std::string& set_access)
835  {
836  cdef_property prop (name);
837 
838  prop.set_class (meta_property ());
839 
840  prop.put ("Description", "");
841  prop.put ("DetailedDescription", "");
842  prop.put ("Abstract", false);
843  prop.put ("Constant", false);
844  prop.put ("GetAccess", get_access);
845  prop.put ("SetAccess", set_access);
846  prop.put ("Dependent", false);
847  prop.put ("Transient", false);
848  prop.put ("Hidden", false);
849  prop.put ("GetObservable", false);
850  prop.put ("SetObservable", false);
851  prop.put ("GetMethod", get_method);
852  prop.put ("SetMethod", set_method);
853  prop.put ("DefiningClass", to_ov (cls));
854  prop.put ("DefaultValue", octave_value ());
855  prop.put ("HasDefault", false);
856 
857  std::string class_name = cls.get_name ();
858 
859  if (! get_method.isempty ())
860  make_function_of_class (class_name, get_method);
861  if (! set_method.isempty ())
862  make_function_of_class (class_name, set_method);
863 
864  return prop;
865  }
866 
868  cdef_manager::make_attribute (const cdef_class& cls, const std::string& name)
869  {
870  return make_property (cls, name, Matrix (), "public", Matrix (), "private");
871  }
872 
874  cdef_manager::make_method (const cdef_class& cls, const std::string& name,
875  const octave_value& fcn,
876  const std::string& m_access, bool is_static)
877  {
878  cdef_method meth (name);
879 
880  meth.set_class (meta_method ());
881 
882  meth.put ("Abstract", false);
883  meth.put ("Access", m_access);
884  meth.put ("DefiningClass", to_ov (cls));
885  meth.put ("Description", "");
886  meth.put ("DetailedDescription", "");
887  meth.put ("Hidden", false);
888  meth.put ("Sealed", true);
889  meth.put ("Static", is_static);
890 
891  if (fcn.is_defined ())
892  make_function_of_class (cls, fcn);
893 
894  meth.set_function (fcn);
895 
896  if (is_dummy_method (fcn))
897  meth.mark_as_external (cls.get_name ());
898 
899  return meth;
900  }
901 
903  cdef_manager::make_method (const cdef_class& cls, const std::string& name,
905  const std::string& m_access, bool is_static)
906  {
907  octave_value fcn (new octave_builtin (ff, name));
908 
909  return make_method (cls, name, fcn, m_access, is_static);
910  }
911 
913  cdef_manager::make_method (const cdef_class& cls, const std::string& name,
915  const std::string& m_access, bool is_static)
916  {
917  octave_value fcn (new octave_builtin (mm, name));
918 
919  return make_method (cls, name, fcn, m_access, is_static);
920  }
921 
923  cdef_manager::make_package (const std::string& nm, const std::string& parent)
924  {
925  cdef_package pack (nm);
926 
927  pack.set_class (meta_package ());
928 
929  if (parent.empty ())
930  pack.put ("ContainingPackage", Matrix ());
931  else
932  pack.put ("ContainingPackage", to_ov (find_package (parent)));
933 
934  if (! nm.empty ())
935  register_package (pack);
936 
937  return pack;
938  }
939 
941  cdef_manager::find_method (const std::string& class_name,
942  const std::string& name) const
943  {
944  cdef_class cls = lookup_class (class_name);
945 
946  return cls.get_method (name);
947  }
948 }
#define META_CLASS_CMP(OP, CLSA, CLSB, FUN)
Definition: Cell.h:43
Definition: dMatrix.h:42
Cell get_methods(bool include_ctor=false)
Definition: cdef-class.h:259
void install_property(const cdef_property &prop)
Definition: cdef-class.h:272
bool is_builtin(void) const
Definition: cdef-class.h:306
void install_method(const cdef_method &meth)
Definition: cdef-class.h:254
cdef_method find_method(const std::string &nm, bool local=false)
Definition: cdef-class.h:438
cdef_property find_property(const std::string &nm)
Definition: cdef-class.h:444
octave_value get_method(const std::string &nm) const
Definition: cdef-class.h:337
Cell get_properties(int mode=property_normal)
Definition: cdef-class.h:277
void mark_as_handle_class(void)
Definition: cdef-class.h:369
std::string get_name(void) const
Definition: cdef-class.h:304
void mark_as_meta_class(void)
Definition: cdef-class.h:379
octave_value get_constructor_function(void)
Definition: cdef-class.h:344
octave_value find_method_symbol(const std::string &method_name, const std::string &class_name)
std::map< std::string, cdef_package > m_all_packages
Definition: cdef-manager.h:145
cdef_class m_meta_class
Definition: cdef-manager.h:147
cdef_class find_class(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
interpreter & m_interpreter
Definition: cdef-manager.h:139
std::map< std::string, cdef_class > m_all_classes
Definition: cdef-manager.h:142
cdef_property make_property(const cdef_class &cls, const std::string &name, const octave_value &get_method=Matrix(), const std::string &get_access="public", const octave_value &set_method=Matrix(), const std::string &set_access="public")
cdef_class m_meta_method
Definition: cdef-manager.h:149
const cdef_class & meta_package(void) const
Definition: cdef-manager.h:91
void register_package(const cdef_package &pkg)
Definition: cdef-manager.h:78
cdef_class make_meta_class(const std::string &name, const cdef_class &super)
cdef_package make_package(const std::string &nm, const std::string &parent="")
cdef_class m_meta_package
Definition: cdef-manager.h:150
cdef_manager(interpreter &interp)
void register_class(const cdef_class &cls)
Definition: cdef-manager.h:68
octave_value find_package_symbol(const std::string &pack_name)
cdef_method make_method(const cdef_class &cls, const std::string &name, const octave_value &fcn, const std::string &m_access="public", bool is_static=false)
const cdef_class & meta_property(void) const
Definition: cdef-manager.h:89
cdef_class m_meta_property
Definition: cdef-manager.h:148
const cdef_class & meta_method(void) const
Definition: cdef-manager.h:90
cdef_package m_meta
Definition: cdef-manager.h:152
cdef_class make_class(const std::string &name, const std::list< cdef_class > &super_list=std::list< cdef_class >())
cdef_package find_package(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
cdef_property make_attribute(const cdef_class &cls, const std::string &name)
const cdef_class & meta_class(void) const
Definition: cdef-manager.h:88
octave_value find_method(const std::string &class_name, const std::string &name) const
octave_value_list execute(const octave_value_list &args, int nargout, bool do_check_access=true, const std::string &who="")
Definition: cdef-method.h:163
bool is_static(void) const
Definition: cdef-method.h:183
void mark_as_external(const std::string &dtype)
Definition: cdef-method.h:212
void set_function(const octave_value &fcn)
Definition: cdef-method.h:185
void put(const std::string &pname, const octave_value &val)
Definition: cdef-object.h:256
void set_class(const cdef_class &cls)
Definition: cdef-object.h:226
bool ok(void) const
Definition: cdef-object.h:300
octave_value get(const std::string &pname) const
Definition: cdef-object.h:261
octave_value find(const std::string &nm)
Definition: cdef-package.h:207
Cell get_functions(void) const
Definition: cdef-package.h:195
Cell get_classes(void) const
Definition: cdef-package.h:190
Cell get_packages(void) const
Definition: cdef-package.h:200
void install_class(const cdef_class &cls, const std::string &nm)
Definition: cdef-package.h:175
octave_value get_value(const cdef_object &obj, bool do_check_access=true, const std::string &who="") const
bool is_constant(void) const
std::string get_name(void) const
load_path & get_load_path(void)
Definition: interpreter.h:243
cdef_manager & get_cdef_manager(void)
Definition: interpreter.h:280
type_info & get_type_info(void)
Definition: interpreter.h:253
symbol_table & get_symbol_table(void)
Definition: interpreter.h:258
octave_value find(const std::string &name)
std::list< std::string > get_all_package_names(bool only_top_level=true) const
Definition: load-path.cc:524
bool find_package(const std::string &package_name) const
Definition: load-path.h:103
void install_built_in_function(const std::string &name, const octave_value &fcn)
Definition: symtab.cc:401
static void register_type(void)
Definition: ov-base.cc:99
octave_value_list(* fcn)(const octave_value_list &, int)
Definition: ov-builtin.h:63
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
Definition: ov-builtin.h:60
octave_idx_type length(void) const
Definition: ovl.h:113
octave_value_list splice(octave_idx_type offset, octave_idx_type len, const octave_value_list &lst=octave_value_list()) const
Definition: ovl.cc:139
bool is_defined(void) const
Definition: ov.h:551
Cell cell_value(void) const
bool isempty(void) const
Definition: ov.h:557
void error_with_id(const char *id, const char *fmt,...)
Definition: error.cc:1013
void error(const char *fmt,...)
Definition: error.cc:968
QString name
static octave_value_list class_le(const octave_value_list &args, int)
bool is_superclass(const cdef_class &clsa, const cdef_class &clsb, bool allow_equal, int max_depth)
Definition: cdef-utils.cc:200
static octave_value_list class_gt(const octave_value_list &args, int)
static octave_value_list class_get_methods(const octave_value_list &args, int)
Definition: cdef-manager.cc:61
std::list< cdef_class > lookup_classes(const Cell &cls_list)
Definition: cdef-utils.cc:113
static octave_value_list handle_delete(const octave_value_list &, int)
void make_function_of_class(const std::string &class_name, const octave_value &fcn)
Definition: cdef-utils.cc:55
bool is_dummy_method(const octave_value &fcn)
Definition: cdef-utils.cc:179
octave_value to_ov(const cdef_object &obj)
Definition: cdef-utils.cc:128
static octave_value_list class_fromName(const octave_value_list &args, int)
static octave_value_list package_get_packages(const octave_value_list &args, int)
cdef_object to_cdef(const octave_value &val)
Definition: cdef-utils.cc:143
static octave_value_list class_get_superclasses(const octave_value_list &args, int)
Definition: cdef-manager.cc:76
static octave_value_list package_getAllPackages(interpreter &interp, const octave_value_list &, int)
static octave_value_list class_get_properties(const octave_value_list &args, int)
Definition: cdef-manager.cc:46
static octave_value_list property_get_defaultvalue(const octave_value_list &args, int)
static octave_value_list class_get_inferiorclasses(const octave_value_list &args, int)
Definition: cdef-manager.cc:94
static octave_value_list class_ge(const octave_value_list &args, int)
cdef_package lookup_package(const std::string &name, bool error_if_not_found, bool load_if_not_found)
Definition: cdef-utils.cc:238
static octave_value_list class_eq(const octave_value_list &args, int)
cdef_class lookup_class(const std::string &name, bool error_if_not_found, bool load_if_not_found)
Definition: cdef-utils.cc:80
static octave_value_list class_lt(const octave_value_list &args, int)
static octave_value_list class_fevalStatic(const octave_value_list &args, int nargout)
static octave_value_list class_getConstant(const octave_value_list &args, int)
static octave_value_list package_get_functions(const octave_value_list &args, int)
static octave_value_list class_ne(const octave_value_list &args, int)
static octave_value_list package_get_classes(const octave_value_list &args, int)
static octave_value_list package_fromName(const octave_value_list &args, int)
bool is_strict_superclass(const cdef_class &clsa, const cdef_class &clsb)
Definition: cdef-utils.cc:226
static octave_value make_fcn_handle(const octave_value &fcn, const std::string &meth_name, const std::string &class_name)
Definition: cdef-class.cc:66
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
Definition: ov.cc:811