Mercurial > octave
annotate libinterp/octave-value/cdef-method.h @ 29359:7854d5752dd2
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 10:10:40 -0500 |
parents | 853e60367cb6 0a5b15007766 |
children | 0e0cc2760540 |
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 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
28515
diff
changeset
|
3 // Copyright (C) 2012-2021 The Octave Project Developers |
27923
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 //////////////////////////////////////////////////////////////////////// |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if ! defined (octave_cdef_method_h) |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #define octave_cdef_method_h 1 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include "octave-config.h" |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <map> |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <set> |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <string> |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "oct-refcount.h" |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "cdef-object.h" |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ov.h" |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
40 namespace octave |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
42 class |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
43 cdef_method : public cdef_meta_object |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
44 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
45 friend class cdef_class; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
46 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
47 private: |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
48 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
49 class |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
50 cdef_method_rep : public cdef_meta_object_rep |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
51 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
52 public: |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
53 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
54 cdef_method_rep (void) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
55 : cdef_meta_object_rep (), function (), dispatch_type () |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
56 { } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
57 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
58 cdef_method_rep& operator = (const cdef_method_rep& m) = delete; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
59 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
60 ~cdef_method_rep (void) = default; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
61 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
62 cdef_object_rep * copy (void) const { return new cdef_method_rep(*this); } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
63 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
64 bool is_method (void) const { return true; } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
65 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
66 std::string get_name (void) const { return get("Name").string_value (); } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
67 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
68 void set_name (const std::string& nm) { put ("Name", nm); } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
69 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
70 bool is_static (void) const { return get("Static").bool_value (); } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
71 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
72 octave_value get_function (void) const { return function; } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
73 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
74 void set_function (const octave_value& fcn) { function = fcn; } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
75 |
29234
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
76 OCTINTERP_API std::string get_doc_string (void); |
28515
49f4d7814760
find help for not-yet-loaded classdef methods defined in @DIR files.
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
77 |
29234
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
78 OCTINTERP_API bool check_access (void) const; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
79 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
80 bool is_external (void) const { return ! dispatch_type.empty (); } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
82 void mark_as_external (const std::string& dtype) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
83 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
84 dispatch_type = dtype; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
85 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
86 |
29234
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
87 OCTINTERP_API octave_value_list |
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
88 execute (const octave_value_list& args, int nargout, |
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
89 bool do_check_access = true, const std::string& who = ""); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
90 |
29234
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
91 OCTINTERP_API octave_value_list |
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
92 execute (const cdef_object& obj, |
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
93 const octave_value_list& args, int nargout, |
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
94 bool do_check_access = true, const std::string& who = ""); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
95 |
29234
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
96 OCTINTERP_API bool is_constructor (void) const; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
97 |
29234
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
98 OCTINTERP_API bool is_defined_in_class (const std::string& cname) const; |
26926
71724787d972
don't call inherited delete methods (bug #53956)
John W. Eaton <jwe@octave.org>
parents:
26774
diff
changeset
|
99 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
100 octave_value_list |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
101 meta_subsref (const std::string& type, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
102 const std::list<octave_value_list>& idx, int nargout); |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
104 bool meta_accepts_postfix_index (char type) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
105 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
106 return (type == '(' || type == '.'); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
107 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
108 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
109 private: |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
110 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
111 cdef_method_rep (const cdef_method_rep& m) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
112 : cdef_meta_object_rep (m), function (m.function), |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
113 dispatch_type (m.dispatch_type) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
114 { } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
115 |
29234
853e60367cb6
Set API tags in files in libinterp/octave-value (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28515
diff
changeset
|
116 OCTINTERP_API void check_method (void); |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
117 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
118 cdef_method wrap (void) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
119 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
120 m_count++; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
121 return cdef_method (this); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
122 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
123 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
124 octave_value function; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
125 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
126 // When non-empty, the method is externally defined and this member |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
127 // is used to cache the dispatch type to look for the method. |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
128 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
129 std::string dispatch_type; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
130 }; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
131 |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 public: |
26773
a95887edd55e
style fixes for classdef classes
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
133 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
134 cdef_method (void) : cdef_meta_object () { } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
136 cdef_method (const std::string& nm) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
137 : cdef_meta_object (new cdef_method_rep ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
138 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
139 get_rep ()->set_name (nm); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
140 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
141 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
142 cdef_method (const cdef_method& meth) : cdef_meta_object (meth) { } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
144 cdef_method (const cdef_object& obj) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
145 : cdef_meta_object (obj) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
146 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
147 // This should never happen... |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
148 if (! is_method ()) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
149 error ("internal error: invalid assignment from %s to meta.method object", |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
150 class_name ().c_str ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
151 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
153 cdef_method& operator = (const cdef_method& meth) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
154 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
155 cdef_object::operator = (meth); |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
157 return *this; |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
158 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
159 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
160 ~cdef_method (void) = default; |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
162 // normal invocation |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
163 octave_value_list execute (const octave_value_list& args, int nargout, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
164 bool do_check_access = true, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
165 const std::string& who = "") |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
166 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
167 return get_rep ()->execute (args, nargout, do_check_access, who); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
168 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
170 // dot-invocation: object is pushed as 1st argument |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
171 octave_value_list execute (const cdef_object& obj, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
172 const octave_value_list& args, int nargout, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
173 bool do_check_access = true, |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
174 const std::string& who = "") |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
175 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
176 return get_rep ()->execute (obj, args, nargout, do_check_access, who); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
177 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
179 bool check_access (void) const { return get_rep ()->check_access (); } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
181 std::string get_name (void) const { return get_rep ()->get_name (); } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
182 |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
183 bool is_static (void) const { return get_rep ()->is_static (); } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
185 void set_function (const octave_value& fcn) |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
186 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
187 get_rep ()->set_function (fcn); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
188 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
190 octave_value get_function (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
191 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
192 return get_rep ()->get_function (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
193 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 |
28515
49f4d7814760
find help for not-yet-loaded classdef methods defined in @DIR files.
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
195 std::string get_doc_string (void) |
49f4d7814760
find help for not-yet-loaded classdef methods defined in @DIR files.
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
196 { |
49f4d7814760
find help for not-yet-loaded classdef methods defined in @DIR files.
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
197 return get_rep ()->get_doc_string (); |
49f4d7814760
find help for not-yet-loaded classdef methods defined in @DIR files.
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
198 } |
49f4d7814760
find help for not-yet-loaded classdef methods defined in @DIR files.
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
199 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
200 bool is_constructor (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
201 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
202 return get_rep ()->is_constructor (); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
203 } |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
204 |
26926
71724787d972
don't call inherited delete methods (bug #53956)
John W. Eaton <jwe@octave.org>
parents:
26774
diff
changeset
|
205 bool is_defined_in_class (const std::string& cname) const |
71724787d972
don't call inherited delete methods (bug #53956)
John W. Eaton <jwe@octave.org>
parents:
26774
diff
changeset
|
206 { |
71724787d972
don't call inherited delete methods (bug #53956)
John W. Eaton <jwe@octave.org>
parents:
26774
diff
changeset
|
207 return get_rep ()->is_defined_in_class (cname); |
71724787d972
don't call inherited delete methods (bug #53956)
John W. Eaton <jwe@octave.org>
parents:
26774
diff
changeset
|
208 } |
71724787d972
don't call inherited delete methods (bug #53956)
John W. Eaton <jwe@octave.org>
parents:
26774
diff
changeset
|
209 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
210 bool is_external (void) const { return get_rep ()->is_external (); } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 void mark_as_external (const std::string& dtype) |
26773
a95887edd55e
style fixes for classdef classes
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
213 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
214 get_rep ()->mark_as_external (dtype); |
26773
a95887edd55e
style fixes for classdef classes
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
215 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 private: |
26773
a95887edd55e
style fixes for classdef classes
John W. Eaton <jwe@octave.org>
parents:
26772
diff
changeset
|
218 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
219 cdef_method_rep * get_rep (void) |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 { |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
221 return dynamic_cast<cdef_method_rep *> (cdef_object::get_rep ()); |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 } |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
224 const cdef_method_rep * get_rep (void) const |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
225 { |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
226 return dynamic_cast<const cdef_method_rep *> (cdef_object::get_rep ()); |
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
227 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 }; |
26774
568c2ab2782d
move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26773
diff
changeset
|
229 } |
26772
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 |
d1419ac09564
split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 #endif |