annotate libinterp/octave-value/cdef-package.cc @ 27000:711f23332204

eliminate some unnecessary include statements * oct-lvalue.h: Include stack-frame.h instead of call-stack.h. * defun.cc, ddef-method.cc, cdef-package.cc: Don't include pt-eval.h. * bp-table.cc, symtab.cc, toplev.cc: Don't include call-stack.h. * fcn-info.cc, symtab.cc, pt-decl.h, pt-misc.h: Don't include symrec.h. * symrec.cc: Don't include symscope.h. * cdef-package.cc, pt-stmt.cc: Don't include pt-walk.h. * ov-classdef.cc: Don't include symtab.h.
author John W. Eaton <jwe@octave.org>
date Fri, 29 Mar 2019 17:06:55 +0000
parents 568c2ab2782d
children 823b4bcf79fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2012-2019 Michael Goffioul
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 (at your option) any later version.
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 GNU General Public License for more details.
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <https://www.gnu.org/licenses/>.
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #if defined (HAVE_CONFIG_H)
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 # include "config.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include <algorithm>
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <iomanip>
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "cdef-class.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "cdef-manager.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "cdef-utils.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include "errwarn.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include "interpreter-private.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "interpreter.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "load-path.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "ov-builtin.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "ov-classdef.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include "ov-fcn-handle.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "ov-usr-fcn.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include "parse.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include "pt-assign.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "pt-classdef.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include "pt-idx.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include "pt-misc.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 #include "pt-stmt.h"
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 // Define to 1 to enable debugging statements.
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 #define DEBUG_TRACE 0
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
51 namespace octave
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 {
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
53 void
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
54 cdef_package::cdef_package_rep::install_class (const cdef_class& cls,
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
55 const std::string& nm)
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 class_map[nm] = cls;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
59 member_count++;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
60 }
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 void
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
63 cdef_package::cdef_package_rep::install_function (const octave_value& fcn,
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
64 const std::string& nm)
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 function_map[nm] = fcn;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
67 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
69 void
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
70 cdef_package::cdef_package_rep::install_package (const cdef_package& pack,
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
71 const std::string& nm)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
72 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
73 package_map[nm] = pack;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
75 member_count++;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
76 }
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 template <typename T1, typename T2>
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
79 Cell
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
80 map2Cell (const std::map<T1, T2>& m)
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 Cell retval (1, m.size ());
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
83 int i = 0;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
85 for (auto it = m.begin (); it != m.end (); ++it, ++i)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
86 retval(i) = to_ov (it->second);
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 return retval;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
89 }
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 Cell
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
92 cdef_package::cdef_package_rep::get_classes (void) const
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
93 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
94 return map2Cell (class_map);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
95 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
97 Cell
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
98 cdef_package::cdef_package_rep::get_functions (void) const
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
99 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
100 return map2Cell (function_map);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
101 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
103 Cell
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
104 cdef_package::cdef_package_rep::get_packages (void) 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 map2Cell (package_map);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
107 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
109 octave_value
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
110 cdef_package::cdef_package_rep::find (const std::string& nm)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
111 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
112 std::string symbol_name = get_name () + '.' + nm;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
114 interpreter& interp
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
115 = __get_interpreter__ ("cdef_package::cdef_package_rep::find");
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
117 return interp.find (symbol_name);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
118 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
120 octave_value_list
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
121 cdef_package::cdef_package_rep::meta_subsref
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 (const std::string& type, const std::list<octave_value_list>& idx,
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 int nargout)
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
124 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
125 octave_value_list retval;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
127 switch (type[0])
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 {
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
129 case '.':
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 if (idx.front ().length () != 1)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
132 error ("invalid meta.package indexing");
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
134 std::string nm = idx.front ()(0).xstring_value ("invalid meta.package indexing, expected a symbol name");
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 #if DEBUG_TRACE
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
137 std::cerr << "meta.package query: " << nm << std::endl;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 #endif
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
140 octave_value o = find (nm);
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
142 if (! o.is_defined ())
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
143 error ("member `%s' in package `%s' does not exist",
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
144 nm.c_str (), get_name ().c_str ());
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
146 if (o.is_function ())
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
147 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
148 octave_function *fcn = o.function_value ();
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
150 // NOTE: the case where the package query is the last
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
151 // part of this subsref index is handled in the parse
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
152 // tree, because there is some logic to handle magic
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
153 // "end" that makes it impossible to execute the
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
154 // function call at this stage.
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
156 if (type.size () > 1
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
157 && ! fcn->accepts_postfix_index (type[1]))
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 octave_value_list tmp_args;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
161 retval = feval (o, tmp_args, nargout);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
162 }
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
163 else
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
164 retval(0) = o;
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
166 if (type.size () > 1 && idx.size () > 1)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
167 retval = retval(0).next_subsref (nargout, type,
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
168 idx, 1);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
169 }
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
170 else if (type.size () > 1 && idx.size () > 1)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
171 retval = o.next_subsref (nargout, type, idx, 1);
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
172 else
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
173 retval(0) = o;
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 break;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
176
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
177 default:
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
178 error ("invalid meta.package indexing");
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
179 break;
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
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
182 return retval;
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
183 }
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
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
186 cdef_package::cdef_package_rep::meta_release (void)
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
187 {
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
188 // FIXME: Do we really want to unregister the package, as it
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
189 // could still be referenced by classes or sub-packages?
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
190 // If the package object is recreated later on, it won't
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
191 // match the one already referenced by those classes or
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
192 // sub-packages.
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193
26774
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
194 cdef_manager& cdm
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
195 = __get_cdef_manager__ ("cdef_package::cdef_package_rep::meta_release");
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
196
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
197 // Don't delete the "meta" package.
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
198 if (this != cdm.meta ().get_rep ())
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
199 cdm.unregister_package (wrap ());
568c2ab2782d move classdef classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26773
diff changeset
200 }
26772
d1419ac09564 split method, package, and property classes from cdef-class file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 }