Mercurial > hg > octave-nkf
annotate src/ov-typeinfo.h @ 10809:85cbd239fce2
try a better status bar for fltk backend
author | Shai Ayal <shaiay@users.sourceforge.net> |
---|---|
date | Tue, 20 Jul 2010 19:31:17 +0300 |
parents | 4217a5402b7e |
children | fd0a3ac60b0e |
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 "Array3.h" | |
31 | |
32 #include "ov.h" | |
33 | |
34 class string_vector; | |
35 | |
36 class | |
6109 | 37 OCTINTERP_API |
2376 | 38 octave_value_typeinfo |
39 { | |
40 public: | |
41 | |
7336 | 42 typedef octave_value (*unary_class_op_fcn) (const octave_value&); |
43 | |
5759 | 44 typedef octave_value (*unary_op_fcn) (const octave_base_value&); |
45 | |
46 typedef void (*non_const_unary_op_fcn) (octave_base_value&); | |
47 | |
7336 | 48 typedef octave_value (*binary_class_op_fcn) |
49 (const octave_value&, const octave_value&); | |
50 | |
5759 | 51 typedef octave_value (*binary_op_fcn) |
52 (const octave_base_value&, const octave_base_value&); | |
53 | |
54 typedef octave_value (*cat_op_fcn) | |
6906 | 55 (octave_base_value&, const octave_base_value&, const Array<octave_idx_type>& ra_idx); |
5759 | 56 |
57 typedef octave_value (*assign_op_fcn) | |
58 (octave_base_value&, const octave_value_list&, const octave_base_value&); | |
59 | |
60 typedef octave_value (*assignany_op_fcn) | |
61 (octave_base_value&, const octave_value_list&, const octave_value&); | |
62 | |
2926 | 63 static bool instance_ok (void); |
64 | |
4640 | 65 static int register_type (const std::string&, const std::string&, |
10313 | 66 const octave_value&); |
2376 | 67 |
7336 | 68 static bool register_unary_class_op (octave_value::unary_op, |
10313 | 69 unary_class_op_fcn); |
7336 | 70 |
3203 | 71 static bool register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
72 | |
73 static bool register_non_const_unary_op (octave_value::unary_op, int, | |
10313 | 74 non_const_unary_op_fcn); |
3203 | 75 |
7336 | 76 static bool register_binary_class_op (octave_value::binary_op, |
10313 | 77 binary_class_op_fcn); |
7336 | 78 |
2376 | 79 static bool register_binary_op (octave_value::binary_op, int, int, |
10313 | 80 binary_op_fcn); |
2376 | 81 |
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
|
82 static bool register_binary_class_op (octave_value::compound_binary_op, |
10313 | 83 binary_class_op_fcn); |
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
|
84 |
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 static bool register_binary_op (octave_value::compound_binary_op, int, int, |
10313 | 86 binary_op_fcn); |
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
|
87 |
4915 | 88 static bool register_cat_op (int, int, cat_op_fcn); |
89 | |
2882 | 90 static bool register_assign_op (octave_value::assign_op, int, int, |
10313 | 91 assign_op_fcn); |
2376 | 92 |
3196 | 93 static bool register_assignany_op (octave_value::assign_op, int, |
10313 | 94 assignany_op_fcn); |
3196 | 95 |
2376 | 96 static bool register_pref_assign_conv (int, int, int); |
97 | |
5759 | 98 static bool |
99 register_type_conv_op (int, int, octave_base_value::type_conv_fcn); | |
4901 | 100 |
5759 | 101 static bool |
102 register_widening_op (int, int, octave_base_value::type_conv_fcn); | |
2376 | 103 |
4640 | 104 static octave_value |
105 lookup_type (const std::string& nm) | |
106 { | |
107 return instance->do_lookup_type (nm); | |
108 } | |
109 | |
7336 | 110 static unary_class_op_fcn |
111 lookup_unary_class_op (octave_value::unary_op op) | |
112 { | |
113 return instance->do_lookup_unary_class_op (op); | |
114 } | |
115 | |
3203 | 116 static unary_op_fcn |
117 lookup_unary_op (octave_value::unary_op op, int t) | |
118 { | |
119 return instance->do_lookup_unary_op (op, t); | |
120 } | |
121 | |
122 static non_const_unary_op_fcn | |
123 lookup_non_const_unary_op (octave_value::unary_op op, int t) | |
124 { | |
125 return instance->do_lookup_non_const_unary_op (op, t); | |
126 } | |
127 | |
7336 | 128 static binary_class_op_fcn |
129 lookup_binary_class_op (octave_value::binary_op op) | |
130 { | |
131 return instance->do_lookup_binary_class_op (op); | |
132 } | |
133 | |
2427 | 134 static binary_op_fcn |
2376 | 135 lookup_binary_op (octave_value::binary_op op, int t1, int t2) |
136 { | |
137 return instance->do_lookup_binary_op (op, t1, t2); | |
138 } | |
139 | |
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
|
140 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
|
141 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
|
142 { |
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 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
|
144 } |
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 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
|
147 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
|
148 { |
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 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
|
150 } |
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 |
4915 | 152 static cat_op_fcn |
153 lookup_cat_op (int t1, int t2) | |
154 { | |
155 return instance->do_lookup_cat_op (t1, t2); | |
156 } | |
157 | |
2427 | 158 static assign_op_fcn |
2882 | 159 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs) |
2376 | 160 { |
2882 | 161 return instance->do_lookup_assign_op (op, t_lhs, t_rhs); |
2376 | 162 } |
163 | |
5759 | 164 static assignany_op_fcn |
3196 | 165 lookup_assignany_op (octave_value::assign_op op, int t_lhs) |
166 { | |
167 return instance->do_lookup_assignany_op (op, t_lhs); | |
168 } | |
169 | |
2376 | 170 static int |
171 lookup_pref_assign_conv (int t_lhs, int t_rhs) | |
172 { | |
173 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs); | |
174 } | |
175 | |
5759 | 176 static octave_base_value::type_conv_fcn |
4901 | 177 lookup_type_conv_op (int t, int t_result) |
178 { | |
179 return instance->do_lookup_type_conv_op (t, t_result); | |
180 } | |
181 | |
5759 | 182 static octave_base_value::type_conv_fcn |
2376 | 183 lookup_widening_op (int t, int t_result) |
184 { | |
185 return instance->do_lookup_widening_op (t, t_result); | |
186 } | |
187 | |
188 static string_vector installed_type_names (void) | |
189 { | |
190 return instance->do_installed_type_names (); | |
191 } | |
192 | |
193 protected: | |
194 | |
195 octave_value_typeinfo (void) | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
196 : num_types (0), types (init_tab_sz, 1, std::string ()), |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
197 vals (init_tab_sz, 1), |
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
198 unary_class_ops (octave_value::num_unary_ops, 1, 0), |
5760 | 199 unary_ops (octave_value::num_unary_ops, init_tab_sz, 0), |
200 non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, 0), | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
201 binary_class_ops (octave_value::num_binary_ops, 1, 0), |
5760 | 202 binary_ops (octave_value::num_binary_ops, init_tab_sz, init_tab_sz, 0), |
10375
4217a5402b7e
add missing initializers in octave_typeinfo ctor
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
203 compound_binary_class_ops (octave_value::num_compound_binary_ops, 1, 0), |
4217a5402b7e
add missing initializers in octave_typeinfo ctor
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
204 compound_binary_ops (octave_value::num_compound_binary_ops, init_tab_sz, init_tab_sz, 0), |
5760 | 205 cat_ops (init_tab_sz, init_tab_sz, 0), |
206 assign_ops (octave_value::num_assign_ops, init_tab_sz, init_tab_sz, 0), | |
207 assignany_ops (octave_value::num_assign_ops, init_tab_sz, 0), | |
2479 | 208 pref_assign_conv (init_tab_sz, init_tab_sz, -1), |
5760 | 209 type_conv_ops (init_tab_sz, init_tab_sz, 0), |
210 widening_ops (init_tab_sz, init_tab_sz, 0) { } | |
2376 | 211 |
212 private: | |
213 | |
2479 | 214 static const int init_tab_sz; |
215 | |
2376 | 216 static octave_value_typeinfo *instance; |
217 | |
218 int num_types; | |
219 | |
3523 | 220 Array<std::string> types; |
2376 | 221 |
4640 | 222 Array<octave_value> vals; |
223 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
224 Array<void *> unary_class_ops; |
7336 | 225 |
10352 | 226 Array<void *> unary_ops; |
3203 | 227 |
10352 | 228 Array<void *> non_const_unary_ops; |
3203 | 229 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
230 Array<void *> binary_class_ops; |
7336 | 231 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
232 Array3<void *> binary_ops; |
2376 | 233 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
234 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
|
235 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
236 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
|
237 |
10352 | 238 Array<void *> cat_ops; |
4915 | 239 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
240 Array3<void *> assign_ops; |
2376 | 241 |
10352 | 242 Array<void *> assignany_ops; |
3196 | 243 |
10352 | 244 Array<int> pref_assign_conv; |
2376 | 245 |
10352 | 246 Array<void *> type_conv_ops; |
4901 | 247 |
10352 | 248 Array<void *> widening_ops; |
2376 | 249 |
4640 | 250 int do_register_type (const std::string&, const std::string&, |
10313 | 251 const octave_value&); |
2376 | 252 |
7336 | 253 bool do_register_unary_class_op (octave_value::unary_op, unary_class_op_fcn); |
254 | |
3203 | 255 bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
256 | |
257 bool do_register_non_const_unary_op (octave_value::unary_op, int, | |
10313 | 258 non_const_unary_op_fcn); |
3203 | 259 |
7336 | 260 bool do_register_binary_class_op (octave_value::binary_op, |
10313 | 261 binary_class_op_fcn); |
7336 | 262 |
2376 | 263 bool do_register_binary_op (octave_value::binary_op, int, int, |
10313 | 264 binary_op_fcn); |
2376 | 265 |
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
|
266 bool do_register_binary_class_op (octave_value::compound_binary_op, |
10313 | 267 binary_class_op_fcn); |
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
|
268 |
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 bool do_register_binary_op (octave_value::compound_binary_op, int, int, |
10313 | 270 binary_op_fcn); |
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
|
271 |
4915 | 272 bool do_register_cat_op (int, int, cat_op_fcn); |
273 | |
2882 | 274 bool do_register_assign_op (octave_value::assign_op, int, int, |
10313 | 275 assign_op_fcn); |
2376 | 276 |
3196 | 277 bool do_register_assignany_op (octave_value::assign_op, int, |
10313 | 278 assignany_op_fcn); |
3196 | 279 |
2376 | 280 bool do_register_pref_assign_conv (int, int, int); |
281 | |
5759 | 282 bool do_register_type_conv_op (int, int, octave_base_value::type_conv_fcn); |
4901 | 283 |
5759 | 284 bool do_register_widening_op (int, int, octave_base_value::type_conv_fcn); |
2376 | 285 |
4640 | 286 octave_value do_lookup_type (const std::string& nm); |
287 | |
7336 | 288 unary_class_op_fcn do_lookup_unary_class_op (octave_value::unary_op); |
289 | |
3203 | 290 unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int); |
291 | |
292 non_const_unary_op_fcn do_lookup_non_const_unary_op | |
293 (octave_value::unary_op, int); | |
2376 | 294 |
7336 | 295 binary_class_op_fcn do_lookup_binary_class_op (octave_value::binary_op); |
296 | |
3203 | 297 binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int); |
2376 | 298 |
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
|
299 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
|
300 |
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 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
|
302 |
4915 | 303 cat_op_fcn do_lookup_cat_op (int, int); |
304 | |
3203 | 305 assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int); |
306 | |
5759 | 307 assignany_op_fcn do_lookup_assignany_op (octave_value::assign_op, int); |
3196 | 308 |
2376 | 309 int do_lookup_pref_assign_conv (int, int); |
310 | |
5759 | 311 octave_base_value::type_conv_fcn do_lookup_type_conv_op (int, int); |
4901 | 312 |
5759 | 313 octave_base_value::type_conv_fcn do_lookup_widening_op (int, int); |
2376 | 314 |
315 string_vector do_installed_type_names (void); | |
316 | |
317 // No copying! | |
318 | |
319 octave_value_typeinfo (const octave_value_typeinfo&); | |
320 | |
321 octave_value_typeinfo& operator = (const octave_value_typeinfo&); | |
322 }; | |
323 | |
324 #endif |