Mercurial > octave-dspies
annotate libinterp/octave-value/ov-classdef.cc @ 15968:cdeb6eb656be classdef
Move property/method access check down to cdef_property/cdef_method classes.
* libinterp/octave-value/ov-classdef.h
(cdef_property::cdef_property_rep::get_value,
cdef_property::cdef_property_rep::set_value): Add arguments (do_check_access
and who) to control access checking and pass down to gripe utility function.
(cdef_property::get_value, cdef_property::set_value): Likewise.
(cdef_method::cdef_method_rep::execute): Likewise.
(cdef_method::execute): Likewise.
(cdef_property::check_get_access, cdef_property::check_set_access): Move
implementation to cdef_property::cdef_property_rep.
(cdef_property::cdef_property_rep::check_get_access,
cdef_property::cdef_property_rep::check_set_access): New methods, moved from
cdef_property.
(cdef_method::check_access): Move implementation to
cdef_method::cdef_method_rep.
(cdef_method::cdef_method_rep::check_access): New method, moved from
cdef_method.
(cdef_property::cdef_property_rep::wrap): New method.
(cdef_method::cdef_method_rep::wrap): New method.
* libinterp/octave-value/ov-classdef.cc
(cdef_property::cdef_property_rep::get_value,
cdef_property::cdef_property_rep::set_value): Add arguments (do_check_access
and who) to control access checking and pass down to gripe utility function.
(cdef_property::cdef_property_rep::check_get_access,
(cdef_method::cdef_method_rep::execute): Likewise.
cdef_property::cdef_property_rep::check_set_access): New methods, moved from
cdef_property.
(cdef_method::cdef_method_rep::check_access): New method, moved from
cdef_method.
(class_fevalStatic, octave_classdef_superclass_ref::do_multi_index_op,
cdef_object_scalar::subsref, cdef_class::cdef_class_rep::subsref_meta,
cdef_class::cdef_class_rep::construct_object): Do not check access, let
cdef_method::execute handle it.
(class_getConstant, cdef_object_scalar::subsref, cdef_object_scalar::subsasgn,
cdef_class::cdef_class_rep::subsref_meta): Do not check get/set access, let
cdef_property::get_value and cdef_property::set_value handle it.
(cdef_class::cdef_class_rep::delete_object): Execute "delete" method without
access checking.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sun, 20 Jan 2013 23:03:17 -0500 |
parents | 4aedc32e3f4d |
children | 14aa0b5a980c |
rev | line source |
---|---|
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1 /* |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3 Copyright (C) 2012 Michael Goffioul |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
4 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
5 This file is part of Octave. |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
6 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
10 option) any later version. |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
11 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
15 for more details. |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
16 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
20 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
21 */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
22 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
24 #include <config.h> |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
25 #endif |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
26 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
27 #include <algorithm> |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
28 #include <map> |
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 "defun.h" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
31 #include "ov-builtin.h" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
32 #include "ov-classdef.h" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
33 #include "ov-fcn-handle.h" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
34 #include "ov-typeinfo.h" |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
35 #include "pt-assign.h" |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
36 #include "pt-classdef.h" |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
37 #include "pt-funcall.h" |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
38 #include "pt-misc.h" |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
39 #include "pt-stmt.h" |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
40 #include "pt-walk.h" |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
41 #include "symtab.h" |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
42 #include "toplev.h" |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
43 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
44 #include "Array.cc" |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
45 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
46 static std::map<std::string, cdef_class> all_classes; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
47 static std::map<std::string, cdef_package> all_packages; |
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 static void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
50 gripe_method_access (const std::string& from, const cdef_method& meth) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
51 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
52 octave_value acc = meth.get ("Access"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
53 std::string acc_s; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
54 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
55 if (acc.is_string ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
56 acc_s = acc.string_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
57 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
58 acc_s = "class-restricted"; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
59 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
60 error ("%s: method `%s' has %s access and cannot be run in this context", |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
61 from.c_str (), meth.get_name ().c_str (), acc_s.c_str ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
62 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
63 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
64 static void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
65 gripe_property_access (const std::string& from, const cdef_property& prop, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
66 bool is_set = false) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
67 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
68 octave_value acc = prop.get (is_set ? "SetAccess" : "GetAccess"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
69 std::string acc_s; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
70 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
71 if (acc.is_string ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
72 acc_s = acc.string_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
73 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
74 acc_s = "class-restricted"; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
75 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
76 if (is_set) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
77 error ("%s: property `%s' has %s access and cannot be set in this context", |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
78 from.c_str (), prop.get_name ().c_str (), acc_s.c_str ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
79 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
80 error ("%s: property `%s' has %s access and cannot be obtained in this context", |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
81 from.c_str (), prop.get_name ().c_str (), acc_s.c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
82 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
83 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
84 static std::string |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
85 get_base_name (const std::string& nm) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
86 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
87 std::string::size_type pos = nm.find_last_of ('.'); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
88 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
89 if (pos != std::string::npos) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
90 return nm.substr (pos + 1); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
91 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
92 return nm; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
93 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
94 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
95 static void |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
96 make_function_of_class (const std::string& class_name, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
97 const octave_value& fcn) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
98 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
99 octave_function *of = fcn.function_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
100 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
101 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
102 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
103 of->stash_dispatch_class (class_name); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
104 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
105 octave_user_function *uf = of->user_function_value (true); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
106 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
107 if (! error_state && uf) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
108 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
109 if (get_base_name (class_name) == uf->name ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
110 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
111 uf->mark_as_class_constructor (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
112 uf->mark_as_classdef_constructor (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
113 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
114 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
115 uf->mark_as_class_method (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
116 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
117 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
118 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
119 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
120 static void |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
121 make_function_of_class (const cdef_class& cls, const octave_value& fcn) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
122 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
123 make_function_of_class (cls.get_name (), fcn); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
124 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
125 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
126 static octave_value |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
127 make_fcn_handle (octave_builtin::fcn ff, const std::string& nm) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
128 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
129 octave_value fcn (new octave_builtin (ff, nm)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
130 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
131 octave_value fcn_handle (new octave_fcn_handle (fcn, nm)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
132 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
133 return fcn_handle; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
134 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
135 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
136 inline octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
137 execute_ov (octave_value val, const octave_value_list& args, int nargout) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
138 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
139 std::list<octave_value_list> idx (1, args); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
140 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
141 std::string type ("("); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
142 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
143 return val.subsref (type, idx, nargout); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
144 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
145 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
146 static cdef_class |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
147 lookup_class (const std::string& name, bool error_if_not_found = true) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
148 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
149 std::map<std::string, cdef_class>::iterator it = all_classes.find (name); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
150 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
151 if (it == all_classes.end ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
152 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
153 // FIXME: implement this properly |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
154 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
155 octave_value ov_cls = symbol_table::find (name); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
156 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
157 if (ov_cls.is_defined ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
158 it = all_classes.find (name); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
159 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
160 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
161 if (it == all_classes.end ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
162 { |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
163 if (error_if_not_found) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
164 error ("class not found: %s", name.c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
165 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
166 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
167 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
168 cdef_class& cls = it->second; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
169 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
170 if (! cls.is_builtin ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
171 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
172 // FIXME: check whether a class reload is needed |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
173 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
174 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
175 if (cls.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
176 return cls; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
177 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
178 all_classes.erase (it); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
179 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
180 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
181 return cdef_class (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
182 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
183 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
184 static cdef_class |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
185 lookup_class (const cdef_class& cls) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
186 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
187 // FIXME: placeholder for the time being, the purpose |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
188 // is to centralized any class update activity here. |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
189 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
190 return cls; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
191 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
192 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
193 static cdef_class |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
194 lookup_class (const octave_value& ov) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
195 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
196 if (ov.is_string()) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
197 return lookup_class (ov.string_value ()); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
198 else |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
199 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
200 cdef_class cls (to_cdef (ov)); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
201 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
202 if (! error_state) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
203 return lookup_class (cls); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
204 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
205 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
206 return cdef_class (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
207 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
208 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
209 static std::list<cdef_class> |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
210 lookup_classes (const Cell& cls_list) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
211 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
212 std::list<cdef_class> retval; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
213 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
214 for (int i = 0; i < cls_list.numel (); i++) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
215 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
216 cdef_class c = lookup_class (cls_list(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
217 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
218 if (! error_state) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
219 retval.push_back (c); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
220 else |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
221 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
222 retval.clear (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
223 break; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
224 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
225 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
226 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
227 return retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
228 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
229 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
230 static octave_value |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
231 to_ov (const std::list<cdef_class>& class_list) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
232 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
233 Cell cls (class_list.size (), 1); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
234 int i = 0; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
235 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
236 for (std::list<cdef_class>::const_iterator it = class_list.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
237 it != class_list.end (); ++it, ++i) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
238 cls(i) = to_ov (*it); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
239 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
240 return octave_value (cls); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
241 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
242 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
243 static bool |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
244 is_superclass (const cdef_class& clsa, const cdef_class& clsb, |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
245 bool allow_equal = true, int max_depth = -1) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
246 { |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
247 bool retval = false; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
248 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
249 if (allow_equal && clsa == clsb) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
250 retval = true; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
251 else if (max_depth != 0) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
252 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
253 Cell c = clsb.get ("SuperClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
254 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
255 for (int i = 0; ! error_state && ! retval && i < c.numel (); i++) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
256 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
257 cdef_class cls = lookup_class (c(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
258 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
259 if (! error_state) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
260 retval = is_superclass (clsa, cls, true, |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
261 max_depth < 0 ? max_depth : max_depth-1); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
262 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
263 } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
264 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
265 return retval; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
266 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
267 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
268 inline bool |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
269 is_strict_superclass (const cdef_class& clsa, const cdef_class& clsb) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
270 { return is_superclass (clsa, clsb, false); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
271 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
272 inline bool |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
273 is_direct_superclass (const cdef_class& clsa, const cdef_class& clsb) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
274 { return is_superclass (clsa, clsb, false, 1); } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
275 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
276 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
277 class_get_properties (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
278 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
279 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
280 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
281 if (args.length () == 1 && args(0).type_name () == "object") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
282 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
283 cdef_class cls (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
284 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
285 retval(0) = cls.get_properties (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
286 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
287 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
288 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
289 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
290 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
291 static cdef_class |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
292 get_class_context (std::string& name, bool& in_constructor) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
293 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
294 cdef_class cls; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
295 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
296 octave_function* fcn = octave_call_stack::current (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
297 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
298 in_constructor = false; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
299 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
300 if (fcn && |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
301 (fcn->is_class_method () |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
302 || fcn->is_classdef_constructor () |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
303 || fcn->is_anonymous_function_of_class () |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
304 || (fcn->is_private_function () |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
305 && ! fcn->dispatch_class ().empty ()))) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
306 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
307 cls = lookup_class (fcn->dispatch_class ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
308 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
309 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
310 name = fcn->name (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
311 in_constructor = fcn->is_classdef_constructor (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
312 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
313 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
314 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
315 return cls; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
316 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
317 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
318 inline cdef_class |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
319 get_class_context (void) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
320 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
321 std::string dummy_string; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
322 bool dummy_bool; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
323 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
324 return get_class_context (dummy_string, dummy_bool); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
325 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
326 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
327 static bool |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
328 check_access (const cdef_class& cls, const octave_value& acc) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
329 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
330 if (acc.is_string ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
331 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
332 std::string acc_s = acc.string_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
333 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
334 if (acc_s == "public") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
335 return true; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
336 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
337 cdef_class ctx = get_class_context (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
338 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
339 // The access is private or protected, this requires a |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
340 // valid class context. |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
341 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
342 if (! error_state && ctx.ok ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
343 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
344 if (acc_s == "private") |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
345 return (ctx == cls); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
346 else if (acc_s == "protected") |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
347 return is_superclass (cls, ctx); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
348 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
349 panic_impossible (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
350 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
351 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
352 else if (acc.is_cell ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
353 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
354 Cell acc_c = acc.cell_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
355 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
356 cdef_class ctx = get_class_context (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
357 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
358 // At this point, a class context is always required. |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
359 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
360 if (! error_state && ctx.ok ()) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
361 { |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
362 if (ctx == cls) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
363 return true; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
364 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
365 for (int i = 0; ! error_state && i < acc.numel (); i++) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
366 { |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
367 cdef_class acc_cls (to_cdef (acc_c(i))); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
368 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
369 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
370 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
371 if (is_superclass (acc_cls, ctx)) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
372 return true; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
373 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
374 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
375 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
376 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
377 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
378 error ("invalid property/method access in class `%s'", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
379 cls.get_name ().c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
380 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
381 return false; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
382 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
383 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
384 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
385 class_get_methods (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
386 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
387 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
388 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
389 if (args.length () == 1 && args(0).type_name () == "object") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
390 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
391 cdef_class cls (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
392 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
393 retval(0) = cls.get_methods (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
394 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
395 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
396 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
397 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
398 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
399 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
400 class_get_superclasses (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
401 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
402 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
403 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
404 if (args.length () == 1 && args(0).type_name () == "object" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
405 && args(0).class_name () == "meta.class") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
406 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
407 cdef_class cls (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
408 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
409 Cell classes = cls.get ("SuperClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
410 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
411 retval(0) = to_ov (lookup_classes (classes)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
412 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
413 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
414 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
415 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
416 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
417 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
418 class_get_inferiorclasses (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
419 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
420 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
421 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
422 if (args.length () == 1 && args(0).type_name () == "object" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
423 && args(0).class_name () == "meta.class") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
424 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
425 cdef_class cls (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
426 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
427 Cell classes = cls.get ("InferiorClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
428 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
429 retval(0) = to_ov (lookup_classes (classes)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
430 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
431 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
432 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
433 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
434 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
435 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
436 class_fromName (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
437 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
438 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
439 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
440 if (args.length () == 1) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
441 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
442 std::string name = args(0).string_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
443 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
444 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
445 retval(0) = to_ov (lookup_class (name)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
446 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
447 error ("fromName: invalid class name, expected a string value"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
448 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
449 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
450 error ("fromName: invalid number of parameters"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
451 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
452 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
453 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
454 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
455 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
456 class_fevalStatic (const octave_value_list& args, int nargout) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
457 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
458 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
459 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
460 if (args.length () > 1 && args(0).type_name () == "object") |
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 cdef_class cls (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
463 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
464 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
465 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
466 std::string meth_name = args(1).string_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
467 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
468 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
469 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
470 cdef_method meth = cls.find_method (meth_name); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
471 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
472 if (meth.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
473 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
474 if (meth.is_static ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
475 retval = meth.execute (args.splice (0, 2), nargout, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
476 true, "fevalStatic"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
477 else |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
478 error ("fevalStatic: method `%s' is not static", |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
479 meth_name.c_str ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
480 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
481 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
482 error ("fevalStatic: method not found: %s", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
483 meth_name.c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
484 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
485 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
486 error ("fevalStatic: invalid method name, expected a string value"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
487 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
488 error ("fevalStatic: invalid object, expected a meta.class object"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
489 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
490 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
491 error ("fevalStatic: invalid arguments"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
492 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
493 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
494 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
495 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
496 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
497 class_getConstant (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
498 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
499 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
500 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
501 if (args.length () == 2 && args(0).type_name () == "object" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
502 && args(0).class_name () == "meta.class") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
503 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
504 cdef_class cls = to_cdef (args(0)); |
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 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
507 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
508 std::string prop_name = args(1).string_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
509 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
510 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
511 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
512 cdef_property prop = cls.find_property (prop_name); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
513 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
514 if (prop.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
515 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
516 if (prop.is_constant ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
517 retval(0) = prop.get_value (true, "getConstant"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
518 else |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
519 error ("getConstant: property `%s' is not constant", |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
520 prop_name.c_str ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
521 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
522 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
523 error ("getConstant: property not found: %s", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
524 prop_name.c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
525 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
526 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
527 error ("getConstant: invalid property name, expected a string value"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
528 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
529 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
530 error ("getConstant: invalid object, expected a meta.class object"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
531 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
532 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
533 error ("getConstant: invalid arguments"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
534 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
535 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
536 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
537 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
538 #define META_CLASS_CMP(OP, CLSA, CLSB, FUN) \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
539 static octave_value_list \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
540 class_ ## OP (const octave_value_list& args, int /* nargout */) \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
541 { \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
542 octave_value_list retval; \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
543 \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
544 if (args.length () == 2 \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
545 && args(0).type_name () == "object" && args(1).type_name () == "object" \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
546 && args(0).class_name () == "meta.class" && args(1).class_name () == "meta.class") \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
547 { \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
548 cdef_class clsa = to_cdef (args(0)); \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
549 \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
550 cdef_class clsb = to_cdef (args(1)); \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
551 \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
552 if (! error_state) \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
553 retval(0) = FUN (CLSA, CLSB); \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
554 else \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
555 error (#OP ": invalid objects, expected meta.class objects"); \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
556 } \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
557 else \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
558 error (#OP ": invalid arguments"); \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
559 \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
560 return retval; \ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
561 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
562 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
563 META_CLASS_CMP (lt, clsb, clsa, is_strict_superclass) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
564 META_CLASS_CMP (le, clsb, clsa, is_superclass) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
565 META_CLASS_CMP (gt, clsa, clsb, is_strict_superclass) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
566 META_CLASS_CMP (ge, clsa, clsb, is_superclass) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
567 META_CLASS_CMP (eq, clsa, clsb, operator==) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
568 META_CLASS_CMP (ne, clsa, clsb, operator!=) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
569 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
570 octave_value_list |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
571 property_get_defaultvalue (const octave_value_list& args, int /* nargout */) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
572 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
573 octave_value_list retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
574 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
575 if (args.length () == 1 && args(0).type_name () == "object") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
576 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
577 cdef_property prop (to_cdef (args(0))); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
578 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
579 retval(0) = prop.get ("DefaultValue"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
580 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
581 if (! retval(0).is_defined ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
582 error_with_id ("Octave:class:NotDefaultDefined", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
583 "no default value for property `%s'", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
584 prop.get_name ().c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
585 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
586 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
587 return retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
588 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
589 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
590 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
591 handle_delete (const octave_value_list& /* args */, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
592 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
593 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
594 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
595 // FIXME: implement this |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
596 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
597 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
598 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
599 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
600 static cdef_class |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
601 make_class (const std::string& name, |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
602 const std::list<cdef_class>& super_list = std::list<cdef_class> ()) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
603 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
604 cdef_class cls (name, super_list); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
605 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
606 cls.set_class (cdef_class::meta_class ()); |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
607 cls.put ("Abstract", false); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
608 cls.put ("ConstructOnLoad", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
609 cls.put ("ContainingPackage", Matrix ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
610 cls.put ("Description", std::string ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
611 cls.put ("DetailedDescription", std::string ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
612 cls.put ("Events", Cell ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
613 cls.put ("Hidden", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
614 cls.put ("InferiorClasses", Cell ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
615 cls.put ("Methods", Cell ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
616 cls.put ("Properties", Cell ()); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
617 cls.put ("Sealed", false); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
618 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
619 if (name == "handle") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
620 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
621 cls.put ("HandleCompatible", true); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
622 cls.mark_as_handle_class (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
623 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
624 else if (super_list.empty ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
625 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
626 cls.put ("HandleCompatible", false); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
627 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
628 else |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
629 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
630 bool all_handle_compatible = true; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
631 bool has_handle_class = false; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
632 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
633 for (std::list<cdef_class>::const_iterator it = super_list.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
634 it != super_list.end (); ++it) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
635 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
636 all_handle_compatible = all_handle_compatible && it->get ("HandleCompatible").bool_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
637 has_handle_class = has_handle_class || it->is_handle_class (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
638 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
639 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
640 if (has_handle_class && ! all_handle_compatible) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
641 ::error ("%s: cannot mix handle and non-HandleCompatible classes", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
642 name.c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
643 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
644 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
645 cls.put ("HandleCompatible", all_handle_compatible); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
646 if (has_handle_class) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
647 cls.mark_as_handle_class (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
648 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
649 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
650 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
651 if (error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
652 return cdef_class (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
653 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
654 if (! name.empty ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
655 all_classes[name] = cls; |
15036
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 return cls; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
658 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
659 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
660 static cdef_class |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
661 make_class (const std::string& name, const cdef_class& super) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
662 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
663 return make_class (name, std::list<cdef_class> (1, super)); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
664 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
665 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
666 static cdef_class |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
667 make_meta_class (const std::string& name, const cdef_class& super) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
668 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
669 cdef_class cls = make_class (name, super); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
670 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
671 cls.put ("Sealed", true); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
672 cls.mark_as_meta_class (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
673 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
674 return cls; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
675 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
676 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
677 static cdef_property |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
678 make_property (const cdef_class& cls, const std::string& name, |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
679 const octave_value& get_method = Matrix (), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
680 const std::string& get_access = "public", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
681 const octave_value& set_method = Matrix (), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
682 const std::string& set_access = "public") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
683 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
684 cdef_property prop (name); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
685 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
686 prop.set_class (cdef_class::meta_property ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
687 prop.put ("Description", std::string ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
688 prop.put ("DetailedDescription", std::string ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
689 prop.put ("Abstract", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
690 prop.put ("Constant", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
691 prop.put ("GetAccess", get_access); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
692 prop.put ("SetAccess", set_access); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
693 prop.put ("Dependent", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
694 prop.put ("Transient", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
695 prop.put ("Hidden", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
696 prop.put ("GetObservable", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
697 prop.put ("SetObservable", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
698 prop.put ("GetMethod", get_method); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
699 prop.put ("SetMethod", set_method); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
700 prop.put ("DefiningClass", to_ov (cls)); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
701 prop.put ("DefaultValue", octave_value ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
702 prop.put ("HasDefault", false); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
703 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
704 std::string class_name = cls.get_name (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
705 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
706 if (! get_method.is_empty ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
707 make_function_of_class (class_name, get_method); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
708 if (! set_method.is_empty ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
709 make_function_of_class (class_name, set_method); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
710 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
711 return prop; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
712 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
713 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
714 inline cdef_property |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
715 make_attribute (const cdef_class& cls, const std::string& name) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
716 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
717 return make_property (cls, name, Matrix (), "public", Matrix (), "private"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
718 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
719 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
720 static cdef_method |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
721 make_method (const cdef_class& cls, const std::string& name, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
722 const octave_value& fcn,const std::string& m_access = "public", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
723 bool is_static = false) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
724 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
725 cdef_method meth (name); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
726 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
727 meth.set_class (cdef_class::meta_method ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
728 meth.put ("Abstract", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
729 meth.put ("Access", m_access); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
730 meth.put ("DefiningClass", to_ov (cls)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
731 meth.put ("Description", std::string ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
732 meth.put ("DetailedDescription", std::string ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
733 meth.put ("Hidden", false); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
734 meth.put ("Sealed", true); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
735 meth.put ("Static", is_static); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
736 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
737 if (fcn.is_defined ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
738 make_function_of_class (cls, fcn); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
739 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
740 meth.set_function (fcn); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
741 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
742 return meth; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
743 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
744 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
745 inline cdef_method |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
746 make_method (const cdef_class& cls, const std::string& name, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
747 octave_builtin::fcn ff, const std::string& m_access = "public", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
748 bool is_static = false) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
749 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
750 octave_value fcn (new octave_builtin (ff, name)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
751 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
752 return make_method (cls, name, fcn, m_access, is_static); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
753 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
754 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
755 static cdef_package |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
756 make_package (const std::string& nm, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
757 const std::string& parent = std::string ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
758 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
759 cdef_package pack ("meta.package"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
760 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
761 pack.set_class (cdef_class::meta_package ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
762 pack.put ("Name", nm); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
763 pack.put ("ContainingPackage", to_ov (all_packages[parent])); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
764 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
765 if (! nm.empty ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
766 all_packages[nm] = pack; |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
767 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
768 return pack; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
769 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
770 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
771 //---------------------------------------------------------------------------- |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
772 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
773 DEFINE_OCTAVE_ALLOCATOR (octave_classdef); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
774 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
775 int octave_classdef::t_id (-1); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
776 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
777 const std::string octave_classdef::t_name ("object"); |
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 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
780 octave_classdef::register_type (void) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
781 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
782 t_id = octave_value_typeinfo::register_type |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
783 (octave_classdef::t_name, "<unknown>", octave_value (new octave_classdef ())); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
784 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
785 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
786 octave_value_list |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
787 octave_classdef::subsref (const std::string& type, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
788 const std::list<octave_value_list>& idx, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
789 int nargout) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
790 { |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
791 size_t skip = 0; |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
792 octave_value_list retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
793 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
794 // FIXME: should check "subsref" method first |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
795 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
796 retval = object.subsref (type, idx, nargout, skip, cdef_class ()); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
797 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
798 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
799 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
800 if (type.length () > skip && idx.size () > skip) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
801 retval = retval(0).next_subsref (nargout, type, idx, skip); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
802 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
803 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
804 return retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
805 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
806 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
807 octave_value |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
808 octave_classdef::subsasgn (const std::string& type, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
809 const std::list<octave_value_list>& idx, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
810 const octave_value& rhs) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
811 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
812 return object.subsasgn (type, idx, rhs); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
813 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
814 |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
815 octave_value |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
816 octave_classdef::undef_subsasgn (const std::string& type, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
817 const std::list<octave_value_list>& idx, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
818 const octave_value& rhs) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
819 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
820 if (type.length () == 1 && type[0] == '(') |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
821 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
822 object = object.make_array (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
823 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
824 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
825 return subsasgn (type, idx, rhs); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
826 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
827 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
828 return octave_base_value::undef_subsasgn (type, idx, rhs); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
829 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
830 return octave_value (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
831 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
832 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
833 //---------------------------------------------------------------------------- |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
834 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
835 class octave_classdef_proxy : public octave_function |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
836 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
837 public: |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
838 octave_classdef_proxy (const cdef_class& _klass) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
839 : klass (_klass) { } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
840 |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
841 ~octave_classdef_proxy (void) |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
842 { |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
843 // This means the class has been cleared from the symbol table. |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
844 all_classes.erase (klass.get_name ()); |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
845 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
846 |
15955
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
847 octave_function* function_value (bool = false) { return this; } |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
848 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
849 octave_value_list |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
850 subsref (const std::string& type, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
851 const std::list<octave_value_list>& idx, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
852 int nargout) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
853 { return klass.subsref_meta (type, idx, nargout); } |
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 octave_value |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
856 subsref (const std::string& type, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
857 const std::list<octave_value_list>& idx) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
858 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
859 octave_value_list retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
860 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
861 retval = subsref (type, idx, 1); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
862 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
863 return (retval.length () > 0 ? retval(0) : octave_value ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
864 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
865 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
866 octave_value_list |
15955
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
867 do_multi_index_op (int nargout, const octave_value_list& idx) |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
868 { |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
869 // Emulate constructor |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
870 |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
871 std::list<octave_value_list> l (1, idx); |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
872 std::string type ("("); |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
873 |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
874 return subsref (type, l, nargout); |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
875 } |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
876 |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
877 bool is_postfix_index_handled (char type) const |
837a4a9b5049
Support constructor call with no indexing syntax.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15913
diff
changeset
|
878 { return (type == '(' || type == '.'); } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
879 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
880 private: |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
881 cdef_class klass; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
882 }; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
883 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
884 //---------------------------------------------------------------------------- |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
885 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
886 class octave_classdef_superclass_ref : public octave_function |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
887 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
888 public: |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
889 octave_classdef_superclass_ref (const octave_value_list& a) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
890 : octave_function (), args (a) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
891 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
892 ~octave_classdef_superclass_ref (void) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
893 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
894 octave_value_list |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
895 subsref (const std::string& type, |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
896 const std::list<octave_value_list>& idx, |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
897 int nargout) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
898 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
899 size_t skip = 0; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
900 octave_value_list retval; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
901 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
902 switch (type[0]) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
903 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
904 case '(': |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
905 skip = 1; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
906 retval = do_multi_index_op (type.length () > 1 ? 1 : nargout, |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
907 idx.front ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
908 break; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
909 default: |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
910 retval = do_multi_index_op (1, octave_value_list ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
911 break; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
912 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
913 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
914 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
915 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
916 if (type.length () > skip && idx.size () > skip |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
917 && retval.length () > 0) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
918 retval = retval(0).next_subsref (nargout, type, idx, skip); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
919 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
920 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
921 return retval; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
922 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
923 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
924 octave_value |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
925 subsref (const std::string& type, |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
926 const std::list<octave_value_list>& idx) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
927 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
928 octave_value_list retval; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
929 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
930 retval = subsref (type, idx, 1); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
931 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
932 return (retval.length () > 0 ? retval(0) : octave_value ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
933 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
934 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
935 octave_value_list |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
936 do_multi_index_op (int nargout, const octave_value_list& idx) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
937 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
938 octave_value_list retval; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
939 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
940 std::string meth_name; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
941 bool in_constructor; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
942 cdef_class ctx; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
943 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
944 ctx = get_class_context (meth_name, in_constructor); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
945 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
946 if (! error_state && ctx.ok ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
947 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
948 std::string mname = args(0).string_value (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
949 std::string pname = args(1).string_value (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
950 std::string cname = args(2).string_value (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
951 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
952 std::string cls_name = (pname.empty () ? |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
953 cname : pname + "." + cname); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
954 cdef_class cls = lookup_class (cls_name); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
955 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
956 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
957 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
958 if (in_constructor) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
959 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
960 if (is_direct_superclass (cls, ctx)) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
961 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
962 if (is_constructed_object (mname)) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
963 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
964 octave_value& sym = symbol_table::varref (mname); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
965 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
966 cls.run_constructor (to_cdef_ref (sym), idx); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
967 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
968 retval(0) = sym; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
969 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
970 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
971 ::error ("cannot call superclass constructor with " |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
972 "variable `%s'", mname.c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
973 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
974 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
975 ::error ("`%s' is not a direct superclass of `%s'", |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
976 cls_name.c_str (), ctx.get_name ().c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
977 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
978 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
979 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
980 if (mname == meth_name) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
981 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
982 if (is_strict_superclass (cls, ctx)) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
983 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
984 // I see 2 possible implementations here: |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
985 // 1) use cdef_object::subsref with a different class |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
986 // context; this avoids duplicating codem but |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
987 // assumes the object is always the first argument |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
988 // 2) lookup the method manually and call |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
989 // cdef_method::execute; this duplicates part of |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
990 // logic in cdef_object::subsref, but avoid the |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
991 // assumption of 1) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
992 // Not being sure about the assumption of 1), I |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
993 // go with option 2) for the time being. |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
994 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
995 cdef_method meth = cls.find_method (meth_name, false); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
996 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
997 if (meth.ok ()) |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
998 retval = meth.execute (idx, nargout, true, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
999 meth_name); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1000 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1001 ::error ("no method `%s' found in superclass `%s'", |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1002 meth_name.c_str (), cls_name.c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1003 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1004 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1005 ::error ("`%s' is not a superclass of `%s'", |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1006 cls_name.c_str (), ctx.get_name ().c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1007 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1008 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1009 ::error ("method name mismatch (`%s' != `%s')", |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1010 mname.c_str (), meth_name.c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1011 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1012 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1013 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1014 else if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1015 ::error ("superclass calls can only occur in methods or constructors"); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1016 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1017 return retval; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1018 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1019 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1020 private: |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1021 bool is_constructed_object (const std::string nm) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1022 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1023 octave_function *of = octave_call_stack::current (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1024 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1025 if (of->is_classdef_constructor ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1026 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1027 octave_user_function *uf = of->user_function_value (true); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1028 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1029 if (uf) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1030 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1031 tree_parameter_list *ret_list = uf->return_list (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1032 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1033 if (ret_list && ret_list->length () == 1) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1034 return (ret_list->front ()->name () == nm); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1035 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1036 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1037 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1038 return false; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1039 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1040 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1041 private: |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1042 octave_value_list args; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1043 }; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1044 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1045 //---------------------------------------------------------------------------- |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1046 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1047 string_vector |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1048 cdef_object_rep::map_keys (void) const |
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 cdef_class cls = get_class (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1051 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1052 if (cls.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1053 return cls.get_names (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1054 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1055 return string_vector (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1056 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1057 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1058 octave_value_list |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1059 cdef_object_scalar::subsref (const std::string& type, |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1060 const std::list<octave_value_list>& idx, |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1061 int nargout, size_t& skip, |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1062 const cdef_class& context) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1063 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1064 skip = 0; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1065 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1066 cdef_class cls = (context.ok () ? context : get_class ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1067 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1068 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1069 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1070 if (! cls.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1071 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1072 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1073 switch (type[0]) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1074 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1075 case '.': |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1076 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1077 std::string name = (idx.front ())(0).string_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1078 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1079 cdef_method meth = cls.find_method (name); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1080 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1081 if (meth.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1082 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1083 int _nargout = (type.length () > 2 ? 1 : nargout); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1084 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1085 octave_value_list args; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1086 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1087 skip = 1; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1088 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1089 if (type.length () > 1 && type[1] == '(') |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1090 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1091 std::list<octave_value_list>::const_iterator it = idx.begin (); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1092 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1093 args = *++it; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1094 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1095 skip++; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1096 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1097 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1098 if (meth.is_static ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1099 retval = meth.execute (args, _nargout, true, "subsref"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1100 else |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1101 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1102 refcount++; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1103 retval = meth.execute (cdef_object (this), args, _nargout, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1104 true, "subsref"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1105 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1106 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1107 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1108 if (skip == 0 && ! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1109 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1110 cdef_property prop = cls.find_property (name); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1111 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1112 if (prop.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1113 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1114 if (prop.is_constant ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1115 retval(0) = prop.get_value (true, "subsref"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1116 else |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1117 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1118 refcount++; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1119 retval(0) = prop.get_value (cdef_object (this), |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1120 true, "subsref"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1121 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1122 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1123 skip = 1; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1124 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1125 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1126 error ("subsref: unknown method or property: %s", name.c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1127 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1128 break; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1129 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1130 default: |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1131 error ("object cannot be indexed with `%c'", type[0]); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1132 break; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1133 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1134 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1135 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1136 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1137 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1138 octave_value |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1139 cdef_object_scalar::subsasgn (const std::string& type, |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1140 const std::list<octave_value_list>& idx, |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1141 const octave_value& rhs) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1142 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1143 octave_value retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1144 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1145 cdef_class cls = get_class (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1146 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1147 switch (type[0]) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1148 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1149 case '.': |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1150 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1151 std::string name = (idx.front ())(0).string_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1152 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1153 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1154 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1155 cdef_property prop = cls.find_property (name); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1156 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1157 if (prop.ok ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1158 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1159 if (type.length () == 1) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1160 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1161 refcount++; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1162 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1163 cdef_object obj (this); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1164 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1165 prop.set_value (obj, rhs, true, "subsasgn"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1166 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1167 if (! error_state) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1168 retval = to_ov (obj); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1169 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1170 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1171 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1172 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1173 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1174 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1175 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1176 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1177 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1178 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1179 error ("subsasgn: unknown property: %s", name.c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1180 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1181 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1182 break; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1183 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1184 default: |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1185 panic_impossible (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1186 break; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1187 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1188 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1189 return retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1190 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1191 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1192 void |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1193 cdef_object_scalar::mark_for_construction (const cdef_class& cls) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1194 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1195 std::string cls_name = cls.get_name (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1196 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1197 Cell supcls = cls.get ("SuperClasses").cell_value (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1198 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1199 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1200 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1201 std::list<cdef_class> supcls_list = lookup_classes (supcls); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1202 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1203 if (! error_state) |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1204 ctor_list[cls] = supcls_list; |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1205 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1206 } |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1207 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1208 octave_value_list |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1209 cdef_object_array::subsref (const std::string& type, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1210 const std::list<octave_value_list>& idx, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1211 int /* nargout */, size_t& skip, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1212 const cdef_class& /* context */) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1213 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1214 octave_value_list retval; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1215 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1216 skip = 1; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1217 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1218 switch (type[0]) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1219 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1220 case '(': |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1221 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1222 const octave_value_list& ival = idx.front (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1223 bool is_scalar = true; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1224 Array<idx_vector> iv (dim_vector (1, ival.length ())); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1225 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1226 for (int i = 0; ! error_state && i < ival.length (); i++) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1227 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1228 iv(i) = ival(i).index_vector (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1229 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1230 is_scalar = is_scalar && iv(i).is_scalar (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1231 } |
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 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1234 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1235 Array<cdef_object> ires = array.index (iv); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1236 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1237 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1238 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1239 if (is_scalar) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1240 retval(0) = to_ov (ires(0)); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1241 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1242 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1243 cdef_object array_obj (new cdef_object_array (ires)); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1244 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1245 array_obj.set_class (get_class ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1246 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1247 retval(0) = to_ov (array_obj); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1248 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1249 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1250 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1251 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1252 break; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1253 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1254 default: |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1255 ::error ("can't perform indexing operation on array of %s objects", |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1256 class_name ().c_str ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1257 break; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1258 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1259 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1260 return retval; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1261 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1262 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1263 octave_value |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1264 cdef_object_array::subsasgn (const std::string& type, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1265 const std::list<octave_value_list>& idx, |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1266 const octave_value& rhs) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1267 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1268 octave_value retval; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1269 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1270 switch (type[0]) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1271 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1272 case '(': |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1273 if (type.length () == 1) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1274 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1275 cdef_object rhs_obj = to_cdef (rhs); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1276 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1277 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1278 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1279 if (rhs_obj.get_class () == get_class ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1280 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1281 const octave_value_list& ival = idx.front (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1282 bool is_scalar = true; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1283 Array<idx_vector> iv (dim_vector (1, ival.length ())); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1284 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1285 for (int i = 0; ! error_state && i < ival.length (); i++) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1286 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1287 iv(i) = ival(i).index_vector (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1288 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1289 is_scalar = is_scalar && iv(i).is_scalar (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1290 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1291 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1292 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1293 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1294 Array<cdef_object> rhs_mat; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1295 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1296 if (! rhs_obj.is_array ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1297 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1298 rhs_mat = Array<cdef_object> (dim_vector (1, 1)); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1299 rhs_mat(0) = rhs_obj; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1300 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1301 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1302 rhs_mat = rhs_obj.array_value (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1303 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1304 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1305 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1306 octave_idx_type n = array.numel (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1307 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1308 array.assign (iv, rhs_mat, cdef_object ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1309 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1310 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1311 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1312 if (array.numel () > n) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1313 fill_empty_values (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1314 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1315 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1316 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1317 refcount++; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1318 retval = to_ov (cdef_object (this)); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1319 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1320 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1321 } |
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 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1324 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1325 ::error ("can't assign %s object into array of %s objects.", |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1326 rhs_obj.class_name ().c_str (), |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1327 class_name ().c_str ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1328 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1329 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1330 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1331 ::error ("can't perform indexing operation on array of %s objects", |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1332 class_name ().c_str ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1333 break; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1334 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1335 default: |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1336 ::error ("can't perform indexing operation on array of %s objects", |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1337 class_name ().c_str ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1338 break; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1339 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1340 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1341 return retval; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1342 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1343 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1344 void |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1345 cdef_object_array::fill_empty_values (void) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1346 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1347 cdef_class cls = get_class (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1348 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1349 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1350 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1351 cdef_object obj; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1352 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1353 int n = array.numel (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1354 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1355 for (int i = 0; ! error_state && i < n; i++) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1356 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1357 if (! array.xelem (i).ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1358 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1359 if (! obj.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1360 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1361 obj = cls.construct_object (octave_value_list ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1362 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1363 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1364 array.xelem (i) = obj; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1365 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1366 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1367 array.xelem (i) = obj.copy (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1368 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1369 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1370 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1371 } |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1372 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1373 bool cdef_object_scalar::is_constructed_for (const cdef_class& cls) const |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1374 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1375 return (is_constructed () |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1376 || ctor_list.find (cls) == ctor_list.end ()); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1377 } |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1378 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1379 bool cdef_object_scalar::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:
15897
diff
changeset
|
1380 { |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1381 std::map< cdef_class, std::list<cdef_class> >::const_iterator it; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1382 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1383 if (is_constructed ()) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1384 return true; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1385 else if ((it = ctor_list.find (cls)) == ctor_list.end () |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1386 || it->second.empty ()) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1387 return true; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1388 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1389 for (std::list<cdef_class>::const_iterator lit = it->second.begin (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1390 lit != it->second.end (); ++lit) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1391 if (! is_constructed_for (*lit)) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1392 return false; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1393 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1394 return true; |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1395 } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1396 |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1397 handle_cdef_object::~handle_cdef_object (void) |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1398 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1399 gnulib::printf ("deleting %s object (handle)\n", |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1400 get_class ().get_name ().c_str ()); |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1401 } |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1402 |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1403 value_cdef_object::~value_cdef_object (void) |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1404 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1405 gnulib::printf ("deleting %s object (value)\n", |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1406 get_class ().get_name ().c_str ()); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1407 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1408 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1409 cdef_class::cdef_class_rep::cdef_class_rep (const std::list<cdef_class>& superclasses) |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1410 : handle_cdef_object (), member_count (0), handle_class (false), |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1411 object_count (0), meta (false) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1412 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1413 put ("SuperClasses", to_ov (superclasses)); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1414 implicit_ctor_list = superclasses; |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1415 } |
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
1416 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1417 cdef_method |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1418 cdef_class::cdef_class_rep::find_method (const std::string& nm, bool local) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1419 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1420 method_iterator it = method_map.find (nm); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1421 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1422 if (it == method_map.end ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1423 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1424 // FIXME: look into class directory |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1425 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1426 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1427 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1428 cdef_method& meth = it->second; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1429 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1430 // FIXME: check if method reload needed |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1431 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1432 if (meth.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1433 return meth; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1434 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1435 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1436 if (! local) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1437 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1438 // Look into superclasses |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1439 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1440 Cell super_classes = get ("SuperClasses").cell_value (); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1441 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1442 for (int i = 0; i < super_classes.numel (); i++) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1443 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1444 cdef_class cls = lookup_class (super_classes(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1445 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1446 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1447 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1448 cdef_method meth = cls.find_method (nm); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1449 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1450 if (meth.ok ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1451 return meth; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1452 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1453 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1454 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1455 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1456 return cdef_method (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1457 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1458 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1459 class ctor_analyzer : public tree_walker |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1460 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1461 public: |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1462 ctor_analyzer (const std::string& ctor, const std::string& obj) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1463 : tree_walker (), who (ctor), obj_name (obj) { } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1464 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1465 void visit_statement_list (tree_statement_list& t) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1466 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1467 for (tree_statement_list::const_iterator it = t.begin (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1468 ! error_state && it != t.end (); ++it) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1469 (*it)->accept (*this); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1470 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1471 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1472 void visit_statement (tree_statement& t) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1473 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1474 if (t.is_expression ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1475 t.expression ()->accept (*this); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1476 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1477 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1478 void visit_simple_assignment (tree_simple_assignment& t) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1479 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1480 t.right_hand_side ()->accept (*this); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1481 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1482 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1483 void visit_multi_assignment (tree_multi_assignment& t) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1484 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1485 t.right_hand_side ()->accept (*this); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1486 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1487 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1488 void visit_index_expression (tree_index_expression& t) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1489 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1490 t.expression ()->accept (*this); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1491 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1492 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1493 void visit_funcall (tree_funcall& t) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1494 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1495 octave_value fcn = t.function (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1496 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1497 if (fcn.is_function ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1498 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1499 octave_function *of = fcn.function_value (true); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1500 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1501 if (of) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1502 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1503 if (of->name () == "__superclass_reference__") |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1504 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1505 octave_value_list args = t.arguments (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1506 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1507 if (args(0).string_value () == obj_name) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1508 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1509 std::string package_name = args(1).string_value (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1510 std::string class_name = args(2).string_value (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1511 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1512 std::string ctor_name = (package_name.empty () |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1513 ? class_name |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1514 : package_name + "." + class_name); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1515 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1516 cdef_class cls = lookup_class (ctor_name, false); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1517 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1518 if (cls.ok ()) |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1519 ctor_list.push_back (cls); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1520 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1521 } |
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 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1524 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1525 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1526 std::list<cdef_class> get_constructor_list (void) const |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1527 { return ctor_list; } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1528 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1529 // NO-OP |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1530 void visit_anon_fcn_handle (tree_anon_fcn_handle&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1531 void visit_argument_list (tree_argument_list&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1532 void visit_binary_expression (tree_binary_expression&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1533 void visit_break_command (tree_break_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1534 void visit_colon_expression (tree_colon_expression&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1535 void visit_continue_command (tree_continue_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1536 void visit_global_command (tree_global_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1537 void visit_persistent_command (tree_persistent_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1538 void visit_decl_elt (tree_decl_elt&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1539 void visit_decl_init_list (tree_decl_init_list&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1540 void visit_simple_for_command (tree_simple_for_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1541 void visit_complex_for_command (tree_complex_for_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1542 void visit_octave_user_script (octave_user_script&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1543 void visit_octave_user_function (octave_user_function&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1544 void visit_function_def (tree_function_def&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1545 void visit_identifier (tree_identifier&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1546 void visit_if_clause (tree_if_clause&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1547 void visit_if_command (tree_if_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1548 void visit_if_command_list (tree_if_command_list&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1549 void visit_switch_case (tree_switch_case&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1550 void visit_switch_case_list (tree_switch_case_list&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1551 void visit_switch_command (tree_switch_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1552 void visit_matrix (tree_matrix&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1553 void visit_cell (tree_cell&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1554 void visit_no_op_command (tree_no_op_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1555 void visit_constant (tree_constant&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1556 void visit_fcn_handle (tree_fcn_handle&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1557 void visit_parameter_list (tree_parameter_list&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1558 void visit_postfix_expression (tree_postfix_expression&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1559 void visit_prefix_expression (tree_prefix_expression&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1560 void visit_return_command (tree_return_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1561 void visit_return_list (tree_return_list&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1562 void visit_try_catch_command (tree_try_catch_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1563 void visit_unwind_protect_command (tree_unwind_protect_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1564 void visit_while_command (tree_while_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1565 void visit_do_until_command (tree_do_until_command&) { } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1566 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1567 private: |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1568 /* The name of the constructor being analyzed */ |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1569 std::string who; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1570 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1571 /* The name of the first output argument of the constructor */ |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1572 std::string obj_name; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1573 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1574 /* The list of superclass constructors that are explicitly called */ |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1575 std::list<cdef_class> ctor_list; |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1576 }; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1577 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1578 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1579 cdef_class::cdef_class_rep::install_method (const cdef_method& meth) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1580 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1581 method_map[meth.get_name ()] = meth; |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1582 |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1583 member_count++; |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1584 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1585 if (meth.is_constructor ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1586 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1587 // Analyze the constructor code to determine what superclass |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1588 // constructors are called explicitly. |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1589 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1590 octave_function *of = meth.get_function ().function_value (true); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1591 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1592 if (of) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1593 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1594 octave_user_function *uf = of->user_function_value (true); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1595 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1596 if (uf) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1597 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1598 tree_parameter_list *ret_list = uf->return_list (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1599 tree_statement_list *body = uf->body (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1600 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1601 if (ret_list && ret_list->size () == 1) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1602 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1603 std::string obj_name = ret_list->front ()->name (); |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1604 ctor_analyzer a (meth.get_name (), obj_name); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1605 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1606 body->accept (a); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1607 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1608 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1609 std::list<cdef_class> explicit_ctor_list |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1610 = a.get_constructor_list (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1611 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1612 for (std::list<cdef_class>::const_iterator it = explicit_ctor_list.begin (); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1613 ! error_state && it != explicit_ctor_list.end (); ++it) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1614 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1615 gnulib::printf ("explicit superclass constructor: %s\n", |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1616 it->get_name ().c_str ()); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1617 implicit_ctor_list.remove (*it); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1618 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1619 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1620 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1621 else |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1622 ::error ("%s: invalid constructor output arguments", |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1623 meth.get_name ().c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1624 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1625 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1626 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1627 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1628 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1629 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1630 cdef_class::cdef_class_rep::load_all_methods (void) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1631 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1632 // FIXME: re-scan class directory |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1633 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1634 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1635 Cell |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1636 cdef_class::cdef_class_rep::get_methods (void) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1637 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1638 std::map<std::string,cdef_method> meths; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1639 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1640 find_methods (meths, false); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1641 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1642 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1643 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1644 Cell c (meths.size (), 1); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1645 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1646 int idx = 0; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1647 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1648 for (std::map<std::string,cdef_method>::const_iterator it = meths.begin (); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1649 it != meths.end (); ++it, ++idx) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1650 c (idx, 0) = to_ov (it->second); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1651 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1652 return c; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1653 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1654 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1655 return Cell (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1656 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1657 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1658 void |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1659 cdef_class::cdef_class_rep::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
|
1660 bool only_inherited) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1661 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1662 load_all_methods (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1663 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1664 method_const_iterator it; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1665 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1666 for (it = method_map.begin (); it != method_map.end (); ++it) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1667 { |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1668 if (! it->second.is_constructor ()) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1669 { |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1670 std::string nm = it->second.get_name (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1671 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1672 if (meths.find (nm) == meths.end ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1673 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1674 if (only_inherited) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1675 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1676 octave_value acc = it->second.get ("Access"); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1677 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1678 if (! acc.is_string () |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1679 || acc.string_value () == "private") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1680 continue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1681 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1682 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1683 meths[nm] = it->second; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1684 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1685 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1686 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1687 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1688 // Look into superclasses |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1689 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1690 Cell super_classes = get ("SuperClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1691 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1692 for (int i = 0; i < super_classes.numel (); i++) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1693 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1694 cdef_class cls = lookup_class (super_classes(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1695 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1696 if (! error_state) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1697 cls.get_rep ()->find_methods (meths, true); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1698 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1699 break; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1700 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1701 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1702 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1703 cdef_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1704 cdef_class::cdef_class_rep::find_property (const std::string& nm) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1705 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1706 property_iterator it = property_map.find (nm); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1707 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1708 if (it != property_map.end ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1709 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1710 cdef_property& prop = it->second; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1711 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1712 if (prop.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1713 return prop; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1714 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1715 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1716 // Look into superclasses |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1717 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1718 Cell super_classes = get ("SuperClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1719 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1720 for (int i = 0; i < super_classes.numel (); i++) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1721 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1722 cdef_class cls = lookup_class (super_classes(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1723 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1724 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1725 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1726 cdef_property prop = cls.find_property (nm); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1727 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1728 if (prop.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1729 return prop; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1730 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1731 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1732 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1733 return cdef_property (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1734 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1735 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1736 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1737 cdef_class::cdef_class_rep::install_property (const cdef_property& prop) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1738 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1739 property_map[prop.get_name ()] = prop; |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1740 |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
1741 member_count++; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1742 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1743 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1744 Cell |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1745 cdef_class::cdef_class_rep::get_properties (void) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1746 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1747 std::map<std::string,cdef_property> props; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1748 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1749 find_properties (props, false); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1750 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1751 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1752 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1753 Cell c (props.size (), 1); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1754 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1755 int idx = 0; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1756 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1757 for (std::map<std::string,cdef_property>::const_iterator it = props.begin (); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1758 it != props.end (); ++it, ++idx) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1759 c (idx, 0) = to_ov (it->second); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1760 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1761 return c; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1762 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1763 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1764 return Cell (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1765 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1766 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1767 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1768 cdef_class::cdef_class_rep::find_properties (std::map<std::string,cdef_property>& props, |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1769 bool only_inherited) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1770 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1771 property_const_iterator it; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1772 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1773 for (it = property_map.begin (); ! error_state && it != property_map.end (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1774 ++it) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1775 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1776 std::string nm = it->second.get_name (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1777 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1778 if (props.find (nm) == props.end ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1779 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1780 if (only_inherited) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1781 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1782 octave_value acc = it->second.get ("GetAccess"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1783 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1784 if (! acc.is_string () |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1785 || acc.string_value () == "private") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1786 continue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1787 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1788 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1789 props[nm] = it->second; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1790 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1791 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1792 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1793 // Look into superclasses |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1794 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1795 Cell super_classes = get ("SuperClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1796 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1797 for (int i = 0; ! error_state && i < super_classes.numel (); i++) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1798 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1799 cdef_class cls = lookup_class (super_classes(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1800 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1801 if (! error_state) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1802 cls.get_rep ()->find_properties (props, true); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1803 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1804 break; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1805 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1806 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1807 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1808 void |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1809 cdef_class::cdef_class_rep::find_names (std::set<std::string>& names, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1810 bool all) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1811 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1812 load_all_methods (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1813 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1814 for (method_const_iterator it = method_map.begin (); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1815 ! error_state && it != method_map.end(); ++it) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1816 { |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1817 if (! it->second.is_constructor ()) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1818 { |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1819 std::string nm = it->second.get_name (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
1820 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1821 if (! all) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1822 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1823 octave_value acc = it->second.get ("Access"); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1824 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1825 if (! acc.is_string() |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1826 || acc.string_value () != "public") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1827 continue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1828 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1829 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1830 names.insert (nm); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1831 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1832 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1833 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1834 for (property_const_iterator it = property_map.begin (); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1835 ! error_state && it != property_map.end (); ++it) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1836 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1837 std::string nm = it->second.get_name (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1838 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1839 if (! all) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1840 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1841 octave_value acc = it->second.get ("GetAccess"); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1842 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1843 if (! acc.is_string() |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1844 || acc.string_value () != "public") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1845 continue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1846 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1847 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1848 names.insert (nm); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1849 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1850 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1851 // Look into superclasses |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1852 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1853 Cell super_classes = get ("SuperClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1854 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1855 for (int i = 0; ! error_state && i < super_classes.numel (); i++) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1856 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1857 cdef_class cls = lookup_class (super_classes(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1858 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1859 if (! error_state) |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1860 cls.get_rep ()->find_names (names, all); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1861 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1862 break; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1863 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1864 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1865 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1866 string_vector |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1867 cdef_class::cdef_class_rep::get_names (void) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1868 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1869 std::set<std::string> names; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1870 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1871 find_names (names, false); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1872 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1873 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1874 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1875 string_vector v (names.size ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1876 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1877 int idx = 0; |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1878 for (std::set<std::string>::const_iterator it = names.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1879 it != names.end (); ++it, ++idx) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1880 v[idx] = *it; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1881 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1882 return v.sort (true); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1883 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1884 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1885 return string_vector (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1886 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1887 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1888 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1889 cdef_class::cdef_class_rep::delete_object (cdef_object obj) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1890 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1891 method_iterator it = method_map.find ("delete"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1892 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1893 if (it != method_map.end ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1894 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1895 cdef_class cls = obj.get_class (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1896 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1897 obj.set_class (wrap ()); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1898 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1899 it->second.execute (obj, octave_value_list (), 0, false); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1900 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1901 obj.set_class (cls); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1902 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1903 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1904 // FIXME: should we destroy corresponding properties here? |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1905 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1906 // Call "delete" in super classes |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1907 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1908 Cell super_classes = get ("SuperClasses").cell_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1909 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1910 for (int i = 0; i < super_classes.numel (); i++) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1911 { |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
1912 cdef_class cls = lookup_class (super_classes(i)); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1913 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1914 if (!error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1915 cls.delete_object (obj); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1916 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1917 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1918 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1919 octave_value_list |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1920 cdef_class::cdef_class_rep::subsref_meta (const std::string& type, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1921 const std::list<octave_value_list>& idx, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1922 int nargout) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1923 { |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1924 size_t skip = 1; |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1925 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1926 octave_value_list retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1927 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1928 switch (type[0]) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1929 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1930 case '(': |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1931 // Constructor call |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
1932 gnulib::printf ("constructor\n"); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1933 retval(0) = construct (idx.front ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1934 break; |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1935 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1936 case '.': |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1937 // Static method, constant (or property?) |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1938 gnulib::printf ("static method/property\n"); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1939 if (idx.front ().length () == 1) |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1940 { |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1941 std::string nm = idx.front ()(0).string_value (); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1942 |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1943 if (! error_state) |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1944 { |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1945 cdef_method meth = find_method (nm); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1946 |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1947 if (meth.ok ()) |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1948 { |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1949 if (meth.is_static ()) |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1950 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1951 octave_value_list args; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1952 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1953 if (type.length () > 1 && idx.size () > 1 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1954 && type[1] == '(') |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1955 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1956 args = *(++(idx.begin ())); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1957 skip++; |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1958 } |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1959 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1960 retval = meth.execute (args, (type.length () > skip |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1961 ? 1 : nargout), true, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1962 "meta.class"); |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1963 } |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1964 else |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1965 ::error ("method `%s' is not static", nm.c_str ()); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1966 } |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1967 else |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1968 { |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1969 cdef_property prop = find_property (nm); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1970 |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1971 if (prop.ok ()) |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1972 { |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1973 if (prop.is_constant ()) |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
1974 retval(0) = prop.get_value (true, "meta.class"); |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1975 else |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1976 ::error ("property `%s' is not constant", |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1977 nm.c_str ()); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1978 } |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1979 else |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1980 ::error ("no such method or property `%s'", nm.c_str ()); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1981 } |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1982 } |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1983 else |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1984 ::error ("invalid meta.class indexing, expected a method or property name"); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1985 } |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1986 else |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1987 ::error ("invalid meta.class indexing"); |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1988 break; |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1989 |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1990 default: |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1991 ::error ("invalid meta.class indexing"); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1992 break; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1993 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1994 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1995 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1996 { |
15956
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1997 if (type.length () > skip && idx.size () > skip && ! retval.empty ()) |
d8553705f8f0
Support calling static methods and getting constant properties.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15955
diff
changeset
|
1998 retval = retval(0).next_subsref (nargout, type, idx, skip); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
1999 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2000 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2001 return retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2002 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2003 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2004 void |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2005 cdef_class::cdef_class_rep::initialize_object (cdef_object& obj) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2006 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2007 // Populate the object with default property values |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2008 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2009 std::list<cdef_class> super_classes = lookup_classes (get ("SuperClasses").cell_value ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2010 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2011 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2012 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2013 for (std::list<cdef_class>::iterator it = super_classes.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2014 ! error_state && it != super_classes.end (); ++it) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2015 it->initialize_object (obj); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2016 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2017 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2018 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2019 for (property_const_iterator it = property_map.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2020 ! error_state && it != property_map.end (); ++it) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2021 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2022 if (! it->second.get ("Dependent").bool_value ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2023 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2024 octave_value pvalue = it->second.get ("DefaultValue"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2025 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2026 if (pvalue.is_defined ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2027 obj.put (it->first, pvalue); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2028 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2029 obj.put (it->first, octave_value (Matrix ())); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2030 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2031 } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2032 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2033 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2034 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2035 refcount++; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2036 obj.mark_for_construction (cdef_class (this)); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2037 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2038 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2039 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2040 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2041 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2042 void |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2043 cdef_class::cdef_class_rep::run_constructor (cdef_object& obj, |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2044 const octave_value_list& args) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2045 { |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2046 octave_value_list empty_args; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2047 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2048 for (std::list<cdef_class>::const_iterator it = implicit_ctor_list.begin (); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2049 ! error_state && it != implicit_ctor_list.end (); ++it) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2050 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2051 cdef_class supcls = lookup_class (*it); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2052 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2053 if (! error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2054 supcls.run_constructor (obj, empty_args); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2055 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2056 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2057 if (error_state) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2058 return; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2059 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2060 std::string cls_name = get_name (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2061 std::string ctor_name = get_base_name (cls_name); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2062 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2063 cdef_method ctor = find_method (ctor_name); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2064 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2065 if (ctor.ok ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2066 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2067 octave_value_list ctor_args (args); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2068 octave_value_list ctor_retval; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2069 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2070 ctor_args.prepend (to_ov (obj)); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2071 ctor_retval = ctor.execute (ctor_args, 1, true, "constructor"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2072 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2073 if (! error_state) |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
2074 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2075 if (ctor_retval.length () == 1) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2076 obj = to_cdef (ctor_retval(0)); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2077 else |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2078 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2079 ::error ("%s: invalid number of output arguments for classdef constructor", |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2080 ctor_name.c_str ()); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2081 return; |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2082 } |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
2083 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2084 } |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2085 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2086 obj.mark_as_constructed (wrap ()); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2087 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2088 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2089 octave_value |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2090 cdef_class::cdef_class_rep::construct (const octave_value_list& args) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2091 { |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2092 cdef_object obj = construct_object (args); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2093 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2094 if (! error_state && obj.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2095 return to_ov (obj); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2096 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2097 return octave_value (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2098 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2099 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2100 cdef_object |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2101 cdef_class::cdef_class_rep::construct_object (const octave_value_list& args) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2102 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2103 if (! is_abstract ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2104 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2105 cdef_object obj; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2106 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2107 if (is_meta_class ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2108 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2109 // This code path is only used to create empty meta objects |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2110 // as filler for the empty values within a meta object array. |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2111 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2112 cdef_class this_cls = wrap (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2113 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2114 static cdef_object empty_class; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2115 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2116 if (this_cls == cdef_class::meta_class ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2117 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2118 if (! empty_class.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2119 empty_class = make_class ("", std::list<cdef_class> ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2120 obj = empty_class; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2121 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2122 else if (this_cls == cdef_class::meta_property ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2123 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2124 static cdef_property empty_property; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2125 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2126 if (! empty_class.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2127 empty_class = make_class ("", std::list<cdef_class> ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2128 if (! empty_property.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2129 empty_property = make_property (empty_class, ""); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2130 obj = empty_property; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2131 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2132 else if (this_cls == cdef_class::meta_method ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2133 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2134 static cdef_method empty_method; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2135 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2136 if (! empty_class.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2137 empty_class = make_class ("", std::list<cdef_class> ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2138 if (! empty_method.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2139 empty_method = make_method (empty_class, "", octave_value ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2140 obj = empty_method; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2141 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2142 else if (this_cls == cdef_class::meta_package ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2143 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2144 static cdef_package empty_package; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2145 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2146 if (! empty_package.ok ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2147 empty_package = make_package (""); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2148 obj = empty_package; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2149 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2150 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2151 panic_impossible (); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2152 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2153 return obj; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2154 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2155 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2156 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2157 if (is_handle_class ()) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2158 obj = cdef_object (new handle_cdef_object ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2159 else |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2160 obj = cdef_object (new value_cdef_object ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2161 obj.set_class (wrap ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2162 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2163 initialize_object (obj); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2164 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2165 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2166 { |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2167 run_constructor (obj, args); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2168 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2169 if (! error_state) |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2170 return obj; |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2171 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2172 } |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2173 } |
15870
2b6fe094e615
Implement embryonic value-class semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15869
diff
changeset
|
2174 else |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2175 error ("cannot instantiate object for abstract class `%s'", |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2176 get_name ().c_str ()); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2177 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2178 return cdef_object (); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2179 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2180 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2181 static octave_value |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2182 compute_attribute_value (tree_classdef_attribute* t) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2183 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2184 if (t->expression ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2185 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2186 if (t->expression ()->is_identifier ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2187 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2188 std::string s = t->expression ()->name (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2189 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2190 if (s == "public") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2191 return std::string ("public"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2192 else if (s == "protected") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2193 return std::string ("protected"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2194 else if (s == "private") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2195 return std::string ("private"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2196 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2197 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2198 return t->expression ()->rvalue1 (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2199 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2200 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2201 return octave_value (true); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2202 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2203 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2204 template<class T> |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2205 static std::string |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2206 attribute_value_to_string (T* t, octave_value v) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2207 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2208 if (v.is_string ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2209 return v.string_value (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2210 else if (t->expression ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2211 return t->expression ()->original_text (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2212 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2213 return std::string ("true"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2214 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2215 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2216 cdef_class |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2217 cdef_class::make_meta_class (tree_classdef* t) |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2218 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2219 cdef_class retval; |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2220 std::string class_name; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2221 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2222 // Class creation |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2223 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2224 class_name = t->ident ()->name (); |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2225 gnulib::printf ("class: %s\n", class_name.c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2226 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2227 std::list<cdef_class> slist; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2228 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2229 if (t->superclass_list ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2230 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2231 for (tree_classdef_superclass_list::iterator it = t->superclass_list ()->begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2232 ! error_state && it != t->superclass_list ()->end (); ++it) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2233 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2234 std::string sclass_name = |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2235 ((*it)->package () ? (*it)->package ()->name () + "." : std::string ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2236 + (*it)->ident ()->name (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2237 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2238 gnulib::printf ("superclass: %s\n", sclass_name.c_str ()); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2239 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2240 cdef_class sclass = lookup_class (sclass_name); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2241 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2242 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2243 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2244 if (! sclass.get ("Sealed").bool_value ()) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2245 slist.push_back (sclass); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2246 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2247 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2248 ::error ("`%s' cannot inherit from `%s', because it is sealed", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2249 class_name.c_str (), sclass_name.c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2250 return retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2251 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2252 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2253 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2254 return retval; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2255 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2256 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2257 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2258 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2259 retval = ::make_class (class_name, slist); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2260 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2261 if (error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2262 return cdef_class (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2263 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2264 // Class attributes |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2265 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2266 if (t->attribute_list ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2267 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2268 for (tree_classdef_attribute_list::iterator it = t->attribute_list ()->begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2269 it != t->attribute_list ()->end (); ++it) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2270 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2271 std::string aname = (*it)->ident ()->name (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2272 octave_value avalue = compute_attribute_value (*it); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2273 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2274 gnulib::printf ("class attribute: %s = %s\n", aname.c_str (), |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2275 attribute_value_to_string (*it, avalue).c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2276 retval.put (aname, avalue); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2277 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2278 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2279 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2280 tree_classdef_body* b = t->body (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2281 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2282 if (b) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2283 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2284 // Method blocks |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2285 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2286 std::list<tree_classdef_methods_block *> mb_list = b->methods_list (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2287 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2288 for (tree_classdef_body::methods_list_iterator it = mb_list.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2289 it != mb_list.end (); ++it) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2290 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2291 std::map<std::string, octave_value> amap; |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2292 gnulib::printf ("method block\n"); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2293 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2294 // Method attributes |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2295 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2296 if ((*it)->attribute_list ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2297 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2298 for (tree_classdef_attribute_list::iterator ait = (*it)->attribute_list ()->begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2299 ait != (*it)->attribute_list ()->end (); ++ait) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2300 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2301 std::string aname = (*ait)->ident ()->name (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2302 octave_value avalue = compute_attribute_value (*ait); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2303 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2304 gnulib::printf ("method attribute: %s = %s\n", aname.c_str (), |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2305 attribute_value_to_string (*ait, avalue).c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2306 amap[aname] = avalue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2307 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2308 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2309 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2310 // Methods |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2311 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2312 if ((*it)->element_list ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2313 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2314 for (tree_classdef_methods_list::iterator mit = (*it)->element_list ()->begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2315 mit != (*it)->element_list ()->end (); ++mit) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2316 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2317 std::string mname = mit->function_value ()->name (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2318 cdef_method meth = make_method (retval, mname, *mit); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2319 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2320 gnulib::printf ("%s: %s\n", (mname == class_name ? "constructor" : "method"), |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2321 mname.c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2322 for (std::map<std::string, octave_value>::iterator ait = amap.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2323 ait != amap.end (); ++ait) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2324 meth.put (ait->first, ait->second); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2325 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2326 retval.install_method (meth); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2327 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2328 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2329 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2330 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2331 // Property blocks |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2332 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2333 // FIXME: default property expression should be able to call static |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2334 // methods of the class being constructed. A restricted CLASSNAME |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2335 // symbol should be added to the scope before evaluating default |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2336 // value expressions. |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2337 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2338 std::list<tree_classdef_properties_block *> pb_list = b->properties_list (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2339 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2340 for (tree_classdef_body::properties_list_iterator it = pb_list.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2341 it != pb_list.end (); ++it) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2342 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2343 std::map<std::string, octave_value> amap; |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2344 gnulib::printf ("property block\n"); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2345 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2346 // Property attributes |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2347 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2348 if ((*it)->attribute_list ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2349 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2350 for (tree_classdef_attribute_list::iterator ait = (*it)->attribute_list ()->begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2351 ait != (*it)->attribute_list ()->end (); ++ait) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2352 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2353 std::string aname = (*ait)->ident ()->name (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2354 octave_value avalue = compute_attribute_value (*ait); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2355 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2356 gnulib::printf ("property attribute: %s = %s\n", aname.c_str (), |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2357 attribute_value_to_string (*ait, avalue).c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2358 if (aname == "Access") |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2359 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2360 amap["GetAccess"] = avalue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2361 amap["SetAccess"] = avalue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2362 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2363 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2364 amap[aname] = avalue; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2365 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2366 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2367 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2368 // Properties |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2369 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2370 if ((*it)->element_list ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2371 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2372 for (tree_classdef_property_list::iterator pit = (*it)->element_list ()->begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2373 pit != (*it)->element_list ()->end (); ++pit) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2374 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2375 cdef_property prop = ::make_property (retval, (*pit)->ident ()->name ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2376 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2377 gnulib::printf ("property: %s\n", (*pit)->ident ()->name ().c_str ()); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2378 if ((*pit)->expression ()) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2379 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2380 octave_value pvalue = (*pit)->expression ()->rvalue1 (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2381 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2382 gnulib::printf ("property default: %s\n", |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2383 attribute_value_to_string (*pit, pvalue).c_str ()); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2384 prop.put ("DefaultValue", pvalue); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2385 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2386 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2387 for (std::map<std::string, octave_value>::iterator ait = amap.begin (); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2388 ait != amap.end (); ++ait) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2389 prop.put (ait->first, ait->second); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2390 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2391 retval.install_property (prop); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2392 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2393 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2394 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2395 } |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2396 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2397 return retval; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2398 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2399 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2400 octave_function* |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2401 cdef_class::get_method_function (const std::string& /* nm */) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2402 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2403 octave_classdef_proxy* p = new octave_classdef_proxy (*this); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2404 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2405 return p; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2406 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2407 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2408 octave_value |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2409 cdef_property::cdef_property_rep::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:
15958
diff
changeset
|
2410 bool do_check_access, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2411 const std::string& who) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2412 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2413 octave_value retval; |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2414 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2415 if (do_check_access && ! check_get_access ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2416 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2417 gripe_property_access (who, wrap (), false); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2418 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2419 return retval; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2420 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2421 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2422 if (! obj.is_constructed ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2423 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2424 cdef_class cls (to_cdef (get ("DefiningClass"))); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2425 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2426 if (! obj.is_partially_constructed_for (cls)) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2427 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2428 ::error ("cannot reference properties of class `%s' for non-constructed object", |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2429 cls.get_name ().c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2430 return retval; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2431 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2432 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2433 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2434 octave_value get_fcn = get ("GetMethod"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2435 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2436 // FIXME: should check whether we're already in get accessor method |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2437 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2438 if (get_fcn.is_empty ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2439 retval = obj.get (get ("Name").string_value ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2440 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2441 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2442 octave_value_list args; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2443 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2444 args(0) = to_ov (obj); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2445 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2446 args = execute_ov (get_fcn, args, 1); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2447 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2448 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2449 retval = args(0); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2450 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2451 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2452 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2453 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2454 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2455 octave_value |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2456 cdef_property::cdef_property_rep::get_value (bool do_check_access, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2457 const std::string& who) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2458 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2459 if (do_check_access && ! check_get_access ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2460 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2461 gripe_property_access (who, wrap (), false); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2462 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2463 return octave_value (); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2464 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2465 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2466 return get ("DefaultValue"); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2467 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2468 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2469 bool |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2470 cdef_property::cdef_property_rep::is_recursive_set (const cdef_object& /* obj */) const |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2471 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2472 // FIXME: implement |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2473 return false; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2474 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2475 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2476 void |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2477 cdef_property::cdef_property_rep::set_value (cdef_object& obj, |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2478 const octave_value& val, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2479 bool do_check_access, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2480 const std::string& who) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2481 { |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2482 if (do_check_access && ! check_set_access ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2483 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2484 gripe_property_access (who, wrap (), true); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2485 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2486 return; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2487 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2488 |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2489 if (! obj.is_constructed ()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2490 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2491 cdef_class cls (to_cdef (get ("DefiningClass"))); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2492 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2493 if (! obj.is_partially_constructed_for (cls)) |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2494 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2495 ::error ("cannot reference properties of class `%s' for non-constructed object", |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2496 cls.get_name ().c_str ()); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2497 return; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2498 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2499 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2500 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2501 octave_value set_fcn = get ("SetMethod"); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2502 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2503 if (set_fcn.is_empty () || is_recursive_set (obj)) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2504 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2505 obj.put (get ("Name").string_value (), val); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2506 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2507 else |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2508 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2509 octave_value_list args; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2510 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2511 args(0) = to_ov (obj); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2512 args(1) = val; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2513 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2514 args = execute_ov (set_fcn, args, 1); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2515 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2516 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2517 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2518 if (args.length() > 0) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2519 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2520 cdef_object new_obj = to_cdef (args(0)); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2521 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2522 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2523 obj = new_obj; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2524 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2525 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2526 } |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2527 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2528 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2529 bool |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2530 cdef_property::cdef_property_rep::check_get_access (void) const |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2531 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2532 cdef_class cls (to_cdef (get ("DefiningClass"))); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2533 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2534 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2535 return ::check_access (cls, get ("GetAccess")); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2536 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2537 return false; |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2538 } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2539 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2540 bool |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2541 cdef_property::cdef_property_rep::check_set_access (void) const |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2542 { |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2543 cdef_class cls (to_cdef (get ("DefiningClass"))); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2544 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2545 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2546 return ::check_access (cls, get ("SetAccess")); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2547 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2548 return false; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2549 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2550 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2551 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2552 cdef_method::cdef_method_rep::check_method (void) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2553 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2554 // FIXME: check whether re-load is needed |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2555 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2556 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2557 octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2558 cdef_method::cdef_method_rep::execute (const octave_value_list& args, |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2559 int nargout, bool do_check_access, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2560 const std::string& who) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2561 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2562 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2563 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2564 if (do_check_access && ! check_access ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2565 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2566 gripe_method_access (who, wrap ()); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2567 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2568 return retval; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2569 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2570 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2571 if (! get ("Abstract").bool_value ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2572 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2573 check_method (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2574 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2575 if (function.is_defined ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2576 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2577 retval = execute_ov (function, args, nargout); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2578 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2579 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2580 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2581 error ("%s: cannot execute abstract method", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2582 get ("Name").string_value ().c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2583 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2584 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2585 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2586 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2587 octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2588 cdef_method::cdef_method_rep::execute (const cdef_object& obj, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2589 const octave_value_list& args, |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2590 int nargout, bool do_check_access, |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2591 const std::string& who) |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2592 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2593 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2594 |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2595 if (do_check_access && ! check_access ()) |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2596 { |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2597 gripe_method_access (who, wrap ()); |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2598 |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2599 return retval; |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2600 } |
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2601 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2602 if (! get ("Abstract").bool_value ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2603 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2604 check_method (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2605 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2606 octave_value_list new_args; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2607 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2608 if (function.is_defined ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2609 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2610 new_args.resize (args.length () + 1); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2611 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2612 new_args(0) = to_ov (obj); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2613 for (int i = 0; i < args.length (); i++) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2614 new_args(i+1) = args(i); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2615 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2616 retval = execute_ov (function, new_args, nargout); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2617 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2618 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2619 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2620 error ("%s: cannot execute abstract method", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2621 get ("Name").string_value ().c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2622 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2623 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2624 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2625 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2626 bool |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2627 cdef_method::cdef_method_rep::is_constructor (void) const |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2628 { |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2629 if (function.is_function()) |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2630 return function.function_value ()->is_classdef_constructor (); |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2631 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2632 return false; |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2633 } |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2634 |
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2635 bool |
15968
cdeb6eb656be
Move property/method access check down to cdef_property/cdef_method classes.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15958
diff
changeset
|
2636 cdef_method::cdef_method_rep::check_access (void) const |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2637 { |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2638 cdef_class cls (to_cdef (get ("DefiningClass"))); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2639 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2640 if (! error_state) |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2641 return ::check_access (cls, get ("Access")); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2642 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2643 return false; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2644 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2645 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2646 static cdef_package |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2647 lookup_package (const std::string& name) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2648 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2649 std::map<std::string, cdef_package>::const_iterator it = all_packages.find (name); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2650 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2651 if (it != all_packages.end ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2652 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2653 cdef_package pack = it->second; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2654 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2655 if (pack.ok ()) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2656 return pack; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2657 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2658 error ("invalid package: %s", name.c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2659 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2660 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2661 error ("package not found: %s", name.c_str ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2662 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2663 return cdef_package (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2664 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2665 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2666 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2667 package_fromName (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2668 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2669 octave_value_list retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2670 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2671 if (args.length () == 1) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2672 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2673 std::string name = args(0).string_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2674 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2675 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2676 retval(0) = to_ov (lookup_package (name)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2677 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2678 error ("fromName: invalid package name, expected a string value"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2679 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2680 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2681 error ("fromName: invalid number of parameters"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2682 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2683 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2684 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2685 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2686 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2687 package_get_classes (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2688 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2689 octave_value_list retval (1, Matrix ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2690 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2691 if (args.length () == 1 && args(0).type_name () == "object" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2692 && args(0).class_name () == "meta.package") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2693 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2694 cdef_package pack (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2695 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2696 retval(0) = pack.get_classes (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2697 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2698 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2699 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2700 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2701 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2702 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2703 package_get_functions (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2704 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2705 octave_value_list retval (1, Matrix ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2706 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2707 if (args.length () == 0 && args(0).type_name () == "object" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2708 && args(0).class_name () == "meta.package") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2709 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2710 cdef_package pack (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2711 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2712 retval(0) = pack.get_functions (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2713 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2714 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2715 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2716 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2717 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2718 static octave_value_list |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2719 package_get_packages (const octave_value_list& args, int /* nargout */) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2720 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2721 octave_value_list retval (1, Matrix ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2722 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2723 if (args.length () == 0 && args(0).type_name () == "object" |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2724 && args(0).class_name () == "meta.package") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2725 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2726 cdef_package pack (to_cdef (args(0))); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2727 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2728 retval(0) = pack.get_packages (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2729 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2730 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2731 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2732 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2733 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2734 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2735 cdef_package::cdef_package_rep::install_class (const cdef_class& cls, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2736 const std::string& nm) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2737 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2738 class_map[nm] = cls; |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
2739 |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
2740 member_count++; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2741 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2742 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2743 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2744 cdef_package::cdef_package_rep::install_function (const octave_value& fcn, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2745 const std::string& nm) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2746 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2747 function_map[nm] = fcn; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2748 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2749 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2750 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2751 cdef_package::cdef_package_rep::install_package (const cdef_package& pack, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2752 const std::string& nm) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2753 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2754 package_map[nm] = pack; |
15911
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
2755 |
b18b7e560236
More flexible refcount to account for owned back-references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15910
diff
changeset
|
2756 member_count++; |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2757 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2758 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2759 template<class T1, class T2> |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2760 Cell |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2761 map2Cell (const std::map<T1, T2>& m) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2762 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2763 Cell retval (1, m.size ()); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2764 int i = 0; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2765 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2766 for (typename std::map<T1, T2>::const_iterator it = m.begin (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2767 it != m.end (); ++it, ++i) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2768 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2769 retval(i) = to_ov (it->second); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2770 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2771 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2772 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2773 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2774 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2775 Cell |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2776 cdef_package::cdef_package_rep::get_classes (void) const |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2777 { return map2Cell (class_map); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2778 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2779 Cell |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2780 cdef_package::cdef_package_rep::get_functions (void) const |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2781 { return map2Cell (function_map); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2782 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2783 Cell |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2784 cdef_package::cdef_package_rep::get_packages (void) const |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2785 { return map2Cell (package_map); } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2786 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2787 cdef_class cdef_class::_meta_class = cdef_class (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2788 cdef_class cdef_class::_meta_property = cdef_class (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2789 cdef_class cdef_class::_meta_method = cdef_class (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2790 cdef_class cdef_class::_meta_package = cdef_class (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2791 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2792 cdef_package cdef_package::_meta = cdef_package (); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2793 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2794 void |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2795 install_classdef (void) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2796 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2797 octave_classdef::register_type (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2798 |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2799 /* bootstrap */ |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2800 cdef_class handle = make_class ("handle"); |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2801 cdef_class meta_class = cdef_class::_meta_class = make_meta_class ("meta.class", handle); |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2802 handle.set_class (meta_class); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2803 meta_class.set_class (meta_class); |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2804 |
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2805 /* meta classes */ |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2806 cdef_class meta_property = cdef_class::_meta_property = make_meta_class ("meta.property", handle); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2807 cdef_class meta_method = cdef_class::_meta_method = make_meta_class ("meta.method", handle); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2808 cdef_class meta_package = cdef_class::_meta_package = make_meta_class ("meta.package", handle); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2809 |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2810 cdef_class meta_event = make_meta_class ("meta.event", handle); |
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2811 cdef_class meta_dynproperty = make_meta_class ("meta.dynamicproperty", handle); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2812 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2813 /* meta.class properties */ |
15913
8521321604df
Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15911
diff
changeset
|
2814 meta_class.install_property (make_attribute (meta_class, "Abstract")); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2815 meta_class.install_property (make_attribute (meta_class, "ConstructOnLoad")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2816 meta_class.install_property (make_property (meta_class, "ContainingPackage")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2817 meta_class.install_property (make_property (meta_class, "Description")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2818 meta_class.install_property (make_property (meta_class, "DetailedDescription")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2819 meta_class.install_property (make_property (meta_class, "Events")); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2820 meta_class.install_property (make_attribute (meta_class, "HandleCompatible")); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2821 meta_class.install_property (make_attribute (meta_class, "Hidden")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2822 meta_class.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2823 (make_property (meta_class, "InferiorClasses", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2824 make_fcn_handle (class_get_inferiorclasses, "meta.class>get.InferiorClasses"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2825 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2826 meta_class.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2827 (make_property (meta_class, "Methods", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2828 make_fcn_handle (class_get_methods, "meta.class>get.Methods"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2829 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2830 meta_class.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2831 (make_property (meta_class, "MethodList", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2832 make_fcn_handle (class_get_methods, "meta.class>get.MethodList"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2833 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2834 meta_class.install_property (make_attribute (meta_class, "Name")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2835 meta_class.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2836 (make_property (meta_class, "Properties", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2837 make_fcn_handle (class_get_properties, "meta.class>get.Properties"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2838 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2839 meta_class.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2840 (make_property (meta_class, "PropertyList", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2841 make_fcn_handle (class_get_properties, "meta.class>get.PropertyList"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2842 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2843 meta_class.install_property (make_attribute (meta_class, "Sealed")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2844 meta_class.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2845 (make_property (meta_class, "SuperClasses", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2846 make_fcn_handle (class_get_superclasses, "meta.class>get.SuperClasses"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2847 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2848 meta_class.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2849 (make_property (meta_class, "SuperClassList", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2850 make_fcn_handle (class_get_superclasses, "meta.class>get.SuperClassList"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2851 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2852 /* meta.class methods */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2853 meta_class.install_method (make_method (meta_class, "fromName", class_fromName, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2854 "public", true)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2855 meta_class.install_method (make_method (meta_class, "fevalStatic", class_fevalStatic, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2856 "public", false)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2857 meta_class.install_method (make_method (meta_class, "getConstant", class_getConstant, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2858 "public", false)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2859 meta_class.install_method (make_method (meta_class, "eq", class_eq)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2860 meta_class.install_method (make_method (meta_class, "ne", class_ne)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2861 meta_class.install_method (make_method (meta_class, "lt", class_lt)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2862 meta_class.install_method (make_method (meta_class, "le", class_le)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2863 meta_class.install_method (make_method (meta_class, "gt", class_gt)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2864 meta_class.install_method (make_method (meta_class, "ge", class_ge)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2865 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2866 /* meta.method properties */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2867 meta_method.install_property (make_attribute (meta_method, "Abstract")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2868 meta_method.install_property (make_attribute (meta_method, "Access")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2869 meta_method.install_property (make_attribute (meta_method, "DefiningClass")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2870 meta_method.install_property (make_attribute (meta_method, "Description")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2871 meta_method.install_property (make_attribute (meta_method, "DetailedDescription")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2872 meta_method.install_property (make_attribute (meta_method, "Hidden")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2873 meta_method.install_property (make_attribute (meta_method, "Name")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2874 meta_method.install_property (make_attribute (meta_method, "Sealed")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2875 meta_method.install_property (make_attribute (meta_method, "Static")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2876 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2877 /* meta.property properties */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2878 meta_property.install_property (make_attribute (meta_property, "Name")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2879 meta_property.install_property (make_attribute (meta_property, "Description")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2880 meta_property.install_property (make_attribute (meta_property, "DetailedDescription")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2881 meta_property.install_property (make_attribute (meta_property, "Abstract")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2882 meta_property.install_property (make_attribute (meta_property, "Constant")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2883 meta_property.install_property (make_attribute (meta_property, "GetAccess")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2884 meta_property.install_property (make_attribute (meta_property, "SetAccess")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2885 meta_property.install_property (make_attribute (meta_property, "Dependent")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2886 meta_property.install_property (make_attribute (meta_property, "Transient")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2887 meta_property.install_property (make_attribute (meta_property, "Hidden")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2888 meta_property.install_property (make_attribute (meta_property, "GetObservable")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2889 meta_property.install_property (make_attribute (meta_property, "SetObservable")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2890 meta_property.install_property (make_attribute (meta_property, "GetMethod")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2891 meta_property.install_property (make_attribute (meta_property, "SetMethod")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2892 meta_property.install_property (make_attribute (meta_property, "DefiningClass")); |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2893 meta_property.install_property |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2894 (make_property (meta_property, "DefaultValue", |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2895 make_fcn_handle (property_get_defaultvalue, "meta.property>get.DefaultValue"), |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2896 "public", Matrix (), "private")); |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15841
diff
changeset
|
2897 meta_property.install_property (make_attribute (meta_property, "HasDefault")); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2898 /* meta.property events */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2899 // FIXME: add events |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2900 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2901 /* handle methods */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2902 handle.install_method (make_method (handle, "delete", handle_delete)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2903 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2904 /* meta.package properties */ |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2905 meta_package.install_property (make_attribute (meta_package, "Name")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2906 meta_package.install_property (make_property (meta_package, "ContainingPackage")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2907 meta_package.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2908 (make_property (meta_package, "ClassList", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2909 make_fcn_handle (package_get_classes, "meta.package>get.ClassList"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2910 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2911 meta_package.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2912 (make_property (meta_package, "Classes", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2913 make_fcn_handle (package_get_classes, "meta.package>get.Classes"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2914 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2915 meta_package.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2916 (make_property (meta_package, "FunctionList", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2917 make_fcn_handle (package_get_functions, "meta.package>get.FunctionList"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2918 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2919 meta_package.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2920 (make_property (meta_package, "Functions", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2921 make_fcn_handle (package_get_functions, "meta.package>get.Functions"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2922 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2923 meta_package.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2924 (make_property (meta_package, "PackageList", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2925 make_fcn_handle (package_get_packages, "meta.package>get.PackageList"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2926 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2927 meta_package.install_property |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2928 (make_property (meta_package, "Packages", |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2929 make_fcn_handle (package_get_packages, "meta.package>get.Packages"), |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2930 "public", Matrix (), "private")); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2931 meta_package.install_method (make_method (meta_package, "fromName", package_fromName, |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2932 "public", true)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2933 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2934 /* create "meta" package */ |
15909
b8bff84022d6
Use strong reference between objects and their class.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15897
diff
changeset
|
2935 cdef_package package_meta = cdef_package::_meta = make_package ("meta"); |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2936 package_meta.install_class (meta_class, "class"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2937 package_meta.install_class (meta_property, "property"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2938 package_meta.install_class (meta_method, "method"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2939 package_meta.install_class (meta_package, "package"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2940 package_meta.install_class (meta_event, "event"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2941 package_meta.install_class (meta_dynproperty, "dynproperty"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2942 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2943 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2944 DEFUN (__meta_get_package__, args, , "") |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2945 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2946 octave_value retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2947 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2948 if (args.length () == 1) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2949 { |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2950 std::string cname = args(0).string_value (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2951 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2952 if (! error_state) |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2953 retval = to_ov (lookup_package (cname)); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2954 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2955 error ("invalid package name, expected a string value"); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2956 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2957 else |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2958 print_usage (); |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2959 |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2960 return retval; |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2961 } |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2962 |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2963 DEFUN (__superclass_reference__, args, /* nargout */, |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2964 "-*- texinfo -*-\n\ |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2965 @deftypefn {Built-in Function} {} __superclass_reference__ ()\n\ |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2966 Undocumented internal function.\n\ |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2967 @end deftypefn") |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2968 { |
15896
57be060d7672
Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15870
diff
changeset
|
2969 return octave_value (new octave_classdef_superclass_ref (args)); |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2970 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2971 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2972 DEFUN (__meta_class_query__, args, /* nargout */, |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2973 "-*- texinfo -*-\n\ |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2974 @deftypefn {Built-in Function} {} __meta_class_query__ ()\n\ |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2975 Undocumented internal function.\n\ |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2976 @end deftypefn") |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2977 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2978 octave_value retval; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2979 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2980 std::cerr << "__meta_class_query__ (" |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2981 << args(0).string_value () << ", " |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2982 << args(1).string_value () << ")" |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2983 << std::endl; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2984 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2985 if (args.length () == 2) |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2986 { |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2987 std::string pkg = args(0).string_value (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2988 std::string cls = args(1).string_value (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2989 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2990 if (! pkg.empty ()) |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2991 cls = pkg + "." + cls; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2992 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2993 if (! error_state) |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2994 retval = to_ov (lookup_class (cls)); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2995 else |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2996 error ("invalid class name, expected a string value"); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2997 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2998 else |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
2999 print_usage (); |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
3000 |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
3001 return retval; |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
3002 } |
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
15036
diff
changeset
|
3003 |
15897
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3004 DEFUN (metaclass, args, /* nargout */, |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3005 "-*- texinfo -*-\n\ |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3006 @deftypefn {Built-in Function} {} metaclass (obj)\n\ |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3007 Returns the meta.class object corresponding to the class of @var{obj}.\n\ |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3008 @end deftypefn") |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3009 { |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3010 octave_value retval; |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3011 |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3012 if (args.length () == 1) |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3013 { |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3014 cdef_object obj = to_cdef (args(0)); |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3015 |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3016 if (! error_state) |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3017 retval = to_ov (obj.get_class ()); |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3018 else |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3019 print_usage (); |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3020 } |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3021 else |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3022 print_usage (); |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3023 |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3024 return retval; |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3025 } |
a413c6fe1726
Add metaclass function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15896
diff
changeset
|
3026 |
15036
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3027 /* |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3028 ;;; Local Variables: *** |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3029 ;;; mode: C++ *** |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3030 ;;; End: *** |
aa1f9e479c6e
octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3031 */ |