Mercurial > octave
annotate libinterp/octave-value/ov-classdef.h @ 20941:a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
* debug.cc, det.cc, ellipj.cc, error.cc, file-io.cc, graphics.cc, hess.cc,
input.cc, inv.cc, load-path.cc, lu.cc, octave-link.cc, pager.cc, pinv.cc,
pr-output.cc, profiler.cc, schur.cc, symtab.cc, sysdep.cc, urlwrite.cc,
variables.cc, __magick_read__.cc, audioread.cc, chol.cc, ov-classdef.h,
ov-cs-list.cc, ov-flt-re-mat.cc, ov-re-mat.cc, ov-usr-fcn.cc:
maint: Replace "octave_value_list ()" with "ovl ()".
author | Rik <rik@octave.org> |
---|---|
date | Fri, 18 Dec 2015 16:18:41 -0800 |
parents | 384ff5aa9437 |
children | 6eff66fb8a02 |
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 |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19598
diff
changeset
|
3 Copyright (C) 2012-2015 Michael Goffioul |
15036
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 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20545
diff
changeset
|
23 #if ! defined (octave_classdef_h) |
15036
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" |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
33 #include "symtab.h" |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
34 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
35 class cdef_object; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
36 class cdef_class; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
37 class cdef_property; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
38 class cdef_method; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
39 class cdef_package; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
40 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
41 class tree_classdef; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
42 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
43 // 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
|
44 // 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
|
45 // 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
|
46 class |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
47 cdef_object_rep |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
48 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
49 public: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
50 friend class cdef_object; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
51 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
52 public: |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
53 cdef_object_rep (void) : refcount (1) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
54 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
55 virtual ~cdef_object_rep (void) { } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
56 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
57 virtual cdef_class get_class (void) const; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
58 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
59 virtual void set_class (const cdef_class&) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
60 { gripe_invalid_object ("set_class"); } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
61 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
62 virtual cdef_object_rep* clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
63 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
64 gripe_invalid_object ("clone"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
65 return new cdef_object_rep (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
66 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
67 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
68 virtual cdef_object_rep* empty_clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
69 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
70 gripe_invalid_object ("empty_clone"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
71 return new cdef_object_rep (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
72 } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
73 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
74 virtual cdef_object_rep* copy (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
75 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
76 gripe_invalid_object ("copy"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
77 return new cdef_object_rep (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
78 } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
79 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
80 virtual cdef_object_rep* make_array (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
81 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
82 gripe_invalid_object ("make_array"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
83 return new cdef_object_rep (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
84 } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
85 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
86 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
|
87 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
88 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
|
89 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
90 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
|
91 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
92 virtual bool is_meta_object (void) const { return false; } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
93 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
94 virtual Array<cdef_object> array_value (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
95 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
96 gripe_invalid_object ("array_value"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
97 return Array<cdef_object> (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
98 } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
99 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
100 virtual void put (const std::string&, const octave_value&) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
101 { gripe_invalid_object ("put"); } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
102 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
103 virtual octave_value get (const std::string&) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
104 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
105 gripe_invalid_object ("get"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
106 return octave_value (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
107 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
108 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
109 virtual octave_value_list |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
110 subsref (const std::string&, const std::list<octave_value_list>&, |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
111 int, size_t&, const cdef_class&, bool) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
112 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
113 gripe_invalid_object ("subsref"); |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
114 return ovl (); |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
115 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
116 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
117 virtual octave_value |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
118 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
|
119 const octave_value&) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
120 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
121 gripe_invalid_object ("subsasgn"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
122 return octave_value (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
123 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
124 |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
125 virtual string_vector map_keys (void) const; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
126 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
127 virtual bool is_valid (void) const { return false; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
128 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
129 std::string class_name (void) const; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
130 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
131 virtual void mark_for_construction (const cdef_class&) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
132 { 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
|
133 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
134 virtual bool is_constructed_for (const cdef_class&) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
135 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
136 gripe_invalid_object ("is_constructed_for"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
137 return false; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
138 } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
139 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
140 virtual bool is_partially_constructed_for (const cdef_class&) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
141 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
142 gripe_invalid_object ("is_partially_constructed_for"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
143 return false; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
144 } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
145 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
146 virtual void mark_as_constructed (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
147 { gripe_invalid_object ("mark_as_constructed"); } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
148 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
149 virtual void mark_as_constructed (const cdef_class&) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
150 { 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
|
151 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
152 virtual bool is_constructed (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
153 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
154 gripe_invalid_object ("is_constructed"); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
155 return false; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
156 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
157 |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
158 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
|
159 |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
160 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
|
161 |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
162 void release (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
163 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
164 if (--refcount == static_count ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
165 destroy (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
166 } |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
167 |
15936
da4cd4ab36db
Report correct size for object of classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15926
diff
changeset
|
168 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
|
169 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
170 protected: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
171 /* reference count */ |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
172 octave_refcount<octave_idx_type> refcount; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
173 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
174 protected: |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
175 /* Restricted copying */ |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
176 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
|
177 : refcount (1) { } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
178 |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
179 private: |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
180 /* No assignment */ |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
181 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
|
182 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
183 void gripe_invalid_object (const char *who) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
184 { error ("%s: invalid object", who); } |
15036
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 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
187 class |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
188 cdef_object |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
189 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
190 public: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
191 /* FIXME: use a null object */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
192 cdef_object (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
193 : rep (new cdef_object_rep ()) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
194 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
195 cdef_object (const cdef_object& obj) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
196 : rep (obj.rep) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
197 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
198 rep->refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
199 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
200 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
201 cdef_object (cdef_object_rep *r) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
202 : rep (r) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
203 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
204 virtual ~cdef_object (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
205 { rep->release (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
206 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
207 cdef_object& operator = (const cdef_object& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
208 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
209 if (rep != obj.rep) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
210 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
211 rep->release (); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
212 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
213 rep = obj.rep; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
214 rep->refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
215 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
216 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
217 return *this; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
218 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
219 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
220 cdef_class get_class (void) const; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
221 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
222 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
|
223 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
224 std::string class_name (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
225 { return rep->class_name (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
226 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
227 cdef_object clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
228 { return cdef_object (rep->clone ()); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
229 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
230 cdef_object empty_clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
231 { return cdef_object (rep->empty_clone ()); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
232 |
15936
da4cd4ab36db
Report correct size for object of classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15926
diff
changeset
|
233 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
|
234 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
235 cdef_object make_array (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
236 { return cdef_object (rep->make_array ()); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
237 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
238 cdef_object copy (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
239 { return cdef_object (rep->copy ()); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
240 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
241 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
|
242 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
243 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
|
244 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
245 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
|
246 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
247 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
|
248 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
249 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
|
250 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
251 void put (const std::string& pname, const octave_value& val) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
252 { rep->put (pname, val); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
253 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
254 octave_value get (const std::string& pname) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
255 { return rep->get (pname); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
256 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
257 octave_value_list |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
258 subsref (const std::string& type, const std::list<octave_value_list>& idx, |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
259 int nargout, size_t& skip, const cdef_class& context, |
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
260 bool auto_add = false) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
261 { return rep->subsref (type, idx, nargout, skip, context, auto_add); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
262 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
263 octave_value |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
264 subsasgn (const std::string& type, const std::list<octave_value_list>& idx, |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
265 const octave_value& rhs, int ignore_copies = 0) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
266 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
267 make_unique (ignore_copies); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
268 return rep->subsasgn (type, idx, rhs); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
269 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
270 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
271 string_vector map_keys (void) const { return rep->map_keys (); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
272 |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
273 octave_map map_value (void) const; |
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
274 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
275 const cdef_object_rep* get_rep (void) const { return rep; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
276 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
277 bool ok (void) const { return rep->is_valid (); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
278 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
279 void mark_for_construction (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
280 { rep->mark_for_construction (cls); } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
281 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
282 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
|
283 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
284 bool is_constructed_for (const cdef_class& cls) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
285 { 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
|
286 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
287 bool is_partially_constructed_for (const cdef_class& cls) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
288 { 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
|
289 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
290 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
|
291 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
292 void mark_as_constructed (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
293 { rep->mark_as_constructed (cls); } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
294 |
16695
2823f8e3da77
Add multi-level index assignment for object array.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
295 bool is (const cdef_object& obj) const { return rep == obj.rep; } |
2823f8e3da77
Add multi-level index assignment for object array.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16684
diff
changeset
|
296 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
297 protected: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
298 cdef_object_rep* get_rep (void) { return rep; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
299 |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
300 void make_unique (int ignore_copies) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
301 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
302 if (rep->refcount > ignore_copies + 1) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
303 *this = clone (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
304 } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
305 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
306 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
307 cdef_object_rep *rep; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
308 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
309 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
310 class |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
311 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
|
312 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
313 public: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
314 cdef_object_base (void) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
315 : cdef_object_rep (), klass () |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
316 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
317 register_object (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
318 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
319 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
320 ~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
|
321 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
322 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
|
323 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
324 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
|
325 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
326 cdef_object_rep* empty_clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
327 { return new cdef_object_base (*this); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
328 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
329 cdef_object_rep* make_array (void) const; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
330 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
331 protected: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
332 // Restricted copying! |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
333 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
|
334 : cdef_object_rep (obj), klass (obj.klass) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
335 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
336 register_object (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
337 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
338 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
339 private: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
340 void register_object (void); |
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 void unregister_object (void); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
343 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
344 private: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
345 // The class of the object |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
346 cdef_object klass; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
347 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
348 private: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
349 // No assignment! |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
350 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
|
351 }; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
352 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
353 class |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
354 cdef_object_array : public cdef_object_base |
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 public: |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
357 cdef_object_array (void) : cdef_object_base () { } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
358 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
359 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
|
360 : cdef_object_base (), array (a) { } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
361 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
362 cdef_object_rep* clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
363 { return new cdef_object_array (*this); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
364 |
15936
da4cd4ab36db
Report correct size for object of classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15926
diff
changeset
|
365 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
|
366 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
367 bool is_valid (void) const { return true; } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
368 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
369 bool is_array (void) const { return true; } |
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 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
|
372 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
373 octave_value_list |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
374 subsref (const std::string& type, const std::list<octave_value_list>& idx, |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
375 int nargout, size_t& skip, const cdef_class& context, |
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
376 bool auto_add); |
15913
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 octave_value |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
379 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
|
380 const octave_value& rhs); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
381 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
382 private: |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
383 Array<cdef_object> 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 private: |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
386 void fill_empty_values (void) { fill_empty_values (array); } |
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
387 |
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
388 void fill_empty_values (Array<cdef_object>& arr); |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
389 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
390 // Private copying! |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
391 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
|
392 : cdef_object_base (obj), array (obj.array) { } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
393 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
394 // No assignment! |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
395 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
|
396 }; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
397 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
398 class |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
399 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
|
400 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
401 public: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
402 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
|
403 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
404 ~cdef_object_scalar (void) { } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
405 |
15936
da4cd4ab36db
Report correct size for object of classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15926
diff
changeset
|
406 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
|
407 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
408 void put (const std::string& pname, const octave_value& val) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
409 { map.assign (pname, val); } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
410 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
411 octave_value get (const std::string& pname) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
412 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
413 Cell val = map.contents (pname); |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
414 |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
415 if (val.numel () < 1) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
416 error ("get: unknown slot: %s", pname.c_str ()); |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
417 |
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
418 return val(0, 0); |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
419 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
420 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
421 octave_value_list |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
422 subsref (const std::string& type, const std::list<octave_value_list>& idx, |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
423 int nargout, size_t& skip, const cdef_class& context, |
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
424 bool auto_add); |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
425 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
426 octave_value |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
427 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
|
428 const octave_value& rhs); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
429 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
430 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
|
431 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
432 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
|
433 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
434 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
|
435 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
436 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
|
437 |
20841
9851a296cf87
Fix compilation of classdef with the clang compiler (bug #41178)
akira noda <you.akira.noda@gmail.com>
parents:
19861
diff
changeset
|
438 void mark_as_constructed (const cdef_class& cls); |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
439 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
440 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
|
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 // Object property values |
18396
954bf42180d3
Remove use of deprecate Octave_map in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18382
diff
changeset
|
444 octave_scalar_map map; |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
445 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
446 // 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
|
447 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
|
448 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
449 protected: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
450 // Restricted object copying! |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
451 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
|
452 : 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
|
453 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
454 private: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
455 // No assignment! |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
456 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
|
457 }; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
458 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
459 class |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
460 handle_cdef_object : public cdef_object_scalar |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
461 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
462 public: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
463 handle_cdef_object (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
464 : cdef_object_scalar () { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
465 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
466 ~handle_cdef_object (void); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
467 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
468 cdef_object_rep* clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
469 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
470 handle_cdef_object *obj = const_cast<handle_cdef_object *> (this); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
471 obj->refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
472 return obj; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
473 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
474 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
475 cdef_object_rep* copy (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
476 { return new handle_cdef_object (*this); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
477 |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
478 bool is_valid (void) const { return true; } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
479 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
480 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
|
481 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
482 protected: |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
483 // Restricted copying! |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
484 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
|
485 : cdef_object_scalar (obj) { } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
486 |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
487 private: |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
488 // No assignment |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
489 handle_cdef_object& operator = (const handle_cdef_object&); |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
490 }; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
491 |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
492 class |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
493 value_cdef_object : public cdef_object_scalar |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
494 { |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
495 public: |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
496 value_cdef_object (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
497 : cdef_object_scalar () { } |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
498 |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
499 ~value_cdef_object (void); |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
500 |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
501 cdef_object_rep* clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
502 { return new value_cdef_object (*this); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
503 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
504 cdef_object_rep* copy (void) const { return clone (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
505 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
506 bool is_valid (void) const { return true; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
507 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
508 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
|
509 |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
510 private: |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
511 // Private copying! |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
512 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
|
513 : cdef_object_scalar (obj) { } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
514 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
515 // No assignment! |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
516 value_cdef_object& operator = (const value_cdef_object&); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
517 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
518 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
519 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
|
520 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
|
521 { |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
522 public: |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
523 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
|
524 : 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
|
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 ~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
|
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 cdef_object_rep* copy (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
529 { return new cdef_meta_object_rep (*this); } |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
530 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
531 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
|
532 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
533 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
|
534 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
535 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
|
536 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
537 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
|
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 virtual bool is_package (void) const { return false; } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
540 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
541 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
|
542 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
|
543 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
|
544 int /* nargout */) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
545 { |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
546 error ("subsref: invalid meta object"); |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
547 } |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
548 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
549 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
|
550 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
551 virtual bool meta_is_postfix_index_handled (char /* type */) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
552 { return false; } |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
553 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
554 protected: |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
555 // 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
|
556 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
|
557 : 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
|
558 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
559 private: |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
560 // 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
|
561 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
|
562 }; |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
563 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
564 class |
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 : 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
|
566 { |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
567 public: |
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 (void) |
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 () { } |
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 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
|
572 : 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 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
574 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
|
575 : 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
|
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 // 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
|
578 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
|
579 : 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
|
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 ~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
|
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_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
|
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 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
|
586 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
587 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
|
588 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
589 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
|
590 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
591 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
|
592 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
|
593 const std::list<octave_value_list>& idx, int nargout) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
594 { return get_rep ()->meta_subsref (type, idx, nargout); } |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
595 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
596 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
|
597 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
598 bool meta_is_postfix_index_handled (char type) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
599 { return get_rep ()->meta_is_postfix_index_handled (type); } |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
600 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
601 private: |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
602 cdef_meta_object_rep* get_rep (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
603 { return dynamic_cast<cdef_meta_object_rep *> (cdef_object::get_rep ()); } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
604 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
605 const cdef_meta_object_rep* get_rep (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
606 { return dynamic_cast<const cdef_meta_object_rep *> (cdef_object::get_rep ()); } |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
607 }; |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
608 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
609 class |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
610 cdef_class : public cdef_meta_object |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
611 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
612 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
613 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
614 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
|
615 cdef_class_rep : public cdef_meta_object_rep |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
616 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
617 public: |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
618 cdef_class_rep (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
619 : cdef_meta_object_rep (), member_count (0), handle_class (false), |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
620 object_count (0), meta (false) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
621 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
622 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
|
623 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
624 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
|
625 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
626 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
|
627 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
628 std::string get_name (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
629 { return get ("Name").string_value (); } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
630 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
631 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
|
632 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
633 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
|
634 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
635 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
|
636 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
637 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
|
638 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
639 void install_method (const cdef_method& meth); |
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_methods (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 cdef_property find_property (const std::string& nm); |
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 install_property (const cdef_property& prop); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
646 |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
647 Cell get_properties (int mode); |
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
648 |
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
649 std::map<std::string, cdef_property> get_property_map (int mode); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
650 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
651 string_vector get_names (void); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
652 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
653 void set_directory (const std::string& dir) { directory = dir; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
654 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
655 std::string get_directory (void) const { return directory; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
656 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
657 void delete_object (cdef_object obj); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
658 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
659 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
|
660 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
|
661 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
|
662 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
663 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
|
664 |
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
665 bool meta_is_postfix_index_handled (char type) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
666 { return (type == '(' || type == '.'); } |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
667 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
668 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
|
669 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
670 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
|
671 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
672 void initialize_object (cdef_object& obj); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
673 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
674 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
|
675 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
676 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
|
677 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
678 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
|
679 |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
680 void register_object (void) { object_count++; } |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
681 |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
682 void unregister_object (void) { object_count--; } |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
683 |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
684 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
|
685 |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
686 void destroy (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
687 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
688 if (member_count) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
689 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
690 refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
691 cdef_class lock (this); |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
692 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
693 member_count = 0; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
694 method_map.clear (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
695 property_map.clear (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
696 } |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
697 else |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
698 delete this; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
699 } |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
700 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
701 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
|
702 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
703 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
|
704 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
705 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
706 void load_all_methods (void); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
707 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
708 void find_names (std::set<std::string>& names, bool all); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
709 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
710 void find_properties (std::map<std::string,cdef_property>& props, |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
711 int mode = 0); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
712 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
713 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
|
714 bool only_inherited); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
715 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
716 cdef_class wrap (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
717 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
718 refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
719 return cdef_class (this); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
720 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
721 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
722 private: |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
723 // 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
|
724 // (not used yet) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
725 std::string directory; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
726 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
727 // The methods defined by this class. |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
728 std::map<std::string,cdef_method> method_map; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
729 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
730 // The properties defined by this class. |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
731 std::map<std::string,cdef_property> property_map; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
732 |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
733 // 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
|
734 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
|
735 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
736 // 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
|
737 // 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
|
738 bool handle_class; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
739 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
740 // 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
|
741 // 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
|
742 // 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
|
743 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
|
744 |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
745 // The number of objects of this class. |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
746 octave_refcount<octave_idx_type> object_count; |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
747 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
748 // 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
|
749 bool meta; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
750 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
751 // Utility iterator typedef's. |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
752 typedef std::map<std::string,cdef_method>::iterator method_iterator; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
753 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
|
754 typedef std::map<std::string,cdef_property>::iterator property_iterator; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
755 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
|
756 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
757 private: |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
758 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
|
759 : 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
|
760 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
|
761 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
|
762 implicit_ctor_list (c.implicit_ctor_list), |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
763 object_count (c.object_count), meta (c.meta) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
764 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
765 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
766 public: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
767 // Create and invalid class object |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
768 cdef_class (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
769 : cdef_meta_object () { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
770 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
771 cdef_class (const std::string& nm, |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
772 const std::list<cdef_class>& superclasses) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
773 : cdef_meta_object (new cdef_class_rep (superclasses)) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
774 { get_rep ()->set_name (nm); } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
775 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
776 cdef_class (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
777 : cdef_meta_object (cls) { } |
15036
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 cdef_class (const cdef_object& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
780 : cdef_meta_object (obj) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
781 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
782 // This should never happen... |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
783 if (! is_class ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
784 error ("internal error: invalid assignment from %s to meta.class object", |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
785 class_name ().c_str ()); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
786 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
787 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
788 cdef_class& operator = (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
789 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
790 cdef_object::operator= (cls); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
791 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
792 return *this; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
793 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
794 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
795 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
|
796 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
797 void install_method (const cdef_method& meth) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
798 { get_rep ()->install_method (meth); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
799 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
800 Cell get_methods (void) { return get_rep ()->get_methods (); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
801 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
802 cdef_property find_property (const std::string& nm); |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
803 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
804 void install_property (const cdef_property& prop) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
805 { get_rep ()->install_property (prop); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
806 |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
807 Cell get_properties (int mode = property_normal) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
808 { return get_rep ()->get_properties (mode); } |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
809 |
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
810 std::map<std::string, cdef_property> |
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
811 get_property_map (int mode = property_normal) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
812 { return get_rep ()->get_property_map (mode); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
813 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
814 string_vector get_names (void) { return get_rep ()->get_names (); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
815 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
816 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
|
817 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
818 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
|
819 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
820 void set_directory (const std::string& dir) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
821 { get_rep ()->set_directory (dir); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
822 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
823 std::string get_directory (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
824 { return get_rep ()->get_directory (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
825 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
826 std::string get_name (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
827 { return get_rep ()->get_name (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
828 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
829 bool is_builtin (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
830 { return get_directory ().empty (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
831 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
832 void delete_object (cdef_object obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
833 { get_rep ()->delete_object (obj); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
834 |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
835 static cdef_class make_meta_class (tree_classdef* t, |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
836 bool is_at_folder = false); |
15869
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 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
|
839 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
840 octave_function* get_constructor_function (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
841 { return get_method_function (get_name ()); } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
842 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
843 octave_value construct (const octave_value_list& args) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
844 { return get_rep ()->construct (args); } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
845 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
846 cdef_object construct_object (const octave_value_list& args) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
847 { return get_rep ()->construct_object (args); } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
848 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
849 void initialize_object (cdef_object& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
850 { get_rep ()->initialize_object (obj); } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
851 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
852 void run_constructor (cdef_object& obj, const octave_value_list& args) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
853 { get_rep ()->run_constructor (obj, args); } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
854 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
855 void mark_as_handle_class (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
856 { get_rep ()->mark_as_handle_class (); } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
857 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
858 bool is_handle_class (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
859 { return get_rep ()->is_handle_class (); } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
860 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
861 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
|
862 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
863 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
|
864 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
865 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
|
866 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
|
867 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
|
868 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
|
869 |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
870 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
|
871 |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
872 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
|
873 |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
874 public: |
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
875 enum |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
876 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
877 property_normal, |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
878 property_inherited, |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
879 property_all |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
880 }; |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
881 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
882 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
883 cdef_class_rep* get_rep (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
884 { return dynamic_cast<cdef_class_rep *> (cdef_object::get_rep ()); } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
885 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
886 const cdef_class_rep* get_rep (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
887 { return dynamic_cast<const cdef_class_rep *> (cdef_object::get_rep ()); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
888 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
889 friend bool operator == (const cdef_class&, const cdef_class&); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
890 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
|
891 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
|
892 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
893 private: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
894 static cdef_class _meta_class; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
895 static cdef_class _meta_property; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
896 static cdef_class _meta_method; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
897 static cdef_class _meta_package; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
898 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
899 friend void install_classdef (void); |
15036
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 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
902 inline bool |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
903 operator == (const cdef_class& clsa, const cdef_class& clsb) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
904 // 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
|
905 { return (clsa.get_rep () == clsb.get_rep ()); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
906 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
907 inline bool |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
908 operator != (const cdef_class& clsa, const cdef_class& clsb) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
909 { return ! (clsa == clsb); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
910 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
911 // 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
|
912 inline bool |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
913 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
|
914 { 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
|
915 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
916 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
|
917 cdef_property : public cdef_meta_object |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
918 { |
15926
f97a746e4544
ov-classdef.h: Include class-key when declaring a friend
Ben Abbott <bpabbott@mac.com>
parents:
15913
diff
changeset
|
919 friend class cdef_class; |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
920 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
921 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
922 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
923 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
|
924 cdef_property_rep : public cdef_meta_object_rep |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
925 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
926 public: |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
927 cdef_property_rep (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
928 : cdef_meta_object_rep () { } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
929 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
930 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
|
931 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
932 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
|
933 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
934 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
|
935 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
936 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
|
937 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
938 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
|
939 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
940 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
|
941 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
|
942 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
943 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
|
944 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
|
945 const std::string& who = std::string ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
946 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
947 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
|
948 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
|
949 const std::string& who = std::string ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
950 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
951 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
|
952 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
953 bool check_set_access (void) const; |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
954 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
955 private: |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
956 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
|
957 : cdef_meta_object_rep (p) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
958 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
959 bool is_recursive_set (const cdef_object& obj) const; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
960 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
961 cdef_property wrap (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
962 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
963 refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
964 return cdef_property (this); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
965 } |
15036
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 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
968 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
|
969 cdef_property (void) : cdef_meta_object () { } |
15036
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 cdef_property (const std::string& nm) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
972 : cdef_meta_object (new cdef_property_rep ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
973 { get_rep ()->set_name (nm); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
974 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
975 cdef_property (const cdef_property& prop) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
976 : cdef_meta_object (prop) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
977 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
978 cdef_property (const cdef_object& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
979 : cdef_meta_object (obj) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
980 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
981 // This should never happen... |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
982 if (! is_property ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
983 error ("internal error: invalid assignment from %s to meta.property object", |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
984 class_name ().c_str ()); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
985 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
986 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
987 cdef_property& operator = (const cdef_property& prop) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
988 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
989 cdef_object::operator= (prop); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
990 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
991 return *this; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
992 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
993 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
994 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
|
995 const std::string& who = std::string ()) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
996 { 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
|
997 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
998 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
|
999 const std::string& who = std::string ()) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1000 { return get_rep ()->get_value (do_check_access, who); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1001 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1002 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
|
1003 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
|
1004 const std::string& who = std::string ()) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1005 { 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
|
1006 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1007 bool check_get_access (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1008 { return get_rep ()->check_get_access (); } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
1009 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1010 bool check_set_access (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1011 { return get_rep ()->check_set_access (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1012 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1013 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
|
1014 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1015 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
|
1016 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1017 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1018 cdef_property_rep* get_rep (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1019 { return dynamic_cast<cdef_property_rep *> (cdef_object::get_rep ()); } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
1020 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1021 const cdef_property_rep* get_rep (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1022 { return dynamic_cast<const cdef_property_rep *> (cdef_object::get_rep ()); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1023 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1024 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1025 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
|
1026 cdef_method : public cdef_meta_object |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1027 { |
15926
f97a746e4544
ov-classdef.h: Include class-key when declaring a friend
Ben Abbott <bpabbott@mac.com>
parents:
15913
diff
changeset
|
1028 friend class cdef_class; |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1029 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1030 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1031 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1032 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
|
1033 cdef_method_rep : public cdef_meta_object_rep |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1034 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1035 public: |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1036 cdef_method_rep (void) |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1037 : cdef_meta_object_rep (), function (), dispatch_type () |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1038 { } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1039 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1040 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
|
1041 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1042 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
|
1043 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1044 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
|
1045 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1046 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
|
1047 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1048 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
|
1049 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1050 octave_value get_function (void) const { return function; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1051 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1052 void set_function (const octave_value& fcn) { function = fcn; } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1053 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1054 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
|
1055 |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1056 bool is_external (void) const { return ! dispatch_type.empty (); } |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1057 |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1058 void mark_as_external (const std::string& dtype) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1059 { dispatch_type = dtype; } |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1060 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1061 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
|
1062 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
|
1063 const std::string& who = std::string ()); |
15036
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 octave_value_list execute (const cdef_object& obj, |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18416
diff
changeset
|
1066 const octave_value_list& args, int nargout, |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1067 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
|
1068 const std::string& who = std::string ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1069 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1070 bool is_constructor (void) const; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1071 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1072 octave_value_list |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1073 meta_subsref (const std::string& type, |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1074 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
|
1075 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1076 bool meta_is_postfix_index_handled (char type) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1077 { return (type == '(' || type == '.'); } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1078 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1079 private: |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1080 cdef_method_rep (const cdef_method_rep& m) |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1081 : cdef_meta_object_rep (m), function (m.function), |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1082 dispatch_type (m.dispatch_type) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1083 { } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1084 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1085 void check_method (void); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1086 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1087 cdef_method wrap (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1088 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1089 refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1090 return cdef_method (this); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1091 } |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1092 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1093 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1094 octave_value function; |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1095 |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1096 // When non-empty, the method is externally defined and this member |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1097 // is used to cache the dispatch type to look for the method. |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1098 std::string dispatch_type; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1099 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1100 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1101 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
|
1102 cdef_method (void) : cdef_meta_object () { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1103 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1104 cdef_method (const std::string& nm) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1105 : cdef_meta_object (new cdef_method_rep ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1106 { get_rep ()->set_name (nm); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1107 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
1108 cdef_method (const cdef_method& meth) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1109 : cdef_meta_object (meth) { } |
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 cdef_method (const cdef_object& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1112 : cdef_meta_object (obj) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1113 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1114 // This should never happen... |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1115 if (! is_method ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1116 error ("internal error: invalid assignment from %s to meta.method object", |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1117 class_name ().c_str ()); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1118 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1119 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1120 cdef_method& operator = (const cdef_method& meth) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1121 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1122 cdef_object::operator= (meth); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1123 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1124 return *this; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1125 } |
15036
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 /* 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
|
1128 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
|
1129 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
|
1130 const std::string& who = std::string ()) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1131 { 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
|
1132 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1133 /* dot-invokation: object is pushed as 1st argument */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1134 octave_value_list execute (const cdef_object& obj, |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18416
diff
changeset
|
1135 const octave_value_list& args, int nargout, |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1136 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
|
1137 const std::string& who = std::string ()) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1138 { 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
|
1139 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15936
diff
changeset
|
1140 bool check_access (void) const { return get_rep ()->check_access (); } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
1141 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1142 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
|
1143 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1144 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
|
1145 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1146 void set_function (const octave_value& fcn) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1147 { get_rep ()->set_function (fcn); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1148 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1149 octave_value get_function (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1150 { return get_rep ()->get_function (); } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1151 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1152 bool is_constructor (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1153 { return get_rep ()->is_constructor (); } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1154 |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1155 bool is_external (void) const { return get_rep ()->is_external (); } |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1156 |
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1157 void mark_as_external (const std::string& dtype) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1158 { get_rep ()->mark_as_external (dtype); } |
18263
b5be1a2aa5ab
Initial implementation for classdef methods in separate files.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17746
diff
changeset
|
1159 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1160 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1161 cdef_method_rep* get_rep (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1162 { return dynamic_cast<cdef_method_rep *> (cdef_object::get_rep ()); } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
1163 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1164 const cdef_method_rep* get_rep (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1165 { return dynamic_cast<const cdef_method_rep *> (cdef_object::get_rep ()); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1166 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1167 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1168 inline cdef_class |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1169 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
|
1170 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1171 gripe_invalid_object ("get_class"); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1172 return cdef_class (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1173 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1174 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1175 inline std::string |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1176 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
|
1177 { return get_class ().get_name (); } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1178 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1179 inline cdef_class |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1180 cdef_object::get_class (void) const |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1181 { return rep->get_class (); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1182 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1183 inline cdef_class |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1184 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
|
1185 { return cdef_class (klass); } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1186 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1187 inline void |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1188 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
|
1189 { |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1190 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
|
1191 || (klass.ok () && ! cls.ok ()) |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1192 || (! klass.ok () && cls.ok ())) |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1193 { |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1194 unregister_object (); |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1195 klass = cls; |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1196 register_object (); |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1197 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1198 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1199 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1200 inline void |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1201 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
|
1202 { |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1203 if (klass.ok ()) |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1204 { |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1205 cdef_class cls (get_class ()); |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1206 |
20545
c547458dc10e
eliminate error_state from most header files
John W. Eaton <jwe@octave.org>
parents:
20488
diff
changeset
|
1207 if (cls.ok ()) |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1208 cls.register_object (); |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1209 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1210 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1211 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1212 inline void |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1213 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
|
1214 { |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1215 if (klass.ok ()) |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1216 { |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1217 cdef_class cls (get_class ()); |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1218 |
20545
c547458dc10e
eliminate error_state from most header files
John W. Eaton <jwe@octave.org>
parents:
20488
diff
changeset
|
1219 if (cls.ok ()) |
15910
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1220 cls.unregister_object (); |
dfd0dc594c4f
Add object counting to cdef_class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15909
diff
changeset
|
1221 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1222 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1223 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1224 inline cdef_object_rep* |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1225 cdef_object_base::make_array (void) const |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1226 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1227 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
|
1228 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1229 r->set_class (get_class ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1230 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1231 return r; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1232 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1233 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1234 inline cdef_method |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1235 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
|
1236 { return get_rep ()->find_method (nm, local); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1237 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1238 inline cdef_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1239 cdef_class::find_property (const std::string& nm) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1240 { return get_rep ()->find_property (nm); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1241 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1242 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
|
1243 cdef_package : public cdef_meta_object |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1244 { |
15926
f97a746e4544
ov-classdef.h: Include class-key when declaring a friend
Ben Abbott <bpabbott@mac.com>
parents:
15913
diff
changeset
|
1245 friend class cdef_class; |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1246 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1247 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1248 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1249 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
|
1250 cdef_package_rep : public cdef_meta_object_rep |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1251 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1252 public: |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1253 cdef_package_rep (void) |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
1254 : cdef_meta_object_rep (), member_count (0) { } |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1255 |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
1256 ~cdef_package_rep (void) { } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1257 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1258 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
|
1259 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1260 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
|
1261 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1262 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
|
1263 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1264 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
|
1265 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1266 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
|
1267 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1268 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
|
1269 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1270 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
|
1271 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1272 Cell get_classes (void) const; |
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 Cell get_functions (void) const; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1275 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1276 Cell get_packages (void) const; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1277 |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1278 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
|
1279 |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1280 void destroy (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1281 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1282 if (member_count) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1283 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1284 refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1285 cdef_package lock (this); |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1286 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1287 member_count = 0; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1288 class_map.clear (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1289 package_map.clear (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1290 } |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1291 else |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1292 delete this; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1293 } |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1294 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1295 octave_value_list |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1296 meta_subsref (const std::string& type, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1297 const std::list<octave_value_list>& idx, int nargout); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1298 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1299 void meta_release (void); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1300 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1301 bool meta_is_postfix_index_handled (char type) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1302 { return (type == '.'); } |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1303 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1304 octave_value find (const std::string& nm); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1305 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1306 private: |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1307 std::string full_name; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1308 std::map<std::string, cdef_class> class_map; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1309 std::map<std::string, octave_value> function_map; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1310 std::map<std::string, cdef_package> package_map; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1311 |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1312 // 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
|
1313 // 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
|
1314 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
|
1315 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1316 typedef std::map<std::string, cdef_class>::iterator class_iterator; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1317 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
|
1318 typedef std::map<std::string, octave_value>::iterator function_iterator; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1319 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
|
1320 typedef std::map<std::string, cdef_package>::iterator package_iterator; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1321 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
|
1322 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1323 private: |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1324 cdef_package_rep (const cdef_package_rep& p) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1325 : cdef_meta_object_rep (p), full_name (p.full_name), |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1326 class_map (p.class_map), function_map (p.function_map), |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1327 package_map (p.package_map), member_count (p.member_count) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1328 { } |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1329 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1330 cdef_package wrap (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1331 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1332 refcount++; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1333 return cdef_package (this); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1334 } |
15036
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 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1337 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
|
1338 cdef_package (void) : cdef_meta_object () { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1339 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1340 cdef_package (const std::string& nm) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1341 : cdef_meta_object (new cdef_package_rep ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1342 { get_rep ()->set_name (nm); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1343 |
15986
14aa0b5a980c
Abstract the meta-protocol layer to use it for other meta objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15968
diff
changeset
|
1344 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
|
1345 : 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
|
1346 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1347 cdef_package (const cdef_object& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1348 : cdef_meta_object (obj) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1349 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1350 // This should never happen... |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1351 if (! is_package ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1352 error ("internal error: invalid assignment from %s to meta.package object", |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1353 class_name ().c_str ()); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1354 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1355 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1356 cdef_package& operator = (const cdef_package& pack) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1357 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1358 cdef_object::operator= (pack); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1359 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1360 return *this; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1361 } |
15036
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 void install_class (const cdef_class& cls, const std::string& nm) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1364 { get_rep ()->install_class (cls, nm); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1365 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1366 void install_function (const octave_value& fcn, const std::string& nm) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1367 { get_rep ()->install_function (fcn, nm); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1368 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1369 void install_package (const cdef_package& pack, const std::string& nm) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1370 { get_rep ()->install_package (pack, nm); } |
15036
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 Cell get_classes (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1373 { return get_rep ()->get_classes (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1374 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1375 Cell get_functions (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1376 { return get_rep ()->get_functions (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1377 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1378 Cell get_packages (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1379 { return get_rep ()->get_packages (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1380 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1381 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
|
1382 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1383 octave_value find (const std::string& nm) { return get_rep ()->find (nm); } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1384 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1385 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
|
1386 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1387 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1388 cdef_package_rep* get_rep (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1389 { return dynamic_cast<cdef_package_rep *> (cdef_object::get_rep ()); } |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19184
diff
changeset
|
1390 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1391 const cdef_package_rep* get_rep (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1392 { 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
|
1393 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1394 private: |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1395 static cdef_package _meta; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1396 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
1397 friend void install_classdef (void); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1398 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1399 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1400 class |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1401 octave_classdef : public octave_base_value |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1402 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1403 public: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1404 octave_classdef (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1405 : octave_base_value (), object () { } |
15036
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 octave_classdef (const cdef_object& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1408 : octave_base_value (), object (obj) { } |
15036
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 octave_classdef (const octave_classdef& obj) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1411 : octave_base_value (obj), object (obj.object) { } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1412 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1413 octave_base_value* clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1414 { return new octave_classdef (object.clone ()); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1415 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1416 octave_base_value* empty_clone (void) const |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1417 { return new octave_classdef (object.empty_clone ()); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1418 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1419 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
|
1420 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1421 cdef_object& get_object_ref (void) { return object; } |
15036
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 bool is_defined (void) const { return true; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1424 |
19110
fa48651fbb8a
isstruct for classdef objects should not return true.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19103
diff
changeset
|
1425 bool is_map (void) const { return false; } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1426 |
18306
122239398a03
Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18263
diff
changeset
|
1427 bool is_object (void) const { return true; } |
122239398a03
Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18263
diff
changeset
|
1428 |
19110
fa48651fbb8a
isstruct for classdef objects should not return true.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19103
diff
changeset
|
1429 bool is_classdef_object (void) const { return true; } |
fa48651fbb8a
isstruct for classdef objects should not return true.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19103
diff
changeset
|
1430 |
18416
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18397
diff
changeset
|
1431 void print (std::ostream& os, bool pr_as_read_syntax = false); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1432 |
18416
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18397
diff
changeset
|
1433 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1434 |
18416
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18397
diff
changeset
|
1435 bool print_name_tag (std::ostream& os, const std::string& name) const; |
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18397
diff
changeset
|
1436 |
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18397
diff
changeset
|
1437 void print_with_name (std::ostream& os, const std::string& name, |
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18397
diff
changeset
|
1438 bool print_padding = true); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1439 |
19103
56bc1464ec59
Implement "isa" for classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18692
diff
changeset
|
1440 bool is_instance_of (const std::string& cls_name) const; |
56bc1464ec59
Implement "isa" for classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18692
diff
changeset
|
1441 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1442 octave_value_list subsref (const std::string& type, |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18416
diff
changeset
|
1443 const std::list<octave_value_list>& idx, |
18416
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18397
diff
changeset
|
1444 int nargout); |
15036
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 octave_value subsref (const std::string& type, |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18416
diff
changeset
|
1447 const std::list<octave_value_list>& idx) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1448 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1449 octave_value_list retval = subsref (type, idx, 1); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1450 return (retval.length () > 0 ? retval(0) : octave_value ()); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1451 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1452 |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
1453 octave_value subsref (const std::string& type, |
18692
fe0e34be5576
maint: untabify recently added code files.
Rik <rik@octave.org>
parents:
18416
diff
changeset
|
1454 const std::list<octave_value_list>& idx, |
16696
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
1455 bool auto_add); |
665fa0f621cc
Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16695
diff
changeset
|
1456 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1457 octave_value subsasgn (const std::string& type, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1458 const std::list<octave_value_list>& idx, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1459 const octave_value& rhs); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1460 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1461 octave_value |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1462 undef_subsasgn (const std::string& type, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1463 const std::list<octave_value_list>& idx, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1464 const octave_value& rhs); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1465 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1466 string_vector map_keys (void) const { return object.map_keys (); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1467 |
19184
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
1468 octave_map map_value (void) const { return object.map_value (); } |
e0a7718ac085
Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
19110
diff
changeset
|
1469 |
15936
da4cd4ab36db
Report correct size for object of classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15926
diff
changeset
|
1470 dim_vector dims (void) const { return object.dims (); } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1471 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1472 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1473 cdef_object object; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1474 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1475 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1476 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1477 public: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1478 int type_id (void) const { return t_id; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1479 std::string type_name (void) const { return t_name; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1480 std::string class_name (void) const { return object.class_name (); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1481 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1482 static int static_type_id (void) { return t_id; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1483 static std::string static_type_name (void) { return t_name; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1484 static std::string static_class_name (void) { return "<unknown>"; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1485 static void register_type (void); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1486 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1487 private: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1488 static int t_id; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1489 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1490 static const std::string t_name; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1491 }; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1492 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1493 inline octave_value |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1494 to_ov (const cdef_object& obj) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1495 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1496 if (obj.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1497 return octave_value (new octave_classdef (obj)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1498 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1499 return octave_value (Matrix ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1500 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1501 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1502 inline octave_value |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1503 to_ov (const octave_value& ov) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1504 { return ov; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1505 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1506 inline cdef_object |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1507 to_cdef (const octave_value& val) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1508 { |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
1509 if (val.type_name () != "object") |
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
1510 error ("cannot convert `%s' into `object'", val.type_name().c_str ()); |
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
1511 |
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
1512 return dynamic_cast<octave_classdef *> (val.internal_rep ())->get_object (); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1513 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1514 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1515 inline cdef_object& |
18397
642fc1165f3f
Remove use of deprecate symbol_table::varref
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18396
diff
changeset
|
1516 to_cdef_ref (const octave_value& val) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1517 { |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
1518 if (val.type_name () != "object") |
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
1519 error ("cannot convert `%s' into `object'", val.type_name().c_str ()); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1520 |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20842
diff
changeset
|
1521 return dynamic_cast<octave_classdef *> (val.internal_rep ())->get_object_ref (); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1522 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1523 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1524 inline cdef_object |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1525 to_cdef (const cdef_object& obj) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1526 { return obj; } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1527 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1528 OCTINTERP_API void install_classdef (void); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1529 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1530 class |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1531 cdef_manager |
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 public: |
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 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
|
1536 bool error_if_not_found = true, |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1537 bool load_if_not_found = true) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1538 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1539 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1540 return instance->do_find_class (name, error_if_not_found, |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1541 load_if_not_found); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1542 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1543 return cdef_class (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1544 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1545 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1546 static octave_function* find_method_symbol (const std::string& method_name, |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1547 const std::string& class_name) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1548 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1549 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1550 return instance->do_find_method_symbol (method_name, class_name); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1551 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1552 return 0; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1553 } |
16048
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 static cdef_package find_package (const std::string& name, |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1556 bool error_if_not_found = true, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1557 bool load_if_not_found = true) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1558 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1559 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1560 return instance->do_find_package (name, error_if_not_found, |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1561 load_if_not_found); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1562 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1563 return cdef_package (); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1564 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1565 |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1566 static octave_function* find_package_symbol (const std::string& pack_name) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1567 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1568 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1569 return instance->do_find_package_symbol (pack_name); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1570 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1571 return 0; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1572 } |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1573 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1574 static void register_class (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1575 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1576 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1577 instance->do_register_class (cls); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1578 } |
16048
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 static void unregister_class (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1581 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1582 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1583 instance->do_unregister_class (cls); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1584 } |
16048
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 static void register_package (const cdef_package& pkg) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1587 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1588 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1589 instance->do_register_package (pkg); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1590 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1591 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1592 static void unregister_package (const cdef_package& pkg) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1593 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1594 if (instance_ok ()) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1595 instance->do_unregister_package (pkg); |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1596 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1597 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1598 private: |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1599 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1600 cdef_manager (void) { } |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1601 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1602 cdef_manager (const cdef_manager&); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1603 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1604 cdef_manager& operator = (const cdef_manager&); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1605 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1606 ~cdef_manager (void) { } |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1607 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1608 static void create_instance (void); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1609 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1610 static bool instance_ok (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1611 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1612 bool retval = true; |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1613 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1614 if (! instance) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1615 create_instance (); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1616 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1617 if (! instance) |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1618 { |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
1619 error ("unable to create cdef_manager!"); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1620 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1621 retval = false; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1622 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1623 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1624 return retval; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1625 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1626 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1627 static void cleanup_instance (void) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1628 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1629 delete instance; |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1630 |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1631 instance = 0; |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1632 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1633 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1634 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
|
1635 bool load_if_not_found); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1636 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1637 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
|
1638 const std::string& class_name); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1639 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1640 cdef_package do_find_package (const std::string& name, |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1641 bool error_if_not_found, |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1642 bool load_if_not_found); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1643 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16048
diff
changeset
|
1644 octave_function* do_find_package_symbol (const std::string& pack_name); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1645 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1646 void do_register_class (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1647 { all_classes[cls.get_name ()] = cls; } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1648 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1649 void do_unregister_class (const cdef_class& cls) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1650 { all_classes.erase(cls.get_name ()); } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1651 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1652 void do_register_package (const cdef_package& pkg) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1653 { all_packages[pkg.get_name ()] = pkg; } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1654 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1655 void do_unregister_package (const cdef_package& pkg) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
1656 { all_packages.erase(pkg.get_name ()); } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1657 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1658 private: |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1659 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1660 // The single cdef_manager instance |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1661 static cdef_manager *instance; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1662 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1663 // All registered/loaded classes |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1664 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
|
1665 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1666 // All registered/loaded packages |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1667 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
|
1668 }; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15986
diff
changeset
|
1669 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1670 #endif |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1671 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1672 /* |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1673 ;;; Local Variables: *** |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1674 ;;; mode: C++ *** |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1675 ;;; End: *** |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1676 */ |