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