annotate libinterp/octave-value/cdef-package.h @ 27923:bd51beb6205e

update formatting of copyright notices * Use <https://octave.org/copyright/> instead of <https://octave.org/COPYRIGHT.html/>. * For consistency with other comments in the Octave sources, use C++-style comments for copyright blocks in C and C++ files. * Use delimiters above and below copyright blocks that are appropriate for the language used in the file. * Eliminate extra spacing inside copyright blocks. * lex.ll (looks_like_copyright): Also allow newlines and carriage returns before the word "Copyright". * scripts/mk-doc.pl (gethelp): Also skip empty comment lines. * bp-table.cc, type.m: Adjust tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Jan 2020 11:59:41 -0500
parents 1891570abac8
children b018f553fd85
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 ////////////////////////////////////////////////////////////////////////
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_package_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_package_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
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 namespace octave
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 {
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 class interpreter;
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 class
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
45 cdef_package : public cdef_meta_object
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 {
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
47 friend class cdef_class;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 private:
26773
a95887edd55e style fixes for classdef classes
John W. Eaton <jwe@octave.org>
parents: 26772
diff changeset
50
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
51 class
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
52 cdef_package_rep : public cdef_meta_object_rep
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 {
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
54 public:
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
55
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
56 cdef_package_rep (void) : cdef_meta_object_rep (), member_count (0) { }
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_package_rep& operator = (const cdef_package_rep&) = 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_package_rep (void) = default;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
26774
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_package_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_package (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 void install_class (const cdef_class& cls, const std::string& nm);
26773
a95887edd55e style fixes for classdef classes
John W. Eaton <jwe@octave.org>
parents: 26772
diff changeset
71
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
72 void install_function (const octave_value& fcn, const std::string& nm);
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 install_package (const cdef_package& pack, const std::string& nm);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
75
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
76 Cell get_classes (void) const;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
77
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
78 Cell get_functions (void) const;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
80 Cell get_packages (void) const;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
81
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
82 octave_idx_type static_count (void) const { return member_count; }
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 void destroy (void)
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 if (member_count)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
87 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
88 m_count++;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
89 cdef_package lock (this);
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
91 member_count = 0;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
92 class_map.clear ();
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
93 package_map.clear ();
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
94 }
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
95 else
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
96 delete this;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
97 }
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
98
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
99 octave_value_list
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
100 meta_subsref (const std::string& type,
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
101 const std::list<octave_value_list>& idx, int nargout);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
102
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
103 void meta_release (void);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
104
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
105 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
106 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
107 return (type == '.');
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
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
110 octave_value find (const std::string& nm);
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
112 private:
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
113
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
114 std::string full_name;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
115 std::map<std::string, cdef_class> class_map;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
116 std::map<std::string, octave_value> function_map;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
117 std::map<std::string, cdef_package> package_map;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
118
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
119 // The number of registered members in this package (classes, packages).
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
120 // This only accounts for the members that back-reference to this package.
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
121 octave_idx_type member_count;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
123 typedef std::map<std::string, cdef_class>::iterator class_iterator;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
124 typedef std::map<std::string, cdef_class>::const_iterator class_const_iterator;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
125 typedef std::map<std::string, octave_value>::iterator function_iterator;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
126 typedef std::map<std::string, octave_value>::const_iterator function_const_iterator;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
127 typedef std::map<std::string, cdef_package>::iterator package_iterator;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
128 typedef std::map<std::string, cdef_package>::const_iterator package_const_iterator;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
129
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
130 cdef_package_rep (const cdef_package_rep& p)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
131 : cdef_meta_object_rep (p), full_name (p.full_name),
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
132 class_map (p.class_map), function_map (p.function_map),
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
133 package_map (p.package_map), member_count (p.member_count)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
134 { }
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_package wrap (void)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
137 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
138 m_count++;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
139 return cdef_package (this);
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 };
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
143 public:
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
145 cdef_package (void) : cdef_meta_object () { }
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 cdef_package (const std::string& nm)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
148 : cdef_meta_object (new cdef_package_rep ())
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
149 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
150 get_rep ()->set_name (nm);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
151 }
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
152
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
153 cdef_package (const cdef_package& pack) : cdef_meta_object (pack) { }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
155 cdef_package (const cdef_object& obj)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
156 : cdef_meta_object (obj)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
157 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
158 // This should never happen...
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
159 if (! is_package ())
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
160 error ("internal error: invalid assignment from %s to meta.package object",
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
161 class_name ().c_str ());
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
162 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
164 cdef_package& operator = (const cdef_package& pack)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
165 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
166 cdef_object::operator = (pack);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
167
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
168 return *this;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
169 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
171 ~cdef_package (void) = default;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
172
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
173 void install_class (const cdef_class& cls, const std::string& nm)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
174 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
175 get_rep ()->install_class (cls, nm);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
176 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
178 void install_function (const octave_value& fcn, const std::string& nm)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
179 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
180 get_rep ()->install_function (fcn, nm);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
181 }
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 void install_package (const cdef_package& pack, const std::string& nm)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
184 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
185 get_rep ()->install_package (pack, nm);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
186 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
188 Cell get_classes (void) const
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
189 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
190 return get_rep ()->get_classes ();
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
191 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
193 Cell get_functions (void) const
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
194 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
195 return get_rep ()->get_functions ();
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
196 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
198 Cell get_packages (void) const
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
199 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
200 return get_rep ()->get_packages ();
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
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
203 std::string get_name (void) const { return get_rep ()->get_name (); }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
205 octave_value find (const std::string& nm)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
206 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
207 return get_rep ()->find (nm);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
208 }
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
209
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
210 private:
26773
a95887edd55e style fixes for classdef classes
John W. Eaton <jwe@octave.org>
parents: 26772
diff changeset
211
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
212 cdef_package_rep * get_rep (void)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
213 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
214 return dynamic_cast<cdef_package_rep *> (cdef_object::get_rep ());
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
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
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
217 const cdef_package_rep * get_rep (void) const
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
218 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
219 return dynamic_cast<const cdef_package_rep *> (cdef_object::get_rep ());
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
220 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
221
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
222 friend void install_classdef (interpreter& interp);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
223 };
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
224 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
225
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
226 #endif