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