2376
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
|
4 2007 John W. Eaton |
2376
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
2376
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
2376
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_value_typeinfo_h) |
|
25 #define octave_value_typeinfo_h 1 |
|
26 |
|
27 #include <string> |
|
28 |
|
29 #include "Array.h" |
|
30 #include "Array2.h" |
|
31 #include "Array3.h" |
|
32 |
|
33 #include "ov.h" |
|
34 |
|
35 class string_vector; |
|
36 |
|
37 class |
6109
|
38 OCTINTERP_API |
2376
|
39 octave_value_typeinfo |
|
40 { |
|
41 public: |
|
42 |
7336
|
43 typedef octave_value (*unary_class_op_fcn) (const octave_value&); |
|
44 |
5759
|
45 typedef octave_value (*unary_op_fcn) (const octave_base_value&); |
|
46 |
|
47 typedef void (*non_const_unary_op_fcn) (octave_base_value&); |
|
48 |
7336
|
49 typedef octave_value (*binary_class_op_fcn) |
|
50 (const octave_value&, const octave_value&); |
|
51 |
5759
|
52 typedef octave_value (*binary_op_fcn) |
|
53 (const octave_base_value&, const octave_base_value&); |
|
54 |
|
55 typedef octave_value (*cat_op_fcn) |
6906
|
56 (octave_base_value&, const octave_base_value&, const Array<octave_idx_type>& ra_idx); |
5759
|
57 |
|
58 typedef octave_value (*assign_op_fcn) |
|
59 (octave_base_value&, const octave_value_list&, const octave_base_value&); |
|
60 |
|
61 typedef octave_value (*assignany_op_fcn) |
|
62 (octave_base_value&, const octave_value_list&, const octave_value&); |
|
63 |
2926
|
64 static bool instance_ok (void); |
|
65 |
4640
|
66 static int register_type (const std::string&, const std::string&, |
|
67 const octave_value&); |
2376
|
68 |
7336
|
69 static bool register_unary_class_op (octave_value::unary_op, |
|
70 unary_class_op_fcn); |
|
71 |
3203
|
72 static bool register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
|
73 |
|
74 static bool register_non_const_unary_op (octave_value::unary_op, int, |
|
75 non_const_unary_op_fcn); |
|
76 |
7336
|
77 static bool register_binary_class_op (octave_value::binary_op, |
|
78 binary_class_op_fcn); |
|
79 |
2376
|
80 static bool register_binary_op (octave_value::binary_op, int, int, |
2427
|
81 binary_op_fcn); |
2376
|
82 |
4915
|
83 static bool register_cat_op (int, int, cat_op_fcn); |
|
84 |
2882
|
85 static bool register_assign_op (octave_value::assign_op, int, int, |
|
86 assign_op_fcn); |
2376
|
87 |
3196
|
88 static bool register_assignany_op (octave_value::assign_op, int, |
5759
|
89 assignany_op_fcn); |
3196
|
90 |
2376
|
91 static bool register_pref_assign_conv (int, int, int); |
|
92 |
5759
|
93 static bool |
|
94 register_type_conv_op (int, int, octave_base_value::type_conv_fcn); |
4901
|
95 |
5759
|
96 static bool |
|
97 register_widening_op (int, int, octave_base_value::type_conv_fcn); |
2376
|
98 |
4640
|
99 static octave_value |
|
100 lookup_type (const std::string& nm) |
|
101 { |
|
102 return instance->do_lookup_type (nm); |
|
103 } |
|
104 |
7336
|
105 static unary_class_op_fcn |
|
106 lookup_unary_class_op (octave_value::unary_op op) |
|
107 { |
|
108 return instance->do_lookup_unary_class_op (op); |
|
109 } |
|
110 |
3203
|
111 static unary_op_fcn |
|
112 lookup_unary_op (octave_value::unary_op op, int t) |
|
113 { |
|
114 return instance->do_lookup_unary_op (op, t); |
|
115 } |
|
116 |
|
117 static non_const_unary_op_fcn |
|
118 lookup_non_const_unary_op (octave_value::unary_op op, int t) |
|
119 { |
|
120 return instance->do_lookup_non_const_unary_op (op, t); |
|
121 } |
|
122 |
7336
|
123 static binary_class_op_fcn |
|
124 lookup_binary_class_op (octave_value::binary_op op) |
|
125 { |
|
126 return instance->do_lookup_binary_class_op (op); |
|
127 } |
|
128 |
2427
|
129 static binary_op_fcn |
2376
|
130 lookup_binary_op (octave_value::binary_op op, int t1, int t2) |
|
131 { |
|
132 return instance->do_lookup_binary_op (op, t1, t2); |
|
133 } |
|
134 |
4915
|
135 static cat_op_fcn |
|
136 lookup_cat_op (int t1, int t2) |
|
137 { |
|
138 return instance->do_lookup_cat_op (t1, t2); |
|
139 } |
|
140 |
2427
|
141 static assign_op_fcn |
2882
|
142 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs) |
2376
|
143 { |
2882
|
144 return instance->do_lookup_assign_op (op, t_lhs, t_rhs); |
2376
|
145 } |
|
146 |
5759
|
147 static assignany_op_fcn |
3196
|
148 lookup_assignany_op (octave_value::assign_op op, int t_lhs) |
|
149 { |
|
150 return instance->do_lookup_assignany_op (op, t_lhs); |
|
151 } |
|
152 |
2376
|
153 static int |
|
154 lookup_pref_assign_conv (int t_lhs, int t_rhs) |
|
155 { |
|
156 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs); |
|
157 } |
|
158 |
5759
|
159 static octave_base_value::type_conv_fcn |
4901
|
160 lookup_type_conv_op (int t, int t_result) |
|
161 { |
|
162 return instance->do_lookup_type_conv_op (t, t_result); |
|
163 } |
|
164 |
5759
|
165 static octave_base_value::type_conv_fcn |
2376
|
166 lookup_widening_op (int t, int t_result) |
|
167 { |
|
168 return instance->do_lookup_widening_op (t, t_result); |
|
169 } |
|
170 |
|
171 static string_vector installed_type_names (void) |
|
172 { |
|
173 return instance->do_installed_type_names (); |
|
174 } |
|
175 |
|
176 protected: |
|
177 |
|
178 octave_value_typeinfo (void) |
3523
|
179 : num_types (0), types (init_tab_sz, std::string ()), |
4645
|
180 vals (init_tab_sz), |
7336
|
181 unary_class_ops (octave_value::num_unary_ops, 0), |
5760
|
182 unary_ops (octave_value::num_unary_ops, init_tab_sz, 0), |
|
183 non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, 0), |
7336
|
184 binary_class_ops (octave_value::num_binary_ops, 0), |
5760
|
185 binary_ops (octave_value::num_binary_ops, init_tab_sz, init_tab_sz, 0), |
|
186 cat_ops (init_tab_sz, init_tab_sz, 0), |
|
187 assign_ops (octave_value::num_assign_ops, init_tab_sz, init_tab_sz, 0), |
|
188 assignany_ops (octave_value::num_assign_ops, init_tab_sz, 0), |
2479
|
189 pref_assign_conv (init_tab_sz, init_tab_sz, -1), |
5760
|
190 type_conv_ops (init_tab_sz, init_tab_sz, 0), |
|
191 widening_ops (init_tab_sz, init_tab_sz, 0) { } |
2376
|
192 |
|
193 private: |
|
194 |
2479
|
195 static const int init_tab_sz; |
|
196 |
2376
|
197 static octave_value_typeinfo *instance; |
|
198 |
|
199 int num_types; |
|
200 |
3523
|
201 Array<std::string> types; |
2376
|
202 |
4640
|
203 Array<octave_value> vals; |
|
204 |
7336
|
205 Array<unary_class_op_fcn> unary_class_ops; |
|
206 |
3203
|
207 Array2<unary_op_fcn> unary_ops; |
|
208 |
|
209 Array2<non_const_unary_op_fcn> non_const_unary_ops; |
|
210 |
7336
|
211 Array<binary_class_op_fcn> binary_class_ops; |
|
212 |
2427
|
213 Array3<binary_op_fcn> binary_ops; |
2376
|
214 |
4915
|
215 Array2<cat_op_fcn> cat_ops; |
|
216 |
2882
|
217 Array3<assign_op_fcn> assign_ops; |
2376
|
218 |
5759
|
219 Array2<assignany_op_fcn> assignany_ops; |
3196
|
220 |
2376
|
221 Array2<int> pref_assign_conv; |
|
222 |
5759
|
223 Array2<octave_base_value::type_conv_fcn> type_conv_ops; |
4901
|
224 |
5759
|
225 Array2<octave_base_value::type_conv_fcn> widening_ops; |
2376
|
226 |
4640
|
227 int do_register_type (const std::string&, const std::string&, |
|
228 const octave_value&); |
2376
|
229 |
7336
|
230 bool do_register_unary_class_op (octave_value::unary_op, unary_class_op_fcn); |
|
231 |
3203
|
232 bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
|
233 |
|
234 bool do_register_non_const_unary_op (octave_value::unary_op, int, |
|
235 non_const_unary_op_fcn); |
|
236 |
7336
|
237 bool do_register_binary_class_op (octave_value::binary_op, |
|
238 binary_class_op_fcn); |
|
239 |
2376
|
240 bool do_register_binary_op (octave_value::binary_op, int, int, |
2427
|
241 binary_op_fcn); |
2376
|
242 |
4915
|
243 bool do_register_cat_op (int, int, cat_op_fcn); |
|
244 |
2882
|
245 bool do_register_assign_op (octave_value::assign_op, int, int, |
|
246 assign_op_fcn); |
2376
|
247 |
3196
|
248 bool do_register_assignany_op (octave_value::assign_op, int, |
5759
|
249 assignany_op_fcn); |
3196
|
250 |
2376
|
251 bool do_register_pref_assign_conv (int, int, int); |
|
252 |
5759
|
253 bool do_register_type_conv_op (int, int, octave_base_value::type_conv_fcn); |
4901
|
254 |
5759
|
255 bool do_register_widening_op (int, int, octave_base_value::type_conv_fcn); |
2376
|
256 |
4640
|
257 octave_value do_lookup_type (const std::string& nm); |
|
258 |
7336
|
259 unary_class_op_fcn do_lookup_unary_class_op (octave_value::unary_op); |
|
260 |
3203
|
261 unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int); |
|
262 |
|
263 non_const_unary_op_fcn do_lookup_non_const_unary_op |
|
264 (octave_value::unary_op, int); |
2376
|
265 |
7336
|
266 binary_class_op_fcn do_lookup_binary_class_op (octave_value::binary_op); |
|
267 |
3203
|
268 binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int); |
2376
|
269 |
4915
|
270 cat_op_fcn do_lookup_cat_op (int, int); |
|
271 |
3203
|
272 assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int); |
|
273 |
5759
|
274 assignany_op_fcn do_lookup_assignany_op (octave_value::assign_op, int); |
3196
|
275 |
2376
|
276 int do_lookup_pref_assign_conv (int, int); |
|
277 |
5759
|
278 octave_base_value::type_conv_fcn do_lookup_type_conv_op (int, int); |
4901
|
279 |
5759
|
280 octave_base_value::type_conv_fcn do_lookup_widening_op (int, int); |
2376
|
281 |
|
282 string_vector do_installed_type_names (void); |
|
283 |
|
284 // No copying! |
|
285 |
|
286 octave_value_typeinfo (const octave_value_typeinfo&); |
|
287 |
|
288 octave_value_typeinfo& operator = (const octave_value_typeinfo&); |
|
289 }; |
|
290 |
|
291 #endif |
|
292 |
|
293 /* |
6705
|
294 ;;; Local Variables: *** |
|
295 ;;; mode: C++ *** |
|
296 ;;; End: *** |
2376
|
297 */ |