annotate libinterp/octave-value/ov-classdef.h @ 28516:70d155283f33

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Mon, 29 Jun 2020 15:12:39 -0400
parents b743a63e2dab fab862fedf85
children 853e60367cb6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 2012-2020 The Octave Project Developers
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20545
diff changeset
26 #if ! defined (octave_classdef_h)
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
27 #define octave_classdef_h 1
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21102
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21102
diff changeset
30
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
31 #include <string>
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
32
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
33 #include "cdef-object.h"
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
34 #include "ov-base.h"
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
35 #include "ov-fcn.h"
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
36
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
37 namespace octave
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
38 {
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
39 class cdef_object;
23533
8edbc923a7dc begin refactoring use of interpreter/evaluator in classdef objects
John W. Eaton <jwe@octave.org>
parents: 23503
diff changeset
40 class interpreter;
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
41 class tree_evaluator;
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24539
diff changeset
42 class type_info;
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23012
diff changeset
43 }
15037
56b8eb7c9c04 improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents: 15036
diff changeset
44
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
45 class
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
46 octave_classdef : public octave_base_value
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
47 {
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
48 public:
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
49
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
50 octave_classdef (void)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
51 : octave_base_value (), object () { }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
52
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
53 octave_classdef (const octave::cdef_object& obj)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
54 : octave_base_value (), object (obj) { }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
55
25321
089852fc8929 use explict default and deleted ctors and dtors for classdef classes
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
56 octave_classdef (const octave_classdef&) = delete;
089852fc8929 use explict default and deleted ctors and dtors for classdef classes
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
57
089852fc8929 use explict default and deleted ctors and dtors for classdef classes
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
58 octave_classdef& operator = (const octave_classdef&) = delete;
089852fc8929 use explict default and deleted ctors and dtors for classdef classes
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
59
089852fc8929 use explict default and deleted ctors and dtors for classdef classes
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
60 ~octave_classdef (void) = default;
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
61
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23446
diff changeset
62 octave_base_value * clone (void) const
26775
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
63 {
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
64 return new octave_classdef (object.clone ());
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
65 }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
66
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23446
diff changeset
67 octave_base_value * empty_clone (void) const
26775
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
68 {
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
69 return new octave_classdef (object.empty_clone ());
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
70 }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
71
23881
5aec653c88e7 new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
72 octave_classdef * classdef_object_value (bool = false) { return this; }
5aec653c88e7 new function for accessing classdef objects
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
73
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
74 octave::cdef_object get_object (void) const { return object; }
15896
57be060d7672 Implement full object construction and superclass references.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15870
diff changeset
75
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
76 octave::cdef_object& get_object_ref (void) { return object; }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
77
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
78 bool is_defined (void) const { return true; }
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
79
23584
7ed6b258db91 maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents: 23534
diff changeset
80 bool isstruct (void) const { return false; }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
81
23587
0c468af9dc00 maint: Deprecate is_object and replace with isobject.
Rik <rik@octave.org>
parents: 23584
diff changeset
82 bool isobject (void) const { return true; }
18306
122239398a03 Partial support for operator overload in classdef.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18263
diff changeset
83
19110
fa48651fbb8a isstruct for classdef objects should not return true.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 19103
diff changeset
84 bool is_classdef_object (void) const { return true; }
fa48651fbb8a isstruct for classdef objects should not return true.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 19103
diff changeset
85
18416
bcd71a2531d3 Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18397
diff changeset
86 void print (std::ostream& os, bool pr_as_read_syntax = false);
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
87
18416
bcd71a2531d3 Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18397
diff changeset
88 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
89
19103
56bc1464ec59 Implement "isa" for classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18692
diff changeset
90 bool is_instance_of (const std::string& cls_name) const;
56bc1464ec59 Implement "isa" for classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18692
diff changeset
91
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
92 octave_value_list subsref (const std::string& type,
18692
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18416
diff changeset
93 const std::list<octave_value_list>& idx,
18416
bcd71a2531d3 Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18397
diff changeset
94 int nargout);
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
95
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
96 octave_value subsref (const std::string& type,
18692
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18416
diff changeset
97 const std::list<octave_value_list>& idx)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
98 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
99 octave_value_list retval = subsref (type, idx, 1);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
100 return (retval.length () > 0 ? retval(0) : octave_value ());
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
101 }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
102
16696
665fa0f621cc Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16695
diff changeset
103 octave_value subsref (const std::string& type,
18692
fe0e34be5576 maint: untabify recently added code files.
Rik <rik@octave.org>
parents: 18416
diff changeset
104 const std::list<octave_value_list>& idx,
16696
665fa0f621cc Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16695
diff changeset
105 bool auto_add);
665fa0f621cc Support combination of object array extension and multi-level indexing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16695
diff changeset
106
15869
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15841
diff changeset
107 octave_value subsasgn (const std::string& type,
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15841
diff changeset
108 const std::list<octave_value_list>& idx,
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15841
diff changeset
109 const octave_value& rhs);
5e5705b3e505 Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15841
diff changeset
110
15913
8521321604df Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15911
diff changeset
111 octave_value
8521321604df Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15911
diff changeset
112 undef_subsasgn (const std::string& type,
8521321604df Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15911
diff changeset
113 const std::list<octave_value_list>& idx,
8521321604df Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15911
diff changeset
114 const octave_value& rhs);
8521321604df Initial support for object array semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15911
diff changeset
115
28072
47238792de58 provide default size method for classdef objects
John W. Eaton <jwe@octave.org>
parents: 27970
diff changeset
116 Matrix size (void);
47238792de58 provide default size method for classdef objects
John W. Eaton <jwe@octave.org>
parents: 27970
diff changeset
117
26922
072d0610cc56 avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents: 26917
diff changeset
118 octave_idx_type xnumel (const octave_value_list&);
24802
7605e06a50d5 tie octave_classdef::numel method to "numel" user override method (bug #46571)
Sébastien Villemot <sebastien@debian.org>
parents: 23219
diff changeset
119
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
120 string_vector map_keys (void) const { return object.map_keys (); }
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
121
19184
e0a7718ac085 Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 19110
diff changeset
122 octave_map map_value (void) const { return object.map_value (); }
e0a7718ac085 Implement calling "struct" on classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 19110
diff changeset
123
15936
da4cd4ab36db Report correct size for object of classdef objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15926
diff changeset
124 dim_vector dims (void) const { return object.dims (); }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
125
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
126 void set_property (octave_idx_type idx, const std::string& name,
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
127 const octave_value& pval)
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
128 {
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
129 object.set_property (idx, name, pval);
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
130 }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
131
23893
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
132 octave_value
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
133 get_property (octave_idx_type idx, const std::string& name) const
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
134 {
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
135 return object.get_property (idx, name);
75eff5b667b3 new mxSetProperty function for MEX API
John W. Eaton <jwe@octave.org>
parents: 23881
diff changeset
136 }
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
137
26718
9b0335f4bc74 revise naming of the parts of a superclass reference
John W. Eaton <jwe@octave.org>
parents: 26686
diff changeset
138 static octave_value superclass_ref (const std::string& meth,
26686
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
139 const std::string& cls);
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
140
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
141 static octave_value metaclass_query (const std::string& cls);
581d01526b34 eliminate unnecessary tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
142
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
143 public:
26775
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
144
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
145 int type_id (void) const { return t_id; }
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
146 std::string type_name (void) const { return t_name; }
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
147 std::string class_name (void) const { return object.class_name (); }
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
148
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
149 static int static_type_id (void) { return t_id; }
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
150 static std::string static_type_name (void) { return t_name; }
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
151 static std::string static_class_name (void) { return "<unknown>"; }
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24539
diff changeset
152 static void register_type (octave::type_info&);
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
153
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
154 private:
23533
8edbc923a7dc begin refactoring use of interpreter/evaluator in classdef objects
John W. Eaton <jwe@octave.org>
parents: 23503
diff changeset
155
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
156 octave::cdef_object object;
23533
8edbc923a7dc begin refactoring use of interpreter/evaluator in classdef objects
John W. Eaton <jwe@octave.org>
parents: 23503
diff changeset
157
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
158 static int t_id;
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
159
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
160 static const std::string t_name;
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
161 };
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
162
23533
8edbc923a7dc begin refactoring use of interpreter/evaluator in classdef objects
John W. Eaton <jwe@octave.org>
parents: 23503
diff changeset
163 OCTINTERP_API void install_classdef (octave::interpreter& interp);
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
164
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
165 class octave_classdef_meta : public octave_function
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
166 {
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
167 public:
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
168
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
169 octave_classdef_meta (const octave::cdef_meta_object& obj)
26775
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
170 : object (obj)
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
171 { }
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
172
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
173 octave_classdef_meta (const octave_classdef_meta&) = delete;
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
174
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
175 octave_classdef_meta& operator = (const octave_classdef_meta&) = delete;
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
176
26775
2d65d46c620b * ov-classdef.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 26774
diff changeset
177 ~octave_classdef_meta (void) { object.meta_release (); }
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
178
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
179 bool is_classdef_meta (void) const { return true; }
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
180
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
181 bool is_package (void) const { return object.is_package(); }
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
182
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
183 octave_function * function_value (bool = false) { return this; }
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
184
26916
9cd4b045fe3d avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents: 26775
diff changeset
185 // We don't need to override all three forms of subsref. The using
9cd4b045fe3d avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents: 26775
diff changeset
186 // declaration will avoid warnings about partially-overloaded virtual
9cd4b045fe3d avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents: 26775
diff changeset
187 // functions.
9cd4b045fe3d avoid some overloaded virtual warnings (bug #55741)
John W. Eaton <jwe@octave.org>
parents: 26775
diff changeset
188 using octave_function::subsref;
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
189
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
190 octave_value_list
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
191 subsref (const std::string& type,
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
192 const std::list<octave_value_list>& idx,
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
193 int nargout)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
194 {
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
195 return object.meta_subsref (type, idx, nargout);
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
196 }
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
197
28429
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
198 // Override default call method because we don't push a new stack
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
199 // frame for this operation on classdef_meta objects.
16676
7368654f302f Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16048
diff changeset
200
28429
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
201 octave_value_list call (octave::tree_evaluator& tw, int nargout,
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
202 const octave_value_list& args)
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
203 {
28429
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
204 return execute (tw, nargout, args);
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
205 }
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
206
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
207 octave_value_list execute (octave::tree_evaluator&, int nargout,
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
208 const octave_value_list& args)
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
209 {
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
210 // Emulate ()-type meta subsref
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
211
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
212 std::list<octave_value_list> idx (1, args);
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
213 std::string type ("(");
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
214
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
215 return subsref (type, idx, nargout);
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
216 }
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
217
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
218 bool accepts_postfix_index (char type) const
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
219 { return object.meta_accepts_postfix_index (type); }
24539
4e2ca22b3cf9 refactor cdef_manager
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
220
28438
55f82d23fe5e new octave_classdef_meta::is_classdef_method function
John W. Eaton <jwe@octave.org>
parents: 28429
diff changeset
221 bool is_classdef_method (const std::string& cname = "") const;
55f82d23fe5e new octave_classdef_meta::is_classdef_method function
John W. Eaton <jwe@octave.org>
parents: 28429
diff changeset
222
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
223 bool is_classdef_constructor (const std::string& cname = "") const;
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
224
28514
fab862fedf85 allow help to find docstrings for classdef classes and methods (bug #43047)
John W. Eaton <jwe@octave.org>
parents: 28438
diff changeset
225 std::string doc_string (const std::string& meth_name) const;
fab862fedf85 allow help to find docstrings for classdef classes and methods (bug #43047)
John W. Eaton <jwe@octave.org>
parents: 28438
diff changeset
226
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
227 private:
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
228
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26769
diff changeset
229 octave::cdef_meta_object object;
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
230 };
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
231
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
232 class octave_classdef_superclass_ref : public octave_function
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
233 {
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
234 public:
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
235 octave_classdef_superclass_ref (void) = delete;
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
236
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
237 octave_classdef_superclass_ref (const std::string& meth,
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
238 const std::string& cls)
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
239 : octave_function (), m_method_name (meth), m_class_name (cls)
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
240 { }
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
241
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
242 octave_classdef_superclass_ref (const octave_classdef_superclass_ref&) = delete;
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
243
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
244 octave_classdef_superclass_ref& operator = (const octave_classdef_superclass_ref&) = delete;
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
245
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
246 ~octave_classdef_superclass_ref (void) = default;
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
247
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
248 bool is_classdef_superclass_ref (void) const { return true; }
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
249
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
250 octave_function * function_value (bool = false) { return this; }
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
251
28429
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
252 // Override default call method because we don't push a new stack
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
253 // frame for this operation on classdef_superclass_ref objects.
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
254
28429
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
255 octave_value_list call (octave::tree_evaluator& tw, int nargout,
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
256 const octave_value_list& args)
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
257 {
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
258 return execute (tw, nargout, args);
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
259 }
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
260
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
261 octave_value_list execute (octave::tree_evaluator& tw, int nargout,
8eb8ba8aff9a refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents: 28072
diff changeset
262 const octave_value_list& idx);
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
263
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
264 private:
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
265
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
266 bool is_constructed_object (octave::tree_evaluator& tw,
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
267 const std::string& nm);
23651
5c6cceef132b don't use singleton for cdef_manager object
John W. Eaton <jwe@octave.org>
parents: 23587
diff changeset
268
26769
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
269 private:
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
270
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
271 std::string m_method_name;
2f847e3e8d6b split classdef into multiple smaller source files
John W. Eaton <jwe@octave.org>
parents: 26745
diff changeset
272 std::string m_class_name;
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
273 };
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15986
diff changeset
274
15036
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
275 #endif
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
276
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
277 /*
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
278 ;;; Local Variables: ***
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
279 ;;; mode: C++ ***
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
280 ;;; End: ***
aa1f9e479c6e octave_value classdef objects
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff changeset
281 */