GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-classdef.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-2017 Michael Goffioul
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_classdef_h)
24 #define octave_classdef_h 1
25 
26 #include "octave-config.h"
27 
28 #include <map>
29 #include <set>
30 #include <string>
31 
32 #include "oct-map.h"
33 #include "oct-refcount.h"
34 #include "ov-base.h"
35 #include "symtab.h"
36 
37 class cdef_object;
38 class cdef_class;
39 class cdef_property;
40 class cdef_method;
41 class cdef_package;
42 
43 class tree_classdef;
44 
45 // This is mainly a boostrap class to declare the expected interface.
46 // The actual base class is cdef_class_base, which is declared after
47 // cdef_object, such that it can contain cdef_object objects.
48 class
50 {
51 public:
52  friend class cdef_object;
53 
54 public:
55  cdef_object_rep (void) : refcount (1) { }
56 
57  virtual ~cdef_object_rep (void) { }
58 
59  virtual cdef_class get_class (void) const;
60 
61  virtual void set_class (const cdef_class&)
62  { err_invalid_object ("set_class"); }
63 
64  virtual cdef_object_rep* clone (void) const
65  {
66  err_invalid_object ("clone");
67  }
68 
69  virtual cdef_object_rep* empty_clone (void) const
70  {
71  err_invalid_object ("empty_clone");
72  }
73 
74  virtual cdef_object_rep* copy (void) const
75  {
76  err_invalid_object ("copy");
77  }
78 
79  virtual cdef_object_rep* make_array (void) const
80  {
81  err_invalid_object ("make_array");
82  }
83 
84  virtual bool is_array (void) const { return false; }
85 
86  virtual bool is_value_object (void) const { return false; }
87 
88  virtual bool is_handle_object (void) const { return false; }
89 
90  virtual bool is_meta_object (void) const { return false; }
91 
92  virtual Array<cdef_object> array_value (void) const
93  {
94  err_invalid_object ("array_value");
95  }
96 
97  virtual void put (const std::string&, const octave_value&)
98  { err_invalid_object ("put"); }
99 
100  virtual octave_value get (const std::string&) const
101  {
102  err_invalid_object ("get");
103  }
104 
105  virtual octave_value_list
106  subsref (const std::string&, const std::list<octave_value_list>&,
107  int, size_t&, const cdef_class&, bool)
108  {
109  err_invalid_object ("subsref");
110  }
111 
112  virtual octave_value
113  subsasgn (const std::string&, const std::list<octave_value_list>&,
114  const octave_value&)
115  {
116  err_invalid_object ("subsasgn");
117  }
118 
119  virtual string_vector map_keys (void) const;
120 
121  virtual bool is_valid (void) const { return false; }
122 
123  std::string class_name (void) const;
124 
125  virtual void mark_for_construction (const cdef_class&)
126  {
127  err_invalid_object ("mark_for_construction");
128  }
129 
130  virtual bool is_constructed_for (const cdef_class&) const
131  {
132  err_invalid_object ("is_constructed_for");
133  }
134 
135  virtual bool is_partially_constructed_for (const cdef_class&) const
136  {
137  err_invalid_object ("is_partially_constructed_for");
138  }
139 
140  virtual void mark_as_constructed (void)
141  {
142  err_invalid_object ("mark_as_constructed");
143  }
144 
145  virtual void mark_as_constructed (const cdef_class&)
146  {
147  err_invalid_object ("mark_as_constructed");
148  }
149 
150  virtual bool is_constructed (void) const
151  {
152  err_invalid_object ("is_constructed");
153  }
154 
155  virtual octave_idx_type static_count (void) const { return 0; }
156 
157  virtual void destroy (void) { delete this; }
158 
159  void release (void)
160  {
161  if (--refcount == static_count ())
162  destroy ();
163  }
164 
165  virtual dim_vector dims (void) const { return dim_vector (); }
166 
167 protected:
168  // Reference count
170 
171 protected:
172  // Restricted copying
174  : refcount (1) { }
175 
176 private:
177  // No assignment
179 
180  OCTAVE_NORETURN void err_invalid_object (const char *who) const
181  { error ("%s: invalid object", who); }
182 };
183 
184 class
186 {
187 public:
188  // FIXME: use a null object
189  cdef_object (void)
190  : rep (new cdef_object_rep ()) { }
191 
193  : rep (obj.rep)
194  {
195  rep->refcount++;
196  }
197 
199  : rep (r) { }
200 
201  virtual ~cdef_object (void)
202  { rep->release (); }
203 
205  {
206  if (rep != obj.rep)
207  {
208  rep->release ();
209 
210  rep = obj.rep;
211  rep->refcount++;
212  }
213 
214  return *this;
215  }
216 
217  cdef_class get_class (void) const;
218 
219  void set_class (const cdef_class& cls) { rep->set_class (cls); }
220 
221  std::string class_name (void) const
222  { return rep->class_name (); }
223 
224  cdef_object clone (void) const
225  { return cdef_object (rep->clone ()); }
226 
228  { return cdef_object (rep->empty_clone ()); }
229 
230  dim_vector dims (void) const { return rep->dims (); }
231 
232  cdef_object make_array (void) const
233  { return cdef_object (rep->make_array ()); }
234 
235  cdef_object copy (void) const
236  { return cdef_object (rep->copy ()); }
237 
238  bool is_array (void) const { return rep->is_array (); }
239 
240  bool is_value_object (void) const { return rep->is_value_object (); }
241 
242  bool is_handle_object (void) const { return rep->is_handle_object (); }
243 
244  bool is_meta_object (void) const { return rep->is_meta_object (); }
245 
246  Array<cdef_object> array_value (void) const { return rep->array_value (); }
247 
248  void put (const std::string& pname, const octave_value& val)
249  { rep->put (pname, val); }
250 
251  octave_value get (const std::string& pname) const
252  { return rep->get (pname); }
253 
255  subsref (const std::string& type, const std::list<octave_value_list>& idx,
256  int nargout, size_t& skip, const cdef_class& context,
257  bool auto_add = false)
258  { return rep->subsref (type, idx, nargout, skip, context, auto_add); }
259 
261  subsasgn (const std::string& type, const std::list<octave_value_list>& idx,
262  const octave_value& rhs, int ignore_copies = 0)
263  {
264  make_unique (ignore_copies);
265  return rep->subsasgn (type, idx, rhs);
266  }
267 
268  string_vector map_keys (void) const { return rep->map_keys (); }
269 
270  octave_map map_value (void) const;
271 
272  const cdef_object_rep* get_rep (void) const { return rep; }
273 
274  bool ok (void) const { return rep->is_valid (); }
275 
277  { rep->mark_for_construction (cls); }
278 
279  bool is_constructed (void) const { return rep->is_constructed (); }
280 
281  bool is_constructed_for (const cdef_class& cls) const
282  { return rep->is_constructed_for (cls); }
283 
284  bool is_partially_constructed_for (const cdef_class& cls) const
285  { return rep->is_partially_constructed_for (cls); }
286 
288 
289  void mark_as_constructed (const cdef_class& cls)
290  { rep->mark_as_constructed (cls); }
291 
292  bool is (const cdef_object& obj) const { return rep == obj.rep; }
293 
294 protected:
295  cdef_object_rep* get_rep (void) { return rep; }
296 
297  void make_unique (int ignore_copies)
298  {
299  if (rep->refcount > ignore_copies + 1)
300  *this = clone ();
301  }
302 
303 private:
305 };
306 
307 class
309 {
310 public:
312  : cdef_object_rep (), klass ()
313  {
314  register_object ();
315  }
316 
317  ~cdef_object_base (void) { unregister_object (); }
318 
319  cdef_class get_class (void) const;
320 
321  void set_class (const cdef_class& cls);
322 
324  { return new cdef_object_base (*this); }
325 
326  cdef_object_rep* make_array (void) const;
327 
328 protected:
329  // Restricted copying!
331  : cdef_object_rep (obj), klass (obj.klass)
332  {
333  register_object ();
334  }
335 
336 private:
337  void register_object (void);
338 
339  void unregister_object (void);
340 
341 private:
342  // The class of the object
344 
345 private:
346  // No assignment!
348 };
349 
350 class
352 {
353 public:
355 
357  : cdef_object_base (), array (a) { }
358 
359  cdef_object_rep* clone (void) const
360  { return new cdef_object_array (*this); }
361 
362  dim_vector dims (void) const { return array.dims (); }
363 
364  bool is_valid (void) const { return true; }
365 
366  bool is_array (void) const { return true; }
367 
368  Array<cdef_object> array_value (void) const { return array; }
369 
371  subsref (const std::string& type, const std::list<octave_value_list>& idx,
372  int nargout, size_t& skip, const cdef_class& context,
373  bool auto_add);
374 
376  subsasgn (const std::string& type, const std::list<octave_value_list>& idx,
377  const octave_value& rhs);
378 
379 private:
381 
382 private:
383  void fill_empty_values (void) { fill_empty_values (array); }
384 
385  void fill_empty_values (Array<cdef_object>& arr);
386 
387  // Private copying!
389  : cdef_object_base (obj), array (obj.array) { }
390 
391  // No assignment!
393 };
394 
395 class
397 {
398 public:
400 
402 
403  dim_vector dims (void) const { return dim_vector (1, 1); }
404 
405  void put (const std::string& pname, const octave_value& val)
406  { map.assign (pname, val); }
407 
408  octave_value get (const std::string& pname) const
409  {
410  Cell val = map.contents (pname);
411 
412  if (val.numel () < 1)
413  error ("get: unknown slot: %s", pname.c_str ());
414 
415  return val(0, 0);
416  }
417 
419  subsref (const std::string& type, const std::list<octave_value_list>& idx,
420  int nargout, size_t& skip, const cdef_class& context,
421  bool auto_add);
422 
424  subsasgn (const std::string& type, const std::list<octave_value_list>& idx,
425  const octave_value& rhs);
426 
427  void mark_for_construction (const cdef_class&);
428 
429  bool is_constructed_for (const cdef_class& cls) const;
430 
431  bool is_partially_constructed_for (const cdef_class& cls) const;
432 
433  void mark_as_constructed (void) { ctor_list.clear (); }
434 
435  void mark_as_constructed (const cdef_class& cls);
436 
437  bool is_constructed (void) const { return ctor_list.empty (); }
438 
439 protected:
440  // Object property values
442 
443  // Internal/temporary structure used during object construction
444  std::map< cdef_class, std::list<cdef_class> > ctor_list;
445 
446 protected:
447  // Restricted object copying!
449  : cdef_object_base (obj), map (obj.map), ctor_list (obj.ctor_list) { }
450 
451 private:
452  // No assignment!
454 };
455 
456 class
458 {
459 public:
461  : cdef_object_scalar () { }
462 
463  ~handle_cdef_object (void);
464 
465  cdef_object_rep* clone (void) const
466  {
467  handle_cdef_object *obj = const_cast<handle_cdef_object *> (this);
468  obj->refcount++;
469  return obj;
470  }
471 
472  cdef_object_rep* copy (void) const
473  { return new handle_cdef_object (*this); }
474 
475  bool is_valid (void) const { return true; }
476 
477  bool is_handle_object (void) const { return true; }
478 
479 protected:
480  // Restricted copying!
482  : cdef_object_scalar (obj) { }
483 
484 private:
485  // No assignment
487 };
488 
489 class
491 {
492 public:
494  : cdef_object_scalar () { }
495 
496  ~value_cdef_object (void);
497 
498  cdef_object_rep* clone (void) const
499  { return new value_cdef_object (*this); }
500 
501  cdef_object_rep* copy (void) const { return clone (); }
502 
503  bool is_valid (void) const { return true; }
504 
505  bool is_value_object (void) const { return true; }
506 
507 private:
508  // Private copying!
510  : cdef_object_scalar (obj) { }
511 
512  // No assignment!
514 };
515 
516 class
518 {
519 public:
521  : handle_cdef_object () { }
522 
524 
525  cdef_object_rep* copy (void) const
526  { return new cdef_meta_object_rep (*this); }
527 
528  bool is_meta_object (void) const { return true; }
529 
530  virtual bool is_class (void) const { return false; }
531 
532  virtual bool is_property (void) const { return false; }
533 
534  virtual bool is_method (void) const { return false; }
535 
536  virtual bool is_package (void) const { return false; }
537 
538  virtual octave_value_list
539  meta_subsref (const std::string& /* type */,
540  const std::list<octave_value_list>& /* idx */,
541  int /* nargout */)
542  {
543  error ("subsref: invalid meta object");
544  }
545 
546  virtual void meta_release (void) { }
547 
548  virtual bool meta_is_postfix_index_handled (char /* type */) const
549  { return false; }
550 
551 protected:
552  // Restricted copying!
554  : handle_cdef_object (obj) { }
555 
556 private:
557  // No assignment!
559 };
560 
561 class
563 {
564 public:
566  : cdef_object () { }
567 
569  : cdef_object (obj) { }
570 
572  : cdef_object (r) { }
573 
574  // Object consistency is checked in sub-classes.
576  : cdef_object (obj) { }
577 
578  ~cdef_meta_object (void) { }
579 
580  bool is_class (void) const { return get_rep ()->is_class (); }
581 
582  bool is_property (void) const { return get_rep ()->is_property (); }
583 
584  bool is_method (void) const { return get_rep ()->is_method (); }
585 
586  bool is_package (void) const { return get_rep ()->is_package (); }
587 
590  const std::list<octave_value_list>& idx, int nargout)
591  { return get_rep ()->meta_subsref (type, idx, nargout); }
592 
593  void meta_release (void) { get_rep ()->meta_release (); }
594 
596  { return get_rep ()->meta_is_postfix_index_handled (type); }
597 
598 private:
600  { return dynamic_cast<cdef_meta_object_rep *> (cdef_object::get_rep ()); }
601 
602  const cdef_meta_object_rep* get_rep (void) const
603  { return dynamic_cast<const cdef_meta_object_rep *> (cdef_object::get_rep ()); }
604 };
605 
606 class
608 {
609 private:
610 
611  class
613  {
614  public:
616  : cdef_meta_object_rep (), member_count (0), handle_class (false),
617  object_count (0), meta (false) { }
618 
619  cdef_class_rep (const std::list<cdef_class>& superclasses);
620 
621  cdef_object_rep* copy (void) const { return new cdef_class_rep (*this); }
622 
623  bool is_class (void) const { return true; }
624 
625  std::string get_name (void) const
626  { return get ("Name").string_value (); }
627 
628  void set_name (const std::string& nm) { put ("Name", nm); }
629 
630  bool is_abstract (void) const { return get ("Abstract").bool_value (); }
631 
632  bool is_sealed (void) const { return get ("Sealed").bool_value (); }
633 
634  cdef_method find_method (const std::string& nm, bool local = false);
635 
636  void install_method (const cdef_method& meth);
637 
638  Cell get_methods (void);
639 
640  cdef_property find_property (const std::string& nm);
641 
642  void install_property (const cdef_property& prop);
643 
644  Cell get_properties (int mode);
645 
646  std::map<std::string, cdef_property> get_property_map (int mode);
647 
648  string_vector get_names (void);
649 
650  void set_directory (const std::string& dir) { directory = dir; }
651 
652  std::string get_directory (void) const { return directory; }
653 
654  void delete_object (cdef_object obj);
655 
657  meta_subsref (const std::string& type,
658  const std::list<octave_value_list>& idx, int nargout);
659 
660  void meta_release (void);
661 
663  { return (type == '(' || type == '.'); }
664 
665  octave_value construct (const octave_value_list& args);
666 
667  cdef_object construct_object (const octave_value_list& args);
668 
669  void initialize_object (cdef_object& obj);
670 
671  void run_constructor (cdef_object& obj, const octave_value_list& args);
672 
673  void mark_as_handle_class (void) { handle_class = true; }
674 
675  bool is_handle_class (void) const { return handle_class; }
676 
677  void register_object (void) { object_count++; }
678 
679  void unregister_object (void) { object_count--; }
680 
681  octave_idx_type static_count (void) const { return member_count; }
682 
683  void destroy (void)
684  {
685  if (member_count)
686  {
687  refcount++;
688  cdef_class lock (this);
689 
690  member_count = 0;
691  method_map.clear ();
692  property_map.clear ();
693  }
694  else
695  delete this;
696  }
697 
698  void mark_as_meta_class (void) { meta = true; }
699 
700  bool is_meta_class (void) const { return meta; }
701 
702  private:
703  void load_all_methods (void);
704 
705  void find_names (std::set<std::string>& names, bool all);
706 
707  void find_properties (std::map<std::string,cdef_property>& props,
708  int mode = 0);
709 
710  void find_methods (std::map<std::string, cdef_method>& meths,
711  bool only_inherited);
712 
714  {
715  refcount++;
716  return cdef_class (this);
717  }
718 
719  private:
720  // The @-directory were this class is loaded from.
721  // (not used yet)
723 
724  // The methods defined by this class.
725  std::map<std::string,cdef_method> method_map;
726 
727  // The properties defined by this class.
728  std::map<std::string,cdef_property> property_map;
729 
730  // The number of members in this class (methods, properties...)
732 
733  // TRUE if this class is a handle class. A class is a handle
734  // class when the abstract "handle" class is one of its superclasses.
736 
737  // The list of super-class constructors that are called implicitly by the
738  // the classdef engine when creating an object. These constructors are not
739  // called explicitly by the class constructor.
740  std::list<cdef_class> implicit_ctor_list;
741 
742  // The number of objects of this class.
744 
745  // TRUE if this class is a built-in meta class.
746  bool meta;
747 
748  // Utility iterator typedef's.
749  typedef std::map<std::string,cdef_method>::iterator method_iterator;
750  typedef std::map<std::string,cdef_method>::const_iterator method_const_iterator;
751  typedef std::map<std::string,cdef_property>::iterator property_iterator;
752  typedef std::map<std::string,cdef_property>::const_iterator property_const_iterator;
753 
754  private:
756  : cdef_meta_object_rep (c), directory (c.directory),
757  method_map (c.method_map), property_map (c.property_map),
758  member_count (c.member_count), handle_class (c.handle_class),
759  implicit_ctor_list (c.implicit_ctor_list),
760  object_count (c.object_count), meta (c.meta) { }
761  };
762 
763 public:
764  // Create and invalid class object
765  cdef_class (void)
766  : cdef_meta_object () { }
767 
769  const std::list<cdef_class>& superclasses)
770  : cdef_meta_object (new cdef_class_rep (superclasses))
771  { get_rep ()->set_name (nm); }
772 
773  cdef_class (const cdef_class& cls)
774  : cdef_meta_object (cls) { }
775 
776  cdef_class (const cdef_object& obj)
777  : cdef_meta_object (obj)
778  {
779  // This should never happen...
780  if (! is_class ())
781  error ("internal error: invalid assignment from %s to meta.class object",
782  class_name ().c_str ());
783  }
784 
786  {
788 
789  return *this;
790  }
791 
792  cdef_method find_method (const std::string& nm, bool local = false);
793 
794  void install_method (const cdef_method& meth)
795  { get_rep ()->install_method (meth); }
796 
797  Cell get_methods (void) { return get_rep ()->get_methods (); }
798 
799  cdef_property find_property (const std::string& nm);
800 
801  void install_property (const cdef_property& prop)
802  { get_rep ()->install_property (prop); }
803 
804  Cell get_properties (int mode = property_normal)
805  { return get_rep ()->get_properties (mode); }
806 
807  std::map<std::string, cdef_property>
808  get_property_map (int mode = property_normal)
809  { return get_rep ()->get_property_map (mode); }
810 
811  string_vector get_names (void) { return get_rep ()->get_names (); }
812 
813  bool is_abstract (void) const { return get_rep ()->is_abstract (); }
814 
815  bool is_sealed (void) const { return get_rep ()->is_sealed (); }
816 
817  void set_directory (const std::string& dir)
818  { get_rep ()->set_directory (dir); }
819 
821  { return get_rep ()->get_directory (); }
822 
823  std::string get_name (void) const
824  { return get_rep ()->get_name (); }
825 
826  bool is_builtin (void) const
827  { return get_directory ().empty (); }
828 
830  { get_rep ()->delete_object (obj); }
831 
833  bool is_at_folder = false);
834 
835  octave_function* get_method_function (const std::string& nm);
836 
838  { return get_method_function (get_name ()); }
839 
841  { return get_rep ()->construct (args); }
842 
844  { return get_rep ()->construct_object (args); }
845 
847  { get_rep ()->initialize_object (obj); }
848 
850  { get_rep ()->run_constructor (obj, args); }
851 
853  { get_rep ()->mark_as_handle_class (); }
854 
855  bool is_handle_class (void) const
856  { return get_rep ()->is_handle_class (); }
857 
858  void mark_as_meta_class (void) { get_rep ()->mark_as_meta_class (); }
859 
860  bool is_meta_class (void) const { return get_rep ()->is_meta_class (); }
861 
862  static const cdef_class& meta_class (void) { return _meta_class; }
863  static const cdef_class& meta_property (void) { return _meta_property; }
864  static const cdef_class& meta_method (void) { return _meta_method; }
865  static const cdef_class& meta_package (void) { return _meta_package; }
866 
867  void register_object (void) { get_rep ()->register_object (); }
868 
869  void unregister_object (void) { get_rep ()->unregister_object (); }
870 
871 public:
872  enum
873  {
876  property_all
877  };
878 
879 private:
881  { return dynamic_cast<cdef_class_rep *> (cdef_object::get_rep ()); }
882 
883  const cdef_class_rep* get_rep (void) const
884  { return dynamic_cast<const cdef_class_rep *> (cdef_object::get_rep ()); }
885 
886  friend bool operator == (const cdef_class&, const cdef_class&);
887  friend bool operator != (const cdef_class&, const cdef_class&);
888  friend bool operator < (const cdef_class&, const cdef_class&);
889 
890 private:
895 
896  friend void install_classdef (void);
897 };
898 
899 inline bool
900 operator == (const cdef_class& clsa, const cdef_class& clsb)
901 // FIXME: is this really the right way to check class equality?
902 { return (clsa.get_rep () == clsb.get_rep ()); }
903 
904 inline bool
905 operator != (const cdef_class& clsa, const cdef_class& clsb)
906 { return ! (clsa == clsb); }
907 
908 // This is only to be able to use cdef_class as map keys.
909 inline bool
910 operator < (const cdef_class& clsa, const cdef_class& clsb)
911 { return clsa.get_rep () < clsb.get_rep (); }
912 
913 class
915 {
916  friend class cdef_class;
917 
918 private:
919 
920  class
922  {
923  public:
925  : cdef_meta_object_rep () { }
926 
927  cdef_object_rep* copy (void) const { return new cdef_property_rep (*this); }
928 
929  bool is_property (void) const { return true; }
930 
931  std::string get_name (void) const { return get("Name").string_value (); }
932 
933  void set_name (const std::string& nm) { put ("Name", nm); }
934 
935  bool is_constant (void) const { return get("Constant").bool_value (); }
936 
937  octave_value get_value (bool do_check_access = true,
938  const std::string& who = "");
939 
940  octave_value get_value (const cdef_object& obj,
941  bool do_check_access = true,
942  const std::string& who = "");
943 
944  void set_value (cdef_object& obj, const octave_value& val,
945  bool do_check_access = true,
946  const std::string& who = "");
947 
948  bool check_get_access (void) const;
949 
950  bool check_set_access (void) const;
951 
952  private:
954  : cdef_meta_object_rep (p) { }
955 
956  bool is_recursive_set (const cdef_object& obj) const;
957 
959  {
960  refcount++;
961  return cdef_property (this);
962  }
963  };
964 
965 public:
967 
970  { get_rep ()->set_name (nm); }
971 
973  : cdef_meta_object (prop) { }
974 
976  : cdef_meta_object (obj)
977  {
978  // This should never happen...
979  if (! is_property ())
980  error ("internal error: invalid assignment from %s to meta.property object",
981  class_name ().c_str ());
982  }
983 
985  {
987 
988  return *this;
989  }
990 
991  octave_value get_value (const cdef_object& obj, bool do_check_access = true,
992  const std::string& who = "")
993  { return get_rep ()->get_value (obj, do_check_access, who); }
994 
995  octave_value get_value (bool do_check_access = true,
996  const std::string& who = "")
997  { return get_rep ()->get_value (do_check_access, who); }
998 
999  void set_value (cdef_object& obj, const octave_value& val,
1000  bool do_check_access = true,
1001  const std::string& who = "")
1002  { get_rep ()->set_value (obj, val, do_check_access, who); }
1003 
1004  bool check_get_access (void) const
1005  { return get_rep ()->check_get_access (); }
1006 
1007  bool check_set_access (void) const
1008  { return get_rep ()->check_set_access (); }
1009 
1010  std::string get_name (void) const { return get_rep ()->get_name (); }
1011 
1012  bool is_constant (void) const { return get_rep ()->is_constant (); }
1013 
1014 private:
1016  { return dynamic_cast<cdef_property_rep *> (cdef_object::get_rep ()); }
1017 
1018  const cdef_property_rep* get_rep (void) const
1019  { return dynamic_cast<const cdef_property_rep *> (cdef_object::get_rep ()); }
1020 };
1021 
1022 class
1024 {
1025  friend class cdef_class;
1026 
1027 private:
1028 
1029  class
1031  {
1032  public:
1034  : cdef_meta_object_rep (), function (), dispatch_type ()
1035  { }
1036 
1037  cdef_object_rep* copy (void) const { return new cdef_method_rep(*this); }
1038 
1039  bool is_method (void) const { return true; }
1040 
1041  std::string get_name (void) const { return get("Name").string_value (); }
1042 
1043  void set_name (const std::string& nm) { put ("Name", nm); }
1044 
1045  bool is_static (void) const { return get("Static").bool_value (); }
1046 
1047  octave_value get_function (void) const { return function; }
1048 
1049  void set_function (const octave_value& fcn) { function = fcn; }
1050 
1051  bool check_access (void) const;
1052 
1053  bool is_external (void) const { return ! dispatch_type.empty (); }
1054 
1055  void mark_as_external (const std::string& dtype)
1056  { dispatch_type = dtype; }
1057 
1058  octave_value_list execute (const octave_value_list& args, int nargout,
1059  bool do_check_access = true,
1060  const std::string& who = "");
1061 
1062  octave_value_list execute (const cdef_object& obj,
1063  const octave_value_list& args, int nargout,
1064  bool do_check_access = true,
1065  const std::string& who = "");
1066 
1067  bool is_constructor (void) const;
1068 
1070  meta_subsref (const std::string& type,
1071  const std::list<octave_value_list>& idx, int nargout);
1072 
1074  { return (type == '(' || type == '.'); }
1075 
1076  private:
1079  dispatch_type (m.dispatch_type)
1080  { }
1081 
1082  void check_method (void);
1083 
1085  {
1086  refcount++;
1087  return cdef_method (this);
1088  }
1089 
1090  private:
1091  octave_value function;
1092 
1093  // When non-empty, the method is externally defined and this member
1094  // is used to cache the dispatch type to look for the method.
1096  };
1097 
1098 public:
1100 
1103  { get_rep ()->set_name (nm); }
1104 
1105  cdef_method (const cdef_method& meth)
1106  : cdef_meta_object (meth) { }
1107 
1109  : cdef_meta_object (obj)
1110  {
1111  // This should never happen...
1112  if (! is_method ())
1113  error ("internal error: invalid assignment from %s to meta.method object",
1114  class_name ().c_str ());
1115  }
1116 
1118  {
1120 
1121  return *this;
1122  }
1123 
1124  // normal invocation
1126  bool do_check_access = true,
1127  const std::string& who = "")
1128  { return get_rep ()->execute (args, nargout, do_check_access, who); }
1129 
1130  // dot-invocation: object is pushed as 1st argument
1132  const octave_value_list& args, int nargout,
1133  bool do_check_access = true,
1134  const std::string& who = "")
1135  { return get_rep ()->execute (obj, args, nargout, do_check_access, who); }
1136 
1137  bool check_access (void) const { return get_rep ()->check_access (); }
1138 
1139  std::string get_name (void) const { return get_rep ()->get_name (); }
1140 
1141  bool is_static (void) const { return get_rep ()->is_static (); }
1142 
1144  { get_rep ()->set_function (fcn); }
1145 
1147  { return get_rep ()->get_function (); }
1148 
1149  bool is_constructor (void) const
1150  { return get_rep ()->is_constructor (); }
1151 
1152  bool is_external (void) const { return get_rep ()->is_external (); }
1153 
1154  void mark_as_external (const std::string& dtype)
1155  { get_rep ()->mark_as_external (dtype); }
1156 
1157 private:
1159  { return dynamic_cast<cdef_method_rep *> (cdef_object::get_rep ()); }
1160 
1161  const cdef_method_rep* get_rep (void) const
1162  { return dynamic_cast<const cdef_method_rep *> (cdef_object::get_rep ()); }
1163 };
1164 
1165 inline cdef_class
1167 {
1168  err_invalid_object ("get_class");
1169 }
1170 
1171 inline std::string
1173 { return get_class ().get_name (); }
1174 
1175 inline cdef_class
1177 { return rep->get_class (); }
1178 
1179 inline cdef_class
1181 { return cdef_class (klass); }
1182 
1183 inline void
1185 {
1186  if ((klass.ok () && cls.ok () && cls != get_class ())
1187  || (klass.ok () && ! cls.ok ())
1188  || (! klass.ok () && cls.ok ()))
1189  {
1190  unregister_object ();
1191  klass = cls;
1192  register_object ();
1193  }
1194 }
1195 
1196 inline void
1198 {
1199  if (klass.ok ())
1200  {
1201  cdef_class cls (get_class ());
1202 
1203  if (cls.ok ())
1204  cls.register_object ();
1205  }
1206 }
1207 
1208 inline void
1210 {
1211  if (klass.ok ())
1212  {
1213  cdef_class cls (get_class ());
1214 
1215  if (cls.ok ())
1216  cls.unregister_object ();
1217  }
1218 }
1219 
1220 inline cdef_object_rep*
1222 {
1223  cdef_object_rep* r = new cdef_object_array ();
1224 
1225  r->set_class (get_class ());
1226 
1227  return r;
1228 }
1229 
1230 inline cdef_method
1232 { return get_rep ()->find_method (nm, local); }
1233 
1234 inline cdef_property
1236 { return get_rep ()->find_property (nm); }
1237 
1238 class
1240 {
1241  friend class cdef_class;
1242 
1243 private:
1244 
1245  class
1247  {
1248  public:
1250  : cdef_meta_object_rep (), member_count (0) { }
1251 
1253 
1254  cdef_object_rep* copy (void) const { return new cdef_package_rep (*this); }
1255 
1256  bool is_package (void) const { return true; }
1257 
1258  std::string get_name (void) const { return get("Name").string_value (); }
1259 
1260  void set_name (const std::string& nm) { put ("Name", nm); }
1261 
1262  void install_class (const cdef_class& cls, const std::string& nm);
1263 
1264  void install_function (const octave_value& fcn, const std::string& nm);
1265 
1266  void install_package (const cdef_package& pack, const std::string& nm);
1267 
1268  Cell get_classes (void) const;
1269 
1270  Cell get_functions (void) const;
1271 
1272  Cell get_packages (void) const;
1273 
1274  octave_idx_type static_count (void) const { return member_count; }
1275 
1276  void destroy (void)
1277  {
1278  if (member_count)
1279  {
1280  refcount++;
1281  cdef_package lock (this);
1282 
1283  member_count = 0;
1284  class_map.clear ();
1285  package_map.clear ();
1286  }
1287  else
1288  delete this;
1289  }
1290 
1292  meta_subsref (const std::string& type,
1293  const std::list<octave_value_list>& idx, int nargout);
1294 
1295  void meta_release (void);
1296 
1298  { return (type == '.'); }
1299 
1300  octave_value find (const std::string& nm);
1301 
1302  private:
1304  std::map<std::string, cdef_class> class_map;
1305  std::map<std::string, octave_value> function_map;
1306  std::map<std::string, cdef_package> package_map;
1307 
1308  // The number of registered members in this package (classes, packages).
1309  // This only accounts for the members that back-reference to this package.
1311 
1312  typedef std::map<std::string, cdef_class>::iterator class_iterator;
1313  typedef std::map<std::string, cdef_class>::const_iterator class_const_iterator;
1314  typedef std::map<std::string, octave_value>::iterator function_iterator;
1315  typedef std::map<std::string, octave_value>::const_iterator function_const_iterator;
1316  typedef std::map<std::string, cdef_package>::iterator package_iterator;
1317  typedef std::map<std::string, cdef_package>::const_iterator package_const_iterator;
1318 
1319  private:
1321  : cdef_meta_object_rep (p), full_name (p.full_name),
1322  class_map (p.class_map), function_map (p.function_map),
1323  package_map (p.package_map), member_count (p.member_count)
1324  { }
1325 
1327  {
1328  refcount++;
1329  return cdef_package (this);
1330  }
1331  };
1332 
1333 public:
1335 
1338  { get_rep ()->set_name (nm); }
1339 
1341  : cdef_meta_object (pack) { }
1342 
1344  : cdef_meta_object (obj)
1345  {
1346  // This should never happen...
1347  if (! is_package ())
1348  error ("internal error: invalid assignment from %s to meta.package object",
1349  class_name ().c_str ());
1350  }
1351 
1353  {
1355 
1356  return *this;
1357  }
1358 
1359  void install_class (const cdef_class& cls, const std::string& nm)
1360  { get_rep ()->install_class (cls, nm); }
1361 
1363  { get_rep ()->install_function (fcn, nm); }
1364 
1365  void install_package (const cdef_package& pack, const std::string& nm)
1366  { get_rep ()->install_package (pack, nm); }
1367 
1368  Cell get_classes (void) const
1369  { return get_rep ()->get_classes (); }
1370 
1371  Cell get_functions (void) const
1372  { return get_rep ()->get_functions (); }
1373 
1374  Cell get_packages (void) const
1375  { return get_rep ()->get_packages (); }
1376 
1377  std::string get_name (void) const { return get_rep ()->get_name (); }
1378 
1379  octave_value find (const std::string& nm) { return get_rep ()->find (nm); }
1380 
1381  static const cdef_package& meta (void) { return _meta; }
1382 
1383 private:
1385  { return dynamic_cast<cdef_package_rep *> (cdef_object::get_rep ()); }
1386 
1387  const cdef_package_rep* get_rep (void) const
1388  { return dynamic_cast<const cdef_package_rep *> (cdef_object::get_rep ()); }
1389 
1390 private:
1392 
1393  friend void install_classdef (void);
1394 };
1395 
1396 class
1398 {
1399 public:
1401  : octave_base_value (), object () { }
1402 
1404  : octave_base_value (), object (obj) { }
1405 
1407  : octave_base_value (obj), object (obj.object) { }
1408 
1409  octave_base_value* clone (void) const
1410  { return new octave_classdef (object.clone ()); }
1411 
1413  { return new octave_classdef (object.empty_clone ()); }
1414 
1415  cdef_object get_object (void) const { return object; }
1416 
1417  cdef_object& get_object_ref (void) { return object; }
1418 
1419  bool is_defined (void) const { return true; }
1420 
1421  bool is_map (void) const { return false; }
1422 
1423  bool is_object (void) const { return true; }
1424 
1425  bool is_classdef_object (void) const { return true; }
1426 
1427  void print (std::ostream& os, bool pr_as_read_syntax = false);
1428 
1429  void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
1430 
1431  bool print_name_tag (std::ostream& os, const std::string& name) const;
1432 
1433  void print_with_name (std::ostream& os, const std::string& name,
1434  bool print_padding = true);
1435 
1436  bool is_instance_of (const std::string& cls_name) const;
1437 
1439  const std::list<octave_value_list>& idx,
1440  int nargout);
1441 
1443  const std::list<octave_value_list>& idx)
1444  {
1445  octave_value_list retval = subsref (type, idx, 1);
1446  return (retval.length () > 0 ? retval(0) : octave_value ());
1447  }
1448 
1450  const std::list<octave_value_list>& idx,
1451  bool auto_add);
1452 
1454  const std::list<octave_value_list>& idx,
1455  const octave_value& rhs);
1456 
1457  octave_value
1458  undef_subsasgn (const std::string& type,
1459  const std::list<octave_value_list>& idx,
1460  const octave_value& rhs);
1461 
1462  string_vector map_keys (void) const { return object.map_keys (); }
1463 
1464  octave_map map_value (void) const { return object.map_value (); }
1465 
1466  dim_vector dims (void) const { return object.dims (); }
1467 
1468 private:
1470 
1471 private:
1472 
1473 public:
1474  int type_id (void) const { return t_id; }
1475  std::string type_name (void) const { return t_name; }
1476  std::string class_name (void) const { return object.class_name (); }
1477 
1478  static int static_type_id (void) { return t_id; }
1479  static std::string static_type_name (void) { return t_name; }
1480  static std::string static_class_name (void) { return "<unknown>"; }
1481  static void register_type (void);
1482 
1483 private:
1484  static int t_id;
1485 
1486  static const std::string t_name;
1487 };
1488 
1489 inline octave_value
1490 to_ov (const cdef_object& obj)
1491 {
1492  if (obj.ok ())
1493  return octave_value (new octave_classdef (obj));
1494  else
1495  return octave_value (Matrix ());
1496 }
1497 
1498 inline octave_value
1499 to_ov (const octave_value& ov)
1500 { return ov; }
1501 
1502 inline cdef_object
1504 {
1505  if (val.type_name () != "object")
1506  error ("cannot convert `%s' into `object'", val.type_name().c_str ());
1507 
1508  return dynamic_cast<octave_classdef *> (val.internal_rep ())->get_object ();
1509 }
1510 
1511 inline cdef_object&
1513 {
1514  if (val.type_name () != "object")
1515  error ("cannot convert `%s' into `object'", val.type_name().c_str ());
1516 
1517  return dynamic_cast<octave_classdef *> (val.internal_rep ())->get_object_ref ();
1518 }
1519 
1520 inline cdef_object
1521 to_cdef (const cdef_object& obj)
1522 { return obj; }
1523 
1524 OCTINTERP_API void install_classdef (void);
1525 
1526 class
1528 {
1529 public:
1530 
1532  bool error_if_not_found = true,
1533  bool load_if_not_found = true)
1534  {
1535  if (instance_ok ())
1536  return instance->do_find_class (name, error_if_not_found,
1537  load_if_not_found);
1538 
1539  return cdef_class ();
1540  }
1541 
1542  static octave_function* find_method_symbol (const std::string& method_name,
1543  const std::string& class_name)
1544  {
1545  if (instance_ok ())
1546  return instance->do_find_method_symbol (method_name, class_name);
1547 
1548  return 0;
1549  }
1550 
1552  bool error_if_not_found = true,
1553  bool load_if_not_found = true)
1554  {
1555  if (instance_ok ())
1556  return instance->do_find_package (name, error_if_not_found,
1557  load_if_not_found);
1558 
1559  return cdef_package ();
1560  }
1561 
1563  {
1564  if (instance_ok ())
1565  return instance->do_find_package_symbol (pack_name);
1566 
1567  return 0;
1568  }
1569 
1570  static void register_class (const cdef_class& cls)
1571  {
1572  if (instance_ok ())
1573  instance->do_register_class (cls);
1574  }
1575 
1576  static void unregister_class (const cdef_class& cls)
1577  {
1578  if (instance_ok ())
1579  instance->do_unregister_class (cls);
1580  }
1581 
1582  static void register_package (const cdef_package& pkg)
1583  {
1584  if (instance_ok ())
1585  instance->do_register_package (pkg);
1586  }
1587 
1588  static void unregister_package (const cdef_package& pkg)
1589  {
1590  if (instance_ok ())
1591  instance->do_unregister_package (pkg);
1592  }
1593 
1594 private:
1595 
1596  cdef_manager (void) { }
1597 
1598  cdef_manager (const cdef_manager&);
1599 
1601 
1602  ~cdef_manager (void) { }
1603 
1604  static void create_instance (void);
1605 
1606  static bool instance_ok (void)
1607  {
1608  bool retval = true;
1609 
1610  if (! instance)
1611  create_instance ();
1612 
1613  if (! instance)
1614  error ("unable to create cdef_manager!");
1615 
1616  return retval;
1617  }
1618 
1619  static void cleanup_instance (void)
1620  {
1621  delete instance;
1622 
1623  instance = 0;
1624  }
1625 
1626  cdef_class do_find_class (const std::string& name, bool error_if_not_found,
1627  bool load_if_not_found);
1628 
1629  octave_function* do_find_method_symbol (const std::string& method_name,
1630  const std::string& class_name);
1631 
1632  cdef_package do_find_package (const std::string& name,
1633  bool error_if_not_found,
1634  bool load_if_not_found);
1635 
1636  octave_function* do_find_package_symbol (const std::string& pack_name);
1637 
1638  void do_register_class (const cdef_class& cls)
1639  { all_classes[cls.get_name ()] = cls; }
1640 
1642  { all_classes.erase(cls.get_name ()); }
1643 
1645  { all_packages[pkg.get_name ()] = pkg; }
1646 
1648  { all_packages.erase(pkg.get_name ()); }
1649 
1650 private:
1651 
1652  // The single cdef_manager instance
1654 
1655  // All registered/loaded classes
1656  std::map<std::string, cdef_class> all_classes;
1657 
1658  // All registered/loaded packages
1659  std::map<std::string, cdef_package> all_packages;
1660 };
1661 
1662 #endif
1663 
1664 /*
1665 ;;; Local Variables: ***
1666 ;;; mode: C++ ***
1667 ;;; End: ***
1668 */
cdef_object get_object(void) const
Definition: ov-classdef.h:1415
std::map< std::string, cdef_package > package_map
Definition: ov-classdef.h:1306
std::map< std::string, cdef_package > all_packages
Definition: ov-classdef.h:1659
cdef_package(const std::string &nm)
Definition: ov-classdef.h:1336
void unregister_object(void)
Definition: ov-classdef.h:1209
bool is_abstract(void) const
Definition: ov-classdef.h:630
void unregister_object(void)
Definition: ov-classdef.h:869
const Cell & contents(const_iterator p) const
Definition: oct-map.h:313
bool is_value_object(void) const
Definition: ov-classdef.h:240
octave_value find(const std::string &nm)
Definition: ov-classdef.h:1379
bool is_static(void) const
Definition: ov-classdef.h:1141
Definition: Cell.h:37
cdef_class(void)
Definition: ov-classdef.h:765
Cell get_properties(int mode=property_normal)
Definition: ov-classdef.h:804
cdef_meta_object(const cdef_meta_object &obj)
Definition: ov-classdef.h:568
std::string get_name(void) const
Definition: ov-classdef.h:1139
static bool check_access(const cdef_class &cls, const octave_value &acc, const std::string &meth_name="", const std::string &prop_name="", bool is_prop_set=false)
Definition: ov-classdef.cc:306
octave_value_list execute(const cdef_object &obj, const octave_value_list &args, int nargout, bool do_check_access=true, const std::string &who="")
Definition: ov-classdef.h:1131
octave_value get_function(void) const
Definition: ov-classdef.h:1146
bool is_method(void) const
Definition: ov-classdef.h:584
void install_method(const cdef_method &meth)
Definition: ov-classdef.h:794
dim_vector dims(void) const
Definition: ov-classdef.h:362
bool is_constructed_for(const cdef_class &cls) const
Definition: ov-classdef.h:281
bool is_valid(void) const
Definition: ov-classdef.h:503
void assign(const std::string &k, const Cell &val)
Definition: oct-map.h:347
cdef_object empty_clone(void) const
Definition: ov-classdef.h:227
std::map< std::string, cdef_class > all_classes
Definition: ov-classdef.h:1656
void do_unregister_package(const cdef_package &pkg)
Definition: ov-classdef.h:1647
cdef_object_rep * clone(void) const
Definition: ov-classdef.h:359
cdef_method_rep(const cdef_method_rep &m)
Definition: ov-classdef.h:1077
virtual cdef_object_rep * make_array(void) const
Definition: ov-classdef.h:79
std::string get_directory(void) const
Definition: ov-classdef.h:820
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout, size_t &skip, const cdef_class &context, bool auto_add=false)
Definition: ov-classdef.h:255
virtual bool is_method(void) const
Definition: ov-classdef.h:534
octave_idx_type member_count
Definition: ov-classdef.h:731
virtual bool is_handle_object(void) const
Definition: ov-classdef.h:88
std::map< std::string, octave_value >::const_iterator function_const_iterator
Definition: ov-classdef.h:1315
cdef_object_base(void)
Definition: ov-classdef.h:311
bool is_handle_class(void) const
Definition: ov-classdef.h:675
octave_map map_value(void) const
cdef_meta_object(cdef_meta_object_rep *r)
Definition: ov-classdef.h:571
void set_value(cdef_object &obj, const octave_value &val, bool do_check_access=true, const std::string &who="")
Definition: ov-classdef.h:999
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
cdef_object & operator=(const cdef_object &obj)
Definition: ov-classdef.h:204
cdef_object make_array(void) const
Definition: ov-classdef.h:232
bool check_set_access(void) const
Definition: ov-classdef.h:1007
octave_idx_type length(void) const
Definition: ovl.h:96
void release(void)
Definition: ov-classdef.h:159
void set_name(const std::string &nm)
Definition: ov-classdef.h:1260
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6386
cdef_method(const cdef_method &meth)
Definition: ov-classdef.h:1105
idx subsref(val, idx) esult
Definition: ov.cc:3080
cdef_object_rep * make_array(void) const
Definition: ov-classdef.h:1221
dim_vector dims(void) const
Definition: ov-classdef.h:403
octave_base_value * empty_clone(void) const
Definition: ov-classdef.h:1412
void register_object(void)
Definition: ov-classdef.h:1197
bool is_meta_object(void) const
Definition: ov-classdef.h:528
void mark_for_construction(const cdef_class &cls)
Definition: ov-classdef.h:276
cdef_property(const std::string &nm)
Definition: ov-classdef.h:968
cdef_manager(void)
Definition: ov-classdef.h:1596
void put(const std::string &pname, const octave_value &val)
Definition: ov-classdef.h:405
static const cdef_class & meta_package(void)
Definition: ov-classdef.h:865
virtual Array< cdef_object > array_value(void) const
Definition: ov-classdef.h:92
virtual bool is_constructed_for(const cdef_class &) const
Definition: ov-classdef.h:130
Array< cdef_object > array
Definition: ov-classdef.h:380
void install_package(const cdef_package &pack, const std::string &nm)
Definition: ov-classdef.h:1365
static const cdef_class & meta_property(void)
Definition: ov-classdef.h:863
std::string get_name(void) const
Definition: ov-classdef.h:625
cdef_meta_object_rep(const cdef_meta_object_rep &obj)
Definition: ov-classdef.h:553
void mark_as_constructed(const cdef_class &cls)
Definition: ov-classdef.h:289
void error(const char *fmt,...)
Definition: error.cc:570
bool is_array(void) const
Definition: ov-classdef.h:366
octave_base_value * clone(void) const
Definition: ov-classdef.h:1409
virtual octave_value_list meta_subsref(const std::string &, const std::list< octave_value_list > &, int)
Definition: ov-classdef.h:539
cdef_object_array(const Array< cdef_object > &a)
Definition: ov-classdef.h:356
virtual bool is_value_object(void) const
Definition: ov-classdef.h:86
cdef_object & to_cdef_ref(const octave_value &val)
Definition: ov-classdef.h:1512
void register_object(void)
Definition: ov-classdef.h:867
std::map< cdef_class, std::list< cdef_class > > ctor_list
Definition: ov-classdef.h:444
bool meta_is_postfix_index_handled(char type) const
Definition: ov-classdef.h:1073
cdef_meta_object(const cdef_object &obj)
Definition: ov-classdef.h:575
bool is_external(void) const
Definition: ov-classdef.h:1152
static void register_class(const cdef_class &cls)
Definition: ov-classdef.h:1570
static cdef_package find_package(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
Definition: ov-classdef.h:1551
bool is_sealed(void) const
Definition: ov-classdef.h:815
~cdef_meta_object(void)
Definition: ov-classdef.h:578
bool is_constructed(void) const
Definition: ov-classdef.h:437
bool is_method(void) const
Definition: ov-classdef.h:1039
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:935
cdef_object_rep * copy(void) const
Definition: ov-classdef.h:472
bool is_constructor(void) const
Definition: ov-classdef.h:1149
cdef_object_rep * copy(void) const
Definition: ov-classdef.h:1037
virtual void meta_release(void)
Definition: ov-classdef.h:546
virtual string_vector map_keys(void) const
void set_name(const std::string &nm)
Definition: ov-classdef.h:628
std::map< std::string, cdef_class >::iterator class_iterator
Definition: ov-classdef.h:1312
void fill_empty_values(void)
Definition: ov-classdef.h:383
handle_cdef_object(const handle_cdef_object &obj)
Definition: ov-classdef.h:481
static octave_function * find_method_symbol(const std::string &method_name, const std::string &class_name)
Definition: ov-classdef.h:1542
bool is_handle_object(void) const
Definition: ov-classdef.h:477
virtual bool is_property(void) const
Definition: ov-classdef.h:532
std::string class_name(void) const
Definition: ov-classdef.h:1476
virtual octave_value get(const std::string &) const
Definition: ov-classdef.h:100
Array< cdef_object > array_value(void) const
Definition: ov-classdef.h:246
octave_function * fcn
Definition: ov-class.cc:1743
std::map< std::string, cdef_property >::iterator property_iterator
Definition: ov-classdef.h:751
octave_idx_type static_count(void) const
Definition: ov-classdef.h:1274
bool check_get_access(void) const
Definition: ov-classdef.h:1004
cdef_class wrap(void)
Definition: ov-classdef.h:713
cdef_property_rep(const cdef_property_rep &p)
Definition: ov-classdef.h:953
void set_name(const std::string &nm)
Definition: ov-classdef.h:1043
virtual void mark_as_constructed(void)
Definition: ov-classdef.h:140
void initialize_object(cdef_object &obj)
Definition: ov-classdef.h:846
std::map< std::string, cdef_property >::const_iterator property_const_iterator
Definition: ov-classdef.h:752
bool is_handle_object(void) const
Definition: ov-classdef.h:242
bool is_array(void) const
Definition: ov-classdef.h:238
cdef_object_rep * copy(void) const
Definition: ov-classdef.h:525
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
cdef_class & operator=(const cdef_class &cls)
Definition: ov-classdef.h:785
octave_idx_type static_count(void) const
Definition: ov-classdef.h:681
dim_vector dims(void) const
Definition: ov-classdef.h:1466
JNIEnv void * args
Definition: ov-java.cc:67
virtual cdef_class get_class(void) const
Definition: ov-classdef.h:1166
const cdef_class_rep * get_rep(void) const
Definition: ov-classdef.h:883
static bool instance_ok(void)
Definition: ov-classdef.h:1606
cdef_class get_class(void) const
Definition: ov-classdef.h:1180
std::string get_name(void) const
Definition: ov-classdef.h:1010
cdef_object_rep * copy(void) const
Definition: ov-classdef.h:621
void do_register_class(const cdef_class &cls)
Definition: ov-classdef.h:1638
bool meta_is_postfix_index_handled(char type) const
Definition: ov-classdef.h:1297
Cell get_functions(void) const
Definition: ov-classdef.h:1371
bool check_access(void) const
Definition: ov-classdef.h:1137
cdef_method(void)
Definition: ov-classdef.h:1099
void install_class(const cdef_class &cls, const std::string &nm)
Definition: ov-classdef.h:1359
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
cdef_package_rep * get_rep(void)
Definition: ov-classdef.h:1384
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
cdef_object_rep * copy(void) const
Definition: ov-classdef.h:1254
std::map< std::string, cdef_package >::const_iterator package_const_iterator
Definition: ov-classdef.h:1317
octave_refcount< octave_idx_type > refcount
Definition: ov-classdef.h:169
void set_directory(const std::string &dir)
Definition: ov-classdef.h:817
cdef_object_rep * rep
Definition: ov-classdef.h:304
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:935
#define OCTINTERP_API
Definition: mexproto.h:69
cdef_method find_method(const std::string &nm, bool local=false)
Definition: ov-classdef.h:1231
octave_function * get_constructor_function(void)
Definition: ov-classdef.h:837
bool is_object(void) const
Definition: ov-classdef.h:1423
~cdef_manager(void)
Definition: ov-classdef.h:1602
OCTINTERP_API void install_classdef(void)
virtual octave_idx_type static_count(void) const
Definition: ov-classdef.h:155
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
cdef_object_base(const cdef_object_base &obj)
Definition: ov-classdef.h:330
octave_value get_value(bool do_check_access=true, const std::string &who="")
Definition: ov-classdef.h:995
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
cdef_object_rep * get_rep(void)
Definition: ov-classdef.h:295
virtual bool is_class(void) const
Definition: ov-classdef.h:530
then the function must return scalars which will be concatenated into the return array(s).If code
Definition: cellfun.cc:398
virtual octave_value subsasgn(const std::string &, const std::list< octave_value_list > &, const octave_value &)
Definition: ov-classdef.h:113
virtual void put(const std::string &, const octave_value &)
Definition: ov-classdef.h:97
void mark_as_external(const std::string &dtype)
Definition: ov-classdef.h:1154
virtual bool is_package(void) const
Definition: ov-classdef.h:536
void put(const std::string &pname, const octave_value &val)
Definition: ov-classdef.h:248
static const cdef_class & meta_method(void)
Definition: ov-classdef.h:864
~cdef_object_base(void)
Definition: ov-classdef.h:317
bool operator<(const cdef_class &clsa, const cdef_class &clsb)
Definition: ov-classdef.h:910
virtual void mark_for_construction(const cdef_class &)
Definition: ov-classdef.h:125
cdef_object_rep * clone(void) const
Definition: ov-classdef.h:498
static cdef_class _meta_method
Definition: ov-classdef.h:893
static cdef_manager * instance
Definition: ov-classdef.h:1653
octave_value_list execute(const octave_value_list &args, int nargout, bool do_check_access=true, const std::string &who="")
Definition: ov-classdef.h:1125
std::list< cdef_class > implicit_ctor_list
Definition: ov-classdef.h:740
octave_value to_ov(const cdef_object &obj)
Definition: ov-classdef.h:1490
void set_name(const std::string &nm)
Definition: ov-classdef.h:933
cdef_property(const cdef_property &prop)
Definition: ov-classdef.h:972
cdef_method(const std::string &nm)
Definition: ov-classdef.h:1101
const cdef_method_rep * get_rep(void) const
Definition: ov-classdef.h:1161
cdef_package(void)
Definition: ov-classdef.h:1334
virtual void mark_as_constructed(const cdef_class &)
Definition: ov-classdef.h:145
virtual cdef_object_rep * clone(void) const
Definition: ov-classdef.h:64
is false
Definition: cellfun.cc:398
octave_value retval
Definition: data.cc:6294
bool is_constant(void) const
Definition: ov-classdef.h:1012
static cdef_package _meta
Definition: ov-classdef.h:1391
static cdef_class _meta_class
Definition: ov-classdef.h:891
cdef_object object
Definition: ov-classdef.h:1469
bool is_map(void) const
Definition: ov-classdef.h:1421
bool is_meta_object(void) const
Definition: ov-classdef.h:244
std::string get_name(void) const
Definition: ov-classdef.h:1258
static int static_type_id(void)
Definition: ov-classdef.h:1478
virtual ~cdef_object(void)
Definition: ov-classdef.h:201
virtual dim_vector dims(void) const
Definition: ov-classdef.h:165
Array< cdef_object > array_value(void) const
Definition: ov-classdef.h:368
static octave_function * find_package_symbol(const std::string &pack_name)
Definition: ov-classdef.h:1562
bool is_class(void) const
Definition: ov-classdef.h:623
virtual bool is_valid(void) const
Definition: ov-classdef.h:121
octave_value get_function(void) const
Definition: ov-classdef.h:1047
bool meta_is_postfix_index_handled(char type) const
Definition: ov-classdef.h:595
static cdef_class _meta_package
Definition: ov-classdef.h:894
cdef_object klass
Definition: ov-classdef.h:343
cdef_package(const cdef_package &pack)
Definition: ov-classdef.h:1340
cdef_object_rep(const cdef_object_rep &)
Definition: ov-classdef.h:173
octave_classdef(const cdef_object &obj)
Definition: ov-classdef.h:1403
cdef_meta_object(void)
Definition: ov-classdef.h:565
idx type
Definition: ov.cc:3129
cdef_object_rep * copy(void) const
Definition: ov-classdef.h:501
cdef_method_rep * get_rep(void)
Definition: ov-classdef.h:1158
virtual cdef_object_rep * empty_clone(void) const
Definition: ov-classdef.h:69
Definition: dMatrix.h:37
static cdef_class _meta_property
Definition: ov-classdef.h:892
cdef_class get_class(void) const
Definition: ov-classdef.h:1176
void mark_as_meta_class(void)
Definition: ov-classdef.h:858
octave_refcount< octave_idx_type > object_count
Definition: ov-classdef.h:743
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
std::map< std::string, cdef_package >::iterator package_iterator
Definition: ov-classdef.h:1316
virtual void destroy(void)
Definition: ov-classdef.h:157
virtual ~cdef_object_rep(void)
Definition: ov-classdef.h:57
octave_value construct(const octave_value_list &args)
Definition: ov-classdef.h:840
bool is_classdef_object(void) const
Definition: ov-classdef.h:1425
void install_function(const octave_value &fcn, const std::string &nm)
Definition: ov-classdef.h:1362
std::string pname
Definition: graphics.cc:11207
cdef_object_scalar(const cdef_object_scalar &obj)
Definition: ov-classdef.h:448
bool is_value_object(void) const
Definition: ov-classdef.h:505
cdef_property find_property(const std::string &nm)
Definition: ov-classdef.h:1235
cdef_object(const cdef_object &obj)
Definition: ov-classdef.h:192
cdef_object(void)
Definition: ov-classdef.h:189
cdef_object & get_object_ref(void)
Definition: ov-classdef.h:1417
bool meta_is_postfix_index_handled(char type) const
Definition: ov-classdef.h:662
const cdef_property_rep * get_rep(void) const
Definition: ov-classdef.h:1018
cdef_class(const cdef_class &cls)
Definition: ov-classdef.h:773
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
Definition: colamd.cc:112
cdef_object_rep * copy(void) const
Definition: ov-classdef.h:927
std::string class_name(void) const
Definition: ov-classdef.h:221
cdef_property find_property(const std::string &nm)
virtual void set_class(const cdef_class &)
Definition: ov-classdef.h:61
cdef_object_rep * empty_clone(void) const
Definition: ov-classdef.h:323
virtual octave_value_list subsref(const std::string &, const std::list< octave_value_list > &, int, size_t &, const cdef_class &, bool)
Definition: ov-classdef.h:106
bool operator!=(const cdef_class &clsa, const cdef_class &clsb)
Definition: ov-classdef.h:905
static int t_id
Definition: ov-classdef.h:1484
std::string type_name(void) const
Definition: ov.h:1232
string_vector map_keys(void) const
Definition: ov-classdef.h:268
void make_unique(int ignore_copies)
Definition: ov-classdef.h:297
bool ok(void) const
Definition: ov-classdef.h:274
std::map< std::string, octave_value > function_map
Definition: ov-classdef.h:1305
static cdef_class make_meta_class(const std::string &name, const cdef_class &super)
Definition: ov-classdef.cc:705
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-classdef.h:1442
std::string get_directory(void) const
Definition: ov-classdef.h:652
Cell get_classes(void) const
Definition: ov-classdef.h:1368
bool is_external(void) const
Definition: ov-classdef.h:1053
cdef_object to_cdef(const octave_value &val)
Definition: ov-classdef.h:1503
bool is_class(void) const
Definition: ov-classdef.h:580
const cdef_package_rep * get_rep(void) const
Definition: ov-classdef.h:1387
void mark_as_handle_class(void)
Definition: ov-classdef.h:852
static const std::string t_name
Definition: ov-classdef.h:1486
std::string get_name(void) const
Definition: ov-classdef.h:1377
virtual bool is_array(void) const
Definition: ov-classdef.h:84
virtual cdef_object_rep * copy(void) const
Definition: ov-classdef.h:74
std::map< std::string, cdef_class >::const_iterator class_const_iterator
Definition: ov-classdef.h:1313
std::map< std::string, cdef_property > property_map
Definition: ov-classdef.h:728
void set_class(const cdef_class &cls)
Definition: ov-classdef.h:219
void run_constructor(cdef_object &obj, const octave_value_list &args)
Definition: ov-classdef.h:849
std::string get_name(void) const
Definition: ov-classdef.h:931
string_vector map_keys(void) const
Definition: ov-classdef.h:1462
static std::string static_class_name(void)
Definition: ov-classdef.h:1480
std::string get_name(void) const
Definition: ov-classdef.h:1041
cdef_object construct_object(const octave_value_list &args)
Definition: ov-classdef.h:843
std::map< std::string, cdef_method > method_map
Definition: ov-classdef.h:725
p
Definition: lu.cc:138
std::map< std::string, cdef_property > get_property_map(int mode=property_normal)
Definition: ov-classdef.h:808
octave_classdef(const octave_classdef &obj)
Definition: ov-classdef.h:1406
bool is_meta_class(void) const
Definition: ov-classdef.h:860
void mark_as_external(const std::string &dtype)
Definition: ov-classdef.h:1055
cdef_class_rep(const cdef_class_rep &c)
Definition: ov-classdef.h:755
octave_map map(dims)
static void register_package(const cdef_package &pkg)
Definition: ov-classdef.h:1582
cdef_object(cdef_object_rep *r)
Definition: ov-classdef.h:198
const cdef_meta_object_rep * get_rep(void) const
Definition: ov-classdef.h:602
void mark_as_constructed(void)
Definition: ov-classdef.h:433
static void unregister_package(const cdef_package &pkg)
Definition: ov-classdef.h:1588
virtual bool meta_is_postfix_index_handled(char) const
Definition: ov-classdef.h:548
octave_map map_value(void) const
Definition: ov-classdef.h:1464
idx subsasgn(val, idx, 0) esult
Definition: ov.cc:3129
cdef_class_rep * get_rep(void)
Definition: ov-classdef.h:880
void meta_release(void)
Definition: ov-classdef.h:593
bool is_partially_constructed_for(const cdef_class &cls) const
Definition: ov-classdef.h:284
ots The first example below creates an uninitialized object
Definition: ov-java.cc:2837
cdef_object clone(void) const
Definition: ov-classdef.h:224
bool is_valid(void) const
Definition: ov-classdef.h:364
bool is_defined(void) const
Definition: ov-classdef.h:1419
std::string get_name(void) const
Definition: ov-classdef.h:823
OCTAVE_NORETURN void err_invalid_object(const char *who) const
Definition: ov-classdef.h:180
void do_register_package(const cdef_package &pkg)
Definition: ov-classdef.h:1644
bool is_package(void) const
Definition: ov-classdef.h:586
std::map< std::string, octave_value >::iterator function_iterator
Definition: ov-classdef.h:1314
cdef_class(const cdef_object &obj)
Definition: ov-classdef.h:776
std::map< std::string, cdef_method >::const_iterator method_const_iterator
Definition: ov-classdef.h:750
bool is_static(void) const
Definition: ov-classdef.h:1045
void delete_object(cdef_object obj)
Definition: ov-classdef.h:829
const cdef_object_rep * get_rep(void) const
Definition: ov-classdef.h:272
static const cdef_class & meta_class(void)
Definition: ov-classdef.h:862
dim_vector dims(void) const
Definition: ov-classdef.h:230
cdef_property(void)
Definition: ov-classdef.h:966
std::map< std::string, cdef_method >::iterator method_iterator
Definition: ov-classdef.h:749
cdef_property_rep * get_rep(void)
Definition: ov-classdef.h:1015
OCTAVE_EXPORT octave_value_list it applies a binary function and expands as necessary singleton dimensions in either input argument function
Definition: bsxfun.cc:336
void mark_as_constructed(void)
Definition: ov-classdef.h:287
cdef_class(const std::string &nm, const std::list< cdef_class > &superclasses)
Definition: ov-classdef.h:768
cdef_object_rep * clone(void) const
Definition: ov-classdef.h:465
value_cdef_object(const value_cdef_object &obj)
Definition: ov-classdef.h:509
static void unregister_class(const cdef_class &cls)
Definition: ov-classdef.h:1576
cdef_object_array(const cdef_object_array &obj)
Definition: ov-classdef.h:388
std::string class_name(void) const
Definition: ov-classdef.h:1172
cdef_method find_method(const std::string &nm, bool local=false)
bool is_meta_class(void) const
Definition: ov-classdef.h:700
bool is_property(void) const
Definition: ov-classdef.h:582
octave_value get_value(const cdef_object &obj, bool do_check_access=true, const std::string &who="")
Definition: ov-classdef.h:991
Cell get_methods(void)
Definition: ov-classdef.h:797
static void cleanup_instance(void)
Definition: ov-classdef.h:1619
bool operator==(const cdef_class &clsa, const cdef_class &clsb)
Definition: ov-classdef.h:900
bool is_builtin(void) const
Definition: ov-classdef.h:826
cdef_property(const cdef_object &obj)
Definition: ov-classdef.h:975
static std::string static_type_name(void)
Definition: ov-classdef.h:1479
void set_function(const octave_value &fcn)
Definition: ov-classdef.h:1049
std::string type_name(void) const
Definition: ov-classdef.h:1475
static const cdef_package & meta(void)
Definition: ov-classdef.h:1381
octave_base_value * internal_rep(void) const
Definition: ov.h:1299
void set_directory(const std::string &dir)
Definition: ov-classdef.h:650
cdef_method(const cdef_object &obj)
Definition: ov-classdef.h:1108
bool is_handle_class(void) const
Definition: ov-classdef.h:855
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
void set_class(const cdef_class &cls)
Definition: ov-classdef.h:1184
void install_property(const cdef_property &prop)
Definition: ov-classdef.h:801
cdef_object_rep(void)
Definition: ov-classdef.h:55
string_vector get_names(void)
Definition: ov-classdef.h:811
cdef_object copy(void) const
Definition: ov-classdef.h:235
cdef_package(const cdef_object &obj)
Definition: ov-classdef.h:1343
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
cdef_meta_object_rep * get_rep(void)
Definition: ov-classdef.h:599
bool is_valid(void) const
Definition: ov-classdef.h:475
octave_scalar_map map
Definition: ov-classdef.h:441
octave_value_list meta_subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout)
Definition: ov-classdef.h:589
cdef_package_rep(const cdef_package_rep &p)
Definition: ov-classdef.h:1320
virtual bool is_constructed(void) const
Definition: ov-classdef.h:150
bool is_package(void) const
Definition: ov-classdef.h:1256
Cell get_packages(void) const
Definition: ov-classdef.h:1374
bool is_constructed(void) const
Definition: ov-classdef.h:279
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs, int ignore_copies=0)
Definition: ov-classdef.h:261
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
void set_function(const octave_value &fcn)
Definition: ov-classdef.h:1143
static cdef_class find_class(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
Definition: ov-classdef.h:1531
virtual bool is_partially_constructed_for(const cdef_class &) const
Definition: ov-classdef.h:135
int type_id(void) const
Definition: ov-classdef.h:1474
bool is_abstract(void) const
Definition: ov-classdef.h:813
virtual bool is_meta_object(void) const
Definition: ov-classdef.h:90
bool is_sealed(void) const
Definition: ov-classdef.h:632
std::map< std::string, cdef_class > class_map
Definition: ov-classdef.h:1304
bool is(const cdef_object &obj) const
Definition: ov-classdef.h:292
OCTAVE_EXPORT octave_value_list directory
Definition: variables.cc:582
void do_unregister_class(const cdef_class &cls)
Definition: ov-classdef.h:1641