Mercurial > hg > octave-nkf
annotate src/ov-typeinfo.h @ 9585:06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 28 Aug 2009 18:37:31 -0400 |
parents | 902a4597dce8 |
children | cd96d29c5efa |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008 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 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
83 static bool register_binary_class_op (octave_value::compound_binary_op, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
84 binary_class_op_fcn); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
85 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
86 static bool register_binary_op (octave_value::compound_binary_op, int, int, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
87 binary_op_fcn); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
88 |
4915 | 89 static bool register_cat_op (int, int, cat_op_fcn); |
90 | |
2882 | 91 static bool register_assign_op (octave_value::assign_op, int, int, |
92 assign_op_fcn); | |
2376 | 93 |
3196 | 94 static bool register_assignany_op (octave_value::assign_op, int, |
5759 | 95 assignany_op_fcn); |
3196 | 96 |
2376 | 97 static bool register_pref_assign_conv (int, int, int); |
98 | |
5759 | 99 static bool |
100 register_type_conv_op (int, int, octave_base_value::type_conv_fcn); | |
4901 | 101 |
5759 | 102 static bool |
103 register_widening_op (int, int, octave_base_value::type_conv_fcn); | |
2376 | 104 |
4640 | 105 static octave_value |
106 lookup_type (const std::string& nm) | |
107 { | |
108 return instance->do_lookup_type (nm); | |
109 } | |
110 | |
7336 | 111 static unary_class_op_fcn |
112 lookup_unary_class_op (octave_value::unary_op op) | |
113 { | |
114 return instance->do_lookup_unary_class_op (op); | |
115 } | |
116 | |
3203 | 117 static unary_op_fcn |
118 lookup_unary_op (octave_value::unary_op op, int t) | |
119 { | |
120 return instance->do_lookup_unary_op (op, t); | |
121 } | |
122 | |
123 static non_const_unary_op_fcn | |
124 lookup_non_const_unary_op (octave_value::unary_op op, int t) | |
125 { | |
126 return instance->do_lookup_non_const_unary_op (op, t); | |
127 } | |
128 | |
7336 | 129 static binary_class_op_fcn |
130 lookup_binary_class_op (octave_value::binary_op op) | |
131 { | |
132 return instance->do_lookup_binary_class_op (op); | |
133 } | |
134 | |
2427 | 135 static binary_op_fcn |
2376 | 136 lookup_binary_op (octave_value::binary_op op, int t1, int t2) |
137 { | |
138 return instance->do_lookup_binary_op (op, t1, t2); | |
139 } | |
140 | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
141 static binary_class_op_fcn |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
142 lookup_binary_class_op (octave_value::compound_binary_op op) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
143 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
144 return instance->do_lookup_binary_class_op (op); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
145 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
146 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
147 static binary_op_fcn |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
148 lookup_binary_op (octave_value::compound_binary_op op, int t1, int t2) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
149 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
150 return instance->do_lookup_binary_op (op, t1, t2); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
151 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
152 |
4915 | 153 static cat_op_fcn |
154 lookup_cat_op (int t1, int t2) | |
155 { | |
156 return instance->do_lookup_cat_op (t1, t2); | |
157 } | |
158 | |
2427 | 159 static assign_op_fcn |
2882 | 160 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs) |
2376 | 161 { |
2882 | 162 return instance->do_lookup_assign_op (op, t_lhs, t_rhs); |
2376 | 163 } |
164 | |
5759 | 165 static assignany_op_fcn |
3196 | 166 lookup_assignany_op (octave_value::assign_op op, int t_lhs) |
167 { | |
168 return instance->do_lookup_assignany_op (op, t_lhs); | |
169 } | |
170 | |
2376 | 171 static int |
172 lookup_pref_assign_conv (int t_lhs, int t_rhs) | |
173 { | |
174 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs); | |
175 } | |
176 | |
5759 | 177 static octave_base_value::type_conv_fcn |
4901 | 178 lookup_type_conv_op (int t, int t_result) |
179 { | |
180 return instance->do_lookup_type_conv_op (t, t_result); | |
181 } | |
182 | |
5759 | 183 static octave_base_value::type_conv_fcn |
2376 | 184 lookup_widening_op (int t, int t_result) |
185 { | |
186 return instance->do_lookup_widening_op (t, t_result); | |
187 } | |
188 | |
189 static string_vector installed_type_names (void) | |
190 { | |
191 return instance->do_installed_type_names (); | |
192 } | |
193 | |
194 protected: | |
195 | |
196 octave_value_typeinfo (void) | |
3523 | 197 : num_types (0), types (init_tab_sz, std::string ()), |
4645 | 198 vals (init_tab_sz), |
7336 | 199 unary_class_ops (octave_value::num_unary_ops, 0), |
5760 | 200 unary_ops (octave_value::num_unary_ops, init_tab_sz, 0), |
201 non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, 0), | |
7336 | 202 binary_class_ops (octave_value::num_binary_ops, 0), |
5760 | 203 binary_ops (octave_value::num_binary_ops, init_tab_sz, init_tab_sz, 0), |
204 cat_ops (init_tab_sz, init_tab_sz, 0), | |
205 assign_ops (octave_value::num_assign_ops, init_tab_sz, init_tab_sz, 0), | |
206 assignany_ops (octave_value::num_assign_ops, init_tab_sz, 0), | |
2479 | 207 pref_assign_conv (init_tab_sz, init_tab_sz, -1), |
5760 | 208 type_conv_ops (init_tab_sz, init_tab_sz, 0), |
209 widening_ops (init_tab_sz, init_tab_sz, 0) { } | |
2376 | 210 |
211 private: | |
212 | |
2479 | 213 static const int init_tab_sz; |
214 | |
2376 | 215 static octave_value_typeinfo *instance; |
216 | |
217 int num_types; | |
218 | |
3523 | 219 Array<std::string> types; |
2376 | 220 |
4640 | 221 Array<octave_value> vals; |
222 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
223 Array<void *> unary_class_ops; |
7336 | 224 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
225 Array2<void *> unary_ops; |
3203 | 226 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
227 Array2<void *> non_const_unary_ops; |
3203 | 228 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
229 Array<void *> binary_class_ops; |
7336 | 230 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
231 Array3<void *> binary_ops; |
2376 | 232 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
233 Array<void *> compound_binary_class_ops; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
234 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
235 Array3<void *> compound_binary_ops; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
236 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
237 Array2<void *> cat_ops; |
4915 | 238 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
239 Array3<void *> assign_ops; |
2376 | 240 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
241 Array2<void *> assignany_ops; |
3196 | 242 |
2376 | 243 Array2<int> pref_assign_conv; |
244 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
245 Array2<void *> type_conv_ops; |
4901 | 246 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
247 Array2<void *> widening_ops; |
2376 | 248 |
4640 | 249 int do_register_type (const std::string&, const std::string&, |
250 const octave_value&); | |
2376 | 251 |
7336 | 252 bool do_register_unary_class_op (octave_value::unary_op, unary_class_op_fcn); |
253 | |
3203 | 254 bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
255 | |
256 bool do_register_non_const_unary_op (octave_value::unary_op, int, | |
257 non_const_unary_op_fcn); | |
258 | |
7336 | 259 bool do_register_binary_class_op (octave_value::binary_op, |
260 binary_class_op_fcn); | |
261 | |
2376 | 262 bool do_register_binary_op (octave_value::binary_op, int, int, |
2427 | 263 binary_op_fcn); |
2376 | 264 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
265 bool do_register_binary_class_op (octave_value::compound_binary_op, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
266 binary_class_op_fcn); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
267 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
268 bool do_register_binary_op (octave_value::compound_binary_op, int, int, |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
269 binary_op_fcn); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
270 |
4915 | 271 bool do_register_cat_op (int, int, cat_op_fcn); |
272 | |
2882 | 273 bool do_register_assign_op (octave_value::assign_op, int, int, |
274 assign_op_fcn); | |
2376 | 275 |
3196 | 276 bool do_register_assignany_op (octave_value::assign_op, int, |
5759 | 277 assignany_op_fcn); |
3196 | 278 |
2376 | 279 bool do_register_pref_assign_conv (int, int, int); |
280 | |
5759 | 281 bool do_register_type_conv_op (int, int, octave_base_value::type_conv_fcn); |
4901 | 282 |
5759 | 283 bool do_register_widening_op (int, int, octave_base_value::type_conv_fcn); |
2376 | 284 |
4640 | 285 octave_value do_lookup_type (const std::string& nm); |
286 | |
7336 | 287 unary_class_op_fcn do_lookup_unary_class_op (octave_value::unary_op); |
288 | |
3203 | 289 unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int); |
290 | |
291 non_const_unary_op_fcn do_lookup_non_const_unary_op | |
292 (octave_value::unary_op, int); | |
2376 | 293 |
7336 | 294 binary_class_op_fcn do_lookup_binary_class_op (octave_value::binary_op); |
295 | |
3203 | 296 binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int); |
2376 | 297 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
298 binary_class_op_fcn do_lookup_binary_class_op (octave_value::compound_binary_op); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
299 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
300 binary_op_fcn do_lookup_binary_op (octave_value::compound_binary_op, int, int); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7336
diff
changeset
|
301 |
4915 | 302 cat_op_fcn do_lookup_cat_op (int, int); |
303 | |
3203 | 304 assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int); |
305 | |
5759 | 306 assignany_op_fcn do_lookup_assignany_op (octave_value::assign_op, int); |
3196 | 307 |
2376 | 308 int do_lookup_pref_assign_conv (int, int); |
309 | |
5759 | 310 octave_base_value::type_conv_fcn do_lookup_type_conv_op (int, int); |
4901 | 311 |
5759 | 312 octave_base_value::type_conv_fcn do_lookup_widening_op (int, int); |
2376 | 313 |
314 string_vector do_installed_type_names (void); | |
315 | |
316 // No copying! | |
317 | |
318 octave_value_typeinfo (const octave_value_typeinfo&); | |
319 | |
320 octave_value_typeinfo& operator = (const octave_value_typeinfo&); | |
321 }; | |
322 | |
323 #endif | |
324 | |
325 /* | |
6705 | 326 ;;; Local Variables: *** |
327 ;;; mode: C++ *** | |
328 ;;; End: *** | |
2376 | 329 */ |