GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-classdef.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2012-2024 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 <algorithm>
31 #include <iomanip>
32 
33 #include "cdef-class.h"
34 #include "cdef-method.h"
35 #include "cdef-package.h"
36 #include "cdef-property.h"
37 #include "cdef-utils.h"
38 #include "defun.h"
39 #include "errwarn.h"
40 #include "interpreter-private.h"
41 #include "load-path.h"
42 #include "ov-classdef.h"
43 #include "ov-fcn-handle.h"
44 #include "ov-typeinfo.h"
45 #include "ov-usr-fcn.h"
46 #include "parse.h"
47 #include "pr-output.h"
48 #include "pt-eval.h"
49 #include "pt-misc.h"
50 #include "oct-lvalue.h"
51 
52 static bool
53 in_class_method (const octave::cdef_class& cls)
54 {
55  octave::cdef_class ctx = octave::get_class_context ();
56 
57  return (ctx.ok () && octave::is_superclass (ctx, cls));
58 }
59 
60 int octave_classdef::s_t_id (-1);
61 
62 const std::string octave_classdef::s_t_name ("object");
63 
64 void
65 octave_classdef::register_type (octave::type_info& ti)
66 {
67  s_t_id = ti.register_type (octave_classdef::s_t_name, "<unknown>",
68  octave_value (new octave_classdef ()));
69 }
70 
72 octave_classdef::subsref (const std::string& type,
73  const std::list<octave_value_list>& idx,
74  int nargout)
75 {
76  std::size_t skip = 0;
77  octave_value_list retval;
78 
79  octave::cdef_class cls = m_object.get_class ();
80 
81  if (! in_class_method (cls) && ! called_from_builtin ())
82  {
83  octave::cdef_method meth = cls.find_method ("subsref");
84 
85  if (meth.ok ())
86  {
87  octave_value_list args;
88 
89  args(1) = make_idx_args (type, idx, "subsref");
90 
91  m_count++;
92  args(0) = octave_value (this);
93 
94  // If the number of output arguments is unknown, attempt to set up
95  // a proper value for nargout at least in the simple case where the
96  // cs-list-type expression - i.e., {} or ().x, is the leading one.
97  if (nargout <= 0)
98  {
99  bool maybe_cs_list_query = (type[0] == '.' || type[0] == '{'
100  || (type.length () > 1 && type[0] == '('
101  && type[1] == '.'));
102 
103  if (maybe_cs_list_query)
104  {
105  // Set up a proper nargout for the subsref call by calling numel.
106  octave_value_list tmp;
107  int nout;
108  if (type[0] != '.') tmp = idx.front ();
109  nout = xnumel (tmp);
110  if (nargout != 0 || nout > 1)
111  nargout = nout;
112  }
113  else if (nargout < 0)
114  nargout = 1;
115  }
116 
117  retval = meth.execute (args, nargout, true, "subsref");
118 
119  // Since we're handling subsref, if the list has more than one element
120  // and the caller to subsref accepts more that one output, return
121  // the elements as a comma-separated list so that we can pass it to the
122  // evaluator
123  if (retval.length () > 1 && (nargout < 0 || nargout > 1))
124  {
125  if (nargout <= 0 || nargout >= retval.length ())
126  // Take the whole list
127  retval = octave_value (retval);
128  else
129  // Take nargout elements of the list
130  retval = octave_value (retval.slice (0, nargout));
131  }
132 
133  return retval;
134  }
135  }
136 
137  // At this point, the default subsref mechanism must be used.
138 
139  retval = m_object.subsref (type, idx, nargout, skip, octave::cdef_class ());
140 
141  if (type.length () > skip && idx.size () > skip)
142  retval = retval(0).next_subsref (nargout, type, idx, skip);
143 
144  return retval;
145 }
146 
148 octave_classdef::subsref (const std::string& type,
149  const std::list<octave_value_list>& idx,
150  bool auto_add)
151 {
152  std::size_t skip = 0;
153  octave_value_list retval;
154 
155  // This variant of subsref is used to create temporary values when doing
156  // assignment with multi-level indexing. AFAIK this is only used for internal
157  // purpose (not sure we should even implement this).
158 
159  octave::cdef_class cls = m_object.get_class ();
160 
161  if (! in_class_method (cls))
162  {
163  octave::cdef_method meth = cls.find_method ("subsref");
164 
165  if (meth.ok ())
166  {
167  octave_value_list args;
168 
169  args(1) = make_idx_args (type, idx, "subsref");
170 
171  m_count++;
172  args(0) = octave_value (this);
173 
174  retval = meth.execute (args, 1, true, "subsref");
175 
176  return retval.length () > 0 ? retval(0) : octave_value ();
177  }
178  }
179 
180  retval = m_object.subsref (type, idx, 1, skip,
181  octave::cdef_class (), auto_add);
182 
183  if (type.length () > skip && idx.size () > skip)
184  retval = retval(0).next_subsref (1, type, idx, skip);
185 
186  return retval.length () > 0 ? retval(0) : octave_value ();
187 }
188 
190 octave_classdef::subsasgn (const std::string& type,
191  const std::list<octave_value_list>& idx,
192  const octave_value& rhs)
193 {
194  octave_value retval;
195 
196  octave::cdef_class cls = m_object.get_class ();
197 
198  if (! in_class_method (cls) && ! called_from_builtin ())
199  {
200  octave::cdef_method meth = cls.find_method ("subsasgn");
201 
202  if (meth.ok ())
203  {
204  octave_value_list args;
205 
206  args(1) = make_idx_args (type, idx, "subsasgn");
207 
208  m_count++;
209  args(0) = octave_value (this);
210  args(2) = rhs;
211 
212  octave_value_list retlist;
213 
214  retlist = meth.execute (args, 1, true, "subsasgn");
215 
216  if (retlist.empty ())
217  error ("overloaded method 'subsasgn' did not return any value");
218 
219  retval = retlist(0);
220  }
221  }
222 
223  if (! retval.is_defined ())
224  retval = m_object.subsasgn (type, idx, rhs);
225 
226  return retval;
227 }
228 
230 octave_classdef::undef_subsasgn (const std::string& type,
231  const std::list<octave_value_list>& idx,
232  const octave_value& rhs)
233 {
234  if (type.length () == 1 && type[0] == '(')
235  {
236  m_object = m_object.make_array ();
237 
238  return subsasgn (type, idx, rhs);
239  }
240  else
241  return octave_base_value::undef_subsasgn (type, idx, rhs);
242 
243  return octave_value ();
244 }
245 
246 Matrix
248 {
249  octave::cdef_class cls = m_object.get_class ();
250 
251  if (! in_class_method (cls) && ! called_from_builtin ())
252  {
253  octave::cdef_method meth = cls.find_method ("size");
254 
255  if (meth.ok ())
256  {
257  m_count++;
258  octave_value_list args (1, octave_value (this));
259 
260  octave_value_list lv = meth.execute (args, 1, true, "size");
261  if (lv.length () <= 0
262  || ! lv(0).is_matrix_type () || ! lv(0).dims ().isvector ())
263  error ("%s.size: invalid return value", class_name ().c_str ());
264 
265  return lv(0).matrix_value ();
266  }
267  }
268 
269  return octave_base_value::size ();
270 }
271 
274 {
275  octave_idx_type retval = -1;
276 
277  octave::cdef_class cls = m_object.get_class ();
278 
279  if (! in_class_method (cls) && ! called_from_builtin ())
280  {
281  octave::cdef_method meth = cls.find_method ("numel");
282 
283  if (meth.ok ())
284  {
285  octave_value_list args (idx.length () + 1, octave_value ());
286 
287  m_count++;
288  args(0) = octave_value (this);
289 
290  for (octave_idx_type i = 0; i < idx.length (); i++)
291  args(i+1) = idx(i);
292 
293  // Temporarily set lvalue list of current statement to NULL, to avoid
294  // using that list for the execution of the method "numel"
295  octave::interpreter& interp = octave::__get_interpreter__ ();
296  octave::tree_evaluator& tw = interp.get_evaluator();
297 
298  octave::unwind_action act ([&tw] (const std::list<octave::octave_lvalue> *lvl)
299  {
300  tw.set_lvalue_list (lvl);
301  }, tw.lvalue_list ());
302  tw.set_lvalue_list (nullptr);
303 
304  octave_value_list lv = meth.execute (args, 1, true, "numel");
305  if (lv.length () != 1 || ! lv(0).is_scalar_type ())
306  error ("@%s/numel: invalid return value", cls.get_name ().c_str ());
307 
308  retval = lv(0).idx_type_value (true);
309 
310  return retval;
311  }
312  }
313 
314  retval = octave_base_value::xnumel (idx);
315 
316  return retval;
317 }
318 
319 void
320 octave_classdef::print (std::ostream& os, bool)
321 {
322  print_raw (os);
323 }
324 
325 void
326 octave_classdef::print_raw (std::ostream& os, bool) const
327 {
328  octave::cdef_class cls = m_object.get_class ();
329 
330  if (cls.ok ())
331  {
332  bool is_array = m_object.is_array ();
333 
335 
336  indent (os);
337  os << class_name () << " object";
338  if (is_array)
339  os << " array";
340  os << " with properties:";
341  newline (os);
342  if (! Vcompact_format)
343  newline (os);
344 
346 
347  std::map<std::string, octave::cdef_property> property_map
348  = cls.get_property_map ();
349 
350  std::size_t max_len = 0;
351  for (const auto& pname_prop : property_map)
352  {
353  // FIXME: this loop duplicates a significant portion of the
354  // loop below and the loop in Fproperties.
355 
356  const octave::cdef_property& prop = pname_prop.second;
357 
358  const std::string nm = prop.get_name ();
359 
360  octave_value acc = prop.get ("GetAccess");
361 
362  if (! acc.is_string () || acc.string_value () != "public")
363  continue;
364 
365  octave_value hid = prop.get ("Hidden");
366 
367  if (hid.bool_value ())
368  continue;
369 
370  std::size_t sz = nm.size ();
371 
372  if (sz > max_len)
373  max_len = sz;
374  }
375 
376  for (auto& pname_prop : property_map)
377  {
378  const octave::cdef_property& prop = pname_prop.second;
379 
380  const std::string nm = prop.get_name ();
381 
382  octave_value acc = prop.get ("GetAccess");
383 
384  if (! acc.is_string () || acc.string_value () != "public")
385  continue;
386 
387  octave_value hid = prop.get ("Hidden");
388 
389  if (hid.bool_value ())
390  continue;
391 
392  indent (os);
393 
394  if (is_array)
395  os << " " << nm;
396  else
397  {
398  octave_value val = prop.get_value (m_object, false);
399  dim_vector dims = val.dims ();
400 
401  os << std::setw (max_len+2) << nm << ": ";
402  if (val.is_string ())
403  os << val.string_value ();
404  else if (val.islogical ())
405  os << val.bool_value ();
406  else
407  os << "[" << dims.str () << " " << val.class_name () << "]";
408  }
409 
410  newline (os);
411  }
412 
415  }
416 }
417 
418 bool
419 octave_classdef::is_instance_of (const std::string& cls_name) const
420 {
421  octave::cdef_class cls = octave::lookup_class (cls_name, false, false);
422 
423  if (cls.ok ())
424  return is_superclass (cls, m_object.get_class ());
425 
426  return false;
427 }
428 
430 octave_classdef::superclass_ref (const std::string& meth,
431  const std::string& cls)
432 {
433  return octave_value (new octave_classdef_superclass_ref (meth, cls));
434 }
435 
437 octave_classdef::metaclass_query (const std::string& cls)
438 {
439  return octave::to_ov (octave::lookup_class (cls));
440 }
441 
442 bool
443 octave_classdef_meta::is_classdef_method (const std::string& cname) const
444 {
445  bool retval = false;
446 
447  if (m_object.is_method ())
448  {
449  if (cname.empty ())
450  retval = true;
451  else
452  {
453  octave::cdef_method meth (m_object);
454 
455  return meth.is_defined_in_class (cname);
456  }
457  }
458 
459  return retval;
460 }
461 
462 bool
463 octave_classdef_meta::is_classdef_constructor (const std::string& cname) const
464 {
465  bool retval = false;
466 
467  if (m_object.is_class ())
468  {
469  if (cname.empty ())
470  retval = true;
471  else
472  {
473  octave::cdef_class cls (m_object);
474 
475  if (cls.get_name () == cname)
476  retval = true;
477  }
478  }
479  else if (m_object.is_method ())
480  {
481  octave::cdef_method meth (m_object);
482 
483  if (meth.is_constructor ())
484  {
485  std::string meth_name = meth.get_name ();
486 
487  // Only consider METH to be a constructor if the dispatch
488  // class CNAME is the same as or derived from the class of
489  // METH.
490 
491  if (cname == meth_name)
492  retval = true;
493  else
494  {
495  octave::cdef_class meth_cls = octave::lookup_class (meth_name, false, false);
496  octave::cdef_class dispatch_cls = octave::lookup_class (cname, false, false);
497 
498  retval = octave::is_superclass (meth_cls, dispatch_cls);
499  }
500  }
501  }
502 
503  return retval;
504 }
505 
506 std::string
507 octave_classdef_meta::doc_string (const std::string& meth_name) const
508 {
509  if (m_object.is_class ())
510  {
511  octave::cdef_class cls (m_object);
512 
513  if (meth_name.empty ())
514  return cls.doc_string ();
515 
516  octave::cdef_method cdef_meth = cls.find_method (meth_name);
517 
518  if (cdef_meth.ok ())
519  return cdef_meth.get_doc_string ();
520  }
521 
522  return "";
523 }
524 
525 std::string
527 {
528  if (m_object.is_class ())
529  {
530  octave::cdef_class cls (m_object);
531 
532  return cls.file_name ();
533  }
534 
535  return "";
536 }
537 
539 octave_classdef_superclass_ref::execute (octave::tree_evaluator& tw,
540  int nargout,
541  const octave_value_list& idx)
542 {
543  octave_value_list retval;
544 
545  std::string meth_name;
546  bool in_constructor;
547  octave::cdef_class ctx;
548 
549  ctx = octave::get_class_context (meth_name, in_constructor);
550 
551  if (! ctx.ok ())
552  error ("superclass calls can only occur in methods or constructors");
553 
554  std::string mname = m_method_name;
555  std::string cname = m_class_name;
556 
557  // CLS is the superclass. The lookup_class function handles
558  // pkg.class names.
559 
560  octave::cdef_class cls = octave::lookup_class (cname);
561 
562  if (in_constructor)
563  {
564  if (! is_direct_superclass (cls, ctx))
565  error ("'%s' is not a direct superclass of '%s'",
566  cname.c_str (), ctx.get_name ().c_str ());
567 
568  if (! is_constructed_object (tw, mname))
569  error ("cannot call superclass constructor with variable '%s'",
570  mname.c_str ());
571 
572  octave_value sym = tw.varval (mname);
573 
574  cls.run_constructor (octave::to_cdef_ref (sym), idx);
575 
576  retval(0) = sym;
577  }
578  else
579  {
580  std::size_t pos = mname.find ('.');
581 
582  octave::cdef_object obj;
583 
584  if (pos != std::string::npos)
585  {
586  // We are looking at obj.meth.
587 
588  std::string oname = m_method_name.substr (0, pos);
589  mname = mname.substr (pos + 1);
590 
591  octave_value tval = tw.varval (oname);
592 
593  // FIXME: Can we only call superclass methods on the current
594  // object? If so, and we are looking at something like
595  //
596  // function meth (obj, ...)
597  // obj.meth@superclass (...)
598  //
599  // Do we need to verify that the object that was passed to
600  // meth is the same as the object we find when looking up
601  // obj in the expression obj.meth? If so, what is the right
602  // way to perform that check?
603 
604  if (tval.is_classdef_object ())
605  {
606  octave_classdef *cdobj = tval.classdef_object_value ();
607 
608  obj = cdobj->get_object ();
609  }
610  }
611 
612  if (mname != meth_name)
613  error ("method name mismatch ('%s' != '%s')",
614  mname.c_str (), meth_name.c_str ());
615 
616  if (! is_strict_superclass (cls, ctx))
617  error ("'%s' is not a superclass of '%s'",
618  cname.c_str (), ctx.get_name ().c_str ());
619 
620  // I see 2 possible implementations here:
621  // 1) use cdef_object::subsref with a different class
622  // context; this avoids duplicating code, but
623  // assumes the object is always the first argument
624  // 2) lookup the method manually and call
625  // cdef_method::execute; this duplicates part of
626  // logic in cdef_object::subsref, but avoid the
627  // assumption of 1)
628  // Not being sure about the assumption of 1), I
629  // go with option 2) for the time being.
630 
631  octave::cdef_method meth = cls.find_method (meth_name, false);
632 
633  if (! meth.ok ())
634  error ("no method '%s' found in superclass '%s'",
635  meth_name.c_str (), cname.c_str ());
636 
637  retval = (obj.ok ()
638  ? meth.execute (obj, idx, nargout, true, meth_name)
639  : meth.execute (idx, nargout, true, meth_name));
640  }
641 
642  return retval;
643 }
644 
645 bool
646 octave_classdef_superclass_ref::is_constructed_object (octave::tree_evaluator& tw,
647  const std::string& nm)
648 {
649  octave_function *of = tw.current_function ();
650 
651  if (of->is_classdef_constructor ())
652  {
653  octave_user_function *uf = of->user_function_value (true);
654 
655  if (uf)
656  {
657  octave::tree_parameter_list *ret_list = uf->return_list ();
658 
659  if (ret_list && ret_list->length () == 1)
660  return (ret_list->front ()->name () == nm);
661  }
662  }
663 
664  return false;
665 }
666 
668 
669 DEFUN (__meta_get_package__, args, ,
670  doc: /* -*- texinfo -*-
671 @deftypefn {} {@var{pkg} =} __meta_get_package__ (@var{pkg_name})
672 Undocumented internal function.
673 @end deftypefn */)
674 {
675  if (args.length () != 1)
676  print_usage ();
677 
678  std::string cname = args(0).xstring_value ("PKG_NAME must be a string");
679 
680  return to_ov (lookup_package (cname));
681 }
682 
683 DEFUN (metaclass, args, ,
684  doc: /* -*- texinfo -*-
685 @deftypefn {} {@var{metaclass_obj} =} metaclass (obj)
686 Return the meta.class object corresponding to the class of @var{obj}.
687 @end deftypefn */)
688 {
689  if (args.length () != 1)
690  print_usage ();
691 
692  cdef_object obj = to_cdef (args(0));
693 
694  return to_ov (obj.get_class ());
695 }
696 
697 // FIXME: What about dynamic properties if obj is a scalar, or the
698 // properties of the class of obj if obj is an array? Probably there
699 // should be a function to do this job so that the DEFUN is just a
700 // simple wrapper.
701 
702 DEFUN (properties, args, nargout,
703  doc: /* -*- texinfo -*-
704 @deftypefn {} {} properties (@var{obj})
705 @deftypefnx {} {} properties (@var{class_name})
706 @deftypefnx {} {@var{proplist} =} properties (@dots{})
707 Display or return the public properties for the classdef object @var{obj} or
708 the named class @var{class_name}.
709 
710 If an output value is requested, return the list of property names in a cell
711 array.
712 
713 Programming Note: Property names are returned if the @code{GetAccess} attribute
714 is public and if the @code{Hidden} attribute is false.
715 @seealso{methods}
716 @end deftypefn */)
717 {
718  if (args.length () != 1)
719  print_usage ();
720 
721  octave_value arg = args(0);
722 
723  std::string class_name;
724 
725  if (arg.isobject ())
726  class_name = arg.class_name ();
727  else if (arg.is_string ())
728  class_name = arg.string_value ();
729  else
730  err_wrong_type_arg ("properties", arg);
731 
732  cdef_class cls;
733 
734  cls = lookup_class (class_name, false, true);
735 
736  if (! cls.ok ())
737  error ("invalid class: %s", class_name.c_str ());
738 
739  std::map<std::string, cdef_property> property_map =
740  cls.get_property_map ();
741 
742  std::list<std::string> property_names;
743 
744  for (const auto& pname_prop : property_map)
745  {
746  // FIXME: this loop duplicates a significant portion of the loops
747  // in octave_classdef::print_raw.
748  const cdef_property& prop = pname_prop.second;
749 
750  octave_value acc = prop.get ("GetAccess");
751 
752  if (! acc.is_string () || acc.string_value () != "public")
753  continue;
754 
755  octave_value hid = prop.get ("Hidden");
756 
757  if (hid.bool_value ())
758  continue;
759 
760  property_names.push_back (pname_prop.first);
761  }
762 
763  if (nargout > 0)
764  return octave_value (Cell (string_vector (property_names)));
765 
766  octave_stdout << "properties for class " << class_name << ":\n\n";
767 
768  for (const auto& nm : property_names)
769  octave_stdout << " " << nm << "\n";
770 
771  octave_stdout << std::endl;
772 
773  return octave_value ();
774 }
775 
776 /*
777 %!assert (properties ("inputParser"),
778 %! {"CaseSensitive"; "FunctionName"; "KeepUnmatched";
779 %! "Parameters"; "PartialMatching"; "Results";
780 %! "StructExpand"; "Unmatched"; "UsingDefaults"});
781 */
782 
783 // FIXME: Need to implement the -full option.
784 
785 DEFMETHOD (__methods__, interp, args, ,
786  doc: /* -*- texinfo -*-
787 @deftypefn {} {[@var{mtds}, @var{found}] =} __methods__ (@var{obj})
788 @deftypefnx {} {[@var{mtds}, @var{found}] =} __methods__ ("classname")
789 Implement @code{methods} for Octave class objects and classnames.
790 @seealso{methods}
791 @end deftypefn */)
792 {
793  // Input validation has already been done in methods.m.
794  octave_value arg = args(0);
795 
796  std::string class_name;
797 
798  if (arg.isobject ())
799  class_name = arg.class_name ();
800  else if (arg.is_string ())
801  class_name = arg.string_value ();
802  else
803  err_wrong_type_arg ("__methods__", arg);
804 
805  string_vector sv;
806  bool found = false;
807 
808  cdef_class cls = lookup_class (class_name, false, true);
809 
810  if (cls.ok ())
811  {
812  // Find methods for classdef objects.
813  std::map<std::string, cdef_method> method_map
814  = cls.get_method_map (false, true);
815 
816  std::list<std::string> method_names;
817 
818  for (const auto& nm_mthd : method_map)
819  {
820  const cdef_method& method = nm_mthd.second;
821 
822  octave_value acc = method.get ("Access");
823 
824  if (! acc.is_string () || acc.string_value () != "public")
825  continue;
826 
827  octave_value hid = method.get ("Hidden");
828 
829  if (hid.bool_value ())
830  continue;
831 
832  method_names.push_back (nm_mthd.first);
833  }
834 
835  sv = string_vector (method_names);
836  found = true;
837  }
838  else
839  {
840  // Find methods for legacy @CLASS objects.
841  load_path& lp = interp.get_load_path ();
842 
843  sv = string_vector (lp.methods (class_name));
844  found = ! sv.empty ();
845  }
846 
847  return ovl (Cell (sv), found);
848 }
849 
850 /*
851 // BIST tests are in file methods.m
852 %!assert (1)
853 */
854 
855 OCTAVE_END_NAMESPACE(octave)
bool isvector(const dim_vector &dim)
Definition: Array-util.cc:140
bool is_superclass(const cdef_class &clsa, const cdef_class &clsb, bool allow_equal, int max_depth)
Definition: cdef-utils.cc:200
bool is_strict_superclass(const cdef_class &clsa, const cdef_class &clsb)
Definition: cdef-utils.cc:226
cdef_object to_cdef(const octave_value &val)
Definition: cdef-utils.cc:143
cdef_object & to_cdef_ref(const octave_value &val)
Definition: cdef-utils.cc:152
cdef_class get_class_context(std::string &name, bool &in_constructor)
Definition: cdef-utils.cc:247
cdef_class lookup_class(const std::string &name, bool error_if_not_found, bool load_if_not_found)
Definition: cdef-utils.cc:80
octave_value to_ov(const cdef_object &obj)
Definition: cdef-utils.cc:128
cdef_package lookup_package(const std::string &name, bool error_if_not_found, bool load_if_not_found)
Definition: cdef-utils.cc:238
bool is_direct_superclass(const cdef_class &clsa, const cdef_class &clsb)
Definition: cdef-utils.cc:232
Definition: Cell.h:43
Definition: dMatrix.h:42
std::map< std::string, cdef_property > get_property_map(int mode=property_normal)
Definition: cdef-class.h:297
std::map< std::string, cdef_method > get_method_map(bool only_inherited=false, bool include_ctor=false)
Definition: cdef-class.h:279
cdef_class get_class() const
Definition: cdef-object.cc:183
bool ok() const
Definition: cdef-object.h:312
octave_value get(const std::string &pname) const
Definition: cdef-object.h:268
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
std::string str(char sep='x') const
Definition: dim-vector.cc:68
std::list< std::string > methods(const std::string &class_name, const std::string &pack_name="")
Definition: load-path.h:93
virtual bool is_scalar_type() const
Definition: ov-base.h:507
void increment_indent_level() const
Definition: ov-base.h:914
void indent(std::ostream &os) const
Definition: ov-base.cc:1369
virtual Matrix size()
Definition: ov-base.cc:223
void newline(std::ostream &os) const
Definition: ov-base.cc:1388
static void register_type()
Definition: ov-base.cc:101
octave::refcount< octave_idx_type > m_count
Definition: ov-base.h:933
virtual octave_idx_type xnumel(const octave_value_list &)
Definition: ov-base.cc:233
void decrement_indent_level() const
Definition: ov-base.h:917
virtual octave_user_function * user_function_value(bool silent=false)
Definition: ov-base.cc:949
virtual octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov-base.cc:363
friend class octave_value
Definition: ov-base.h:269
virtual bool is_matrix_type() const
Definition: ov-base.h:509
bool is_classdef_method(const std::string &cname="") const
Definition: ov-classdef.cc:443
std::string file_name() const
Definition: ov-classdef.cc:526
bool is_classdef_constructor(const std::string &cname="") const
Definition: ov-classdef.cc:463
std::string doc_string(const std::string &meth_name) const
Definition: ov-classdef.cc:507
octave_value_list execute(octave::tree_evaluator &tw, int nargout, const octave_value_list &idx)
Definition: ov-classdef.cc:539
void print(std::ostream &os, bool pr_as_read_syntax=false)
Definition: ov-classdef.cc:320
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov-classdef.cc:190
dim_vector dims() const
Definition: ov-classdef.h:129
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout)
Definition: ov-classdef.cc:72
bool is_instance_of(const std::string &cls_name) const
Definition: ov-classdef.cc:419
octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov-classdef.cc:230
octave::cdef_object get_object() const
Definition: ov-classdef.h:73
static octave_value metaclass_query(const std::string &cls)
Definition: ov-classdef.cc:437
octave_idx_type xnumel(const octave_value_list &)
Definition: ov-classdef.cc:273
static octave_value superclass_ref(const std::string &meth, const std::string &cls)
Definition: ov-classdef.cc:430
std::string class_name() const
Definition: ov-classdef.h:152
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-classdef.cc:326
virtual bool is_classdef_constructor(const std::string &="") const
Definition: ov-fcn.h:125
octave::tree_parameter_list * return_list()
Definition: ov-usr-fcn.h:386
bool empty() const
Definition: ovl.h:115
octave_value_list slice(octave_idx_type offset, octave_idx_type len, bool tags=false) const
Definition: ovl.h:131
octave_idx_type length() const
Definition: ovl.h:113
bool is_classdef_object() const
Definition: ov.h:655
std::string class_name() const
Definition: ov.h:1347
bool bool_value(bool warn=false) const
Definition: ov.h:885
bool is_string() const
Definition: ov.h:637
Matrix size()
Definition: ov.h:462
bool is_defined() const
Definition: ov.h:592
std::string string_value(bool force=false) const
Definition: ov.h:974
octave_classdef * classdef_object_value(bool silent=false) const
bool isobject() const
Definition: ov.h:664
bool islogical() const
Definition: ov.h:735
dim_vector dims() const
Definition: ov.h:541
bool empty() const
Definition: str-vec.h:77
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void print_usage(void)
Definition: defun-int.h:72
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:111
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
void() error(const char *fmt,...)
Definition: error.cc:988
void err_wrong_type_arg(const char *name, const char *s)
Definition: errwarn.cc:166
interpreter & __get_interpreter__()
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value make_idx_args(const std::string &type, const std::list< octave_value_list > &idx, const std::string &who)
Definition: ov-base.cc:1461
bool called_from_builtin()
Definition: ov-base.cc:1524
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:219
#define octave_stdout
Definition: pager.h:309
bool Vcompact_format
Definition: pr-output.cc:102