Mercurial > hg > octave-nkf
comparison src/ov-typeinfo.cc @ 5759:ce79d238f142
[project @ 2006-04-13 13:04:32 by jwe]
author | jwe |
---|---|
date | Thu, 13 Apr 2006 13:04:33 +0000 |
parents | 4c8a2e4e0717 |
children | ace8d8d26933 |
comparison
equal
deleted
inserted
replaced
5758:65208d959bf1 | 5759:ce79d238f142 |
---|---|
41 #include <Array2.h> | 41 #include <Array2.h> |
42 #include <Array3.h> | 42 #include <Array3.h> |
43 | 43 |
44 #include <Array.cc> | 44 #include <Array.cc> |
45 | 45 |
46 INSTANTIATE_ARRAY (unary_op_fcn); | 46 INSTANTIATE_ARRAY (octave_value_typeinfo::unary_op_fcn); |
47 template class Array2<unary_op_fcn>; | 47 template class Array2<octave_value_typeinfo::unary_op_fcn>; |
48 | 48 |
49 INSTANTIATE_ARRAY (non_const_unary_op_fcn); | 49 INSTANTIATE_ARRAY (octave_value_typeinfo::non_const_unary_op_fcn); |
50 template class Array2<non_const_unary_op_fcn>; | 50 template class Array2<octave_value_typeinfo::non_const_unary_op_fcn>; |
51 | 51 |
52 INSTANTIATE_ARRAY (binary_op_fcn); | 52 INSTANTIATE_ARRAY (octave_value_typeinfo::binary_op_fcn); |
53 template class Array2<binary_op_fcn>; | 53 template class Array2<octave_value_typeinfo::binary_op_fcn>; |
54 template class Array3<binary_op_fcn>; | 54 template class Array3<octave_value_typeinfo::binary_op_fcn>; |
55 | 55 |
56 INSTANTIATE_ARRAY (cat_op_fcn); | 56 INSTANTIATE_ARRAY (octave_value_typeinfo::cat_op_fcn); |
57 template class Array2<cat_op_fcn>; | 57 template class Array2<octave_value_typeinfo::cat_op_fcn>; |
58 | 58 |
59 INSTANTIATE_ARRAY (assign_op_fcn); | 59 INSTANTIATE_ARRAY (octave_value_typeinfo::assign_op_fcn); |
60 template class Array2<assign_op_fcn>; | 60 template class Array2<octave_value_typeinfo::assign_op_fcn>; |
61 template class Array3<assign_op_fcn>; | 61 template class Array3<octave_value_typeinfo::assign_op_fcn>; |
62 | 62 |
63 INSTANTIATE_ARRAY (type_conv_fcn); | 63 INSTANTIATE_ARRAY (octave_base_value::type_conv_fcn); |
64 template class Array2<type_conv_fcn>; | 64 template class Array2<octave_base_value::type_conv_fcn>; |
65 | 65 |
66 bool | 66 bool |
67 octave_value_typeinfo::instance_ok (void) | 67 octave_value_typeinfo::instance_ok (void) |
68 { | 68 { |
69 bool retval = true; | 69 bool retval = true; |
89 ? instance->do_register_type (t_name, c_name, val) : -1; | 89 ? instance->do_register_type (t_name, c_name, val) : -1; |
90 } | 90 } |
91 | 91 |
92 bool | 92 bool |
93 octave_value_typeinfo::register_unary_op (octave_value::unary_op op, | 93 octave_value_typeinfo::register_unary_op (octave_value::unary_op op, |
94 int t, unary_op_fcn f) | 94 int t, octave_value_typeinfo::unary_op_fcn f) |
95 { | 95 { |
96 return (instance_ok ()) | 96 return (instance_ok ()) |
97 ? instance->do_register_unary_op (op, t, f) : false; | 97 ? instance->do_register_unary_op (op, t, f) : false; |
98 } | 98 } |
99 | 99 |
100 bool | 100 bool |
101 octave_value_typeinfo::register_non_const_unary_op (octave_value::unary_op op, | 101 octave_value_typeinfo::register_non_const_unary_op (octave_value::unary_op op, |
102 int t, | 102 int t, |
103 non_const_unary_op_fcn f) | 103 octave_value_typeinfo::non_const_unary_op_fcn f) |
104 { | 104 { |
105 return (instance_ok ()) | 105 return (instance_ok ()) |
106 ? instance->do_register_non_const_unary_op (op, t, f) : false; | 106 ? instance->do_register_non_const_unary_op (op, t, f) : false; |
107 } | 107 } |
108 | 108 |
109 bool | 109 bool |
110 octave_value_typeinfo::register_binary_op (octave_value::binary_op op, | 110 octave_value_typeinfo::register_binary_op (octave_value::binary_op op, |
111 int t1, int t2, | 111 int t1, int t2, |
112 binary_op_fcn f) | 112 octave_value_typeinfo::binary_op_fcn f) |
113 { | 113 { |
114 return (instance_ok ()) | 114 return (instance_ok ()) |
115 ? instance->do_register_binary_op (op, t1, t2, f) : false; | 115 ? instance->do_register_binary_op (op, t1, t2, f) : false; |
116 } | 116 } |
117 | 117 |
118 bool | 118 bool |
119 octave_value_typeinfo::register_cat_op (int t1, int t2, cat_op_fcn f) | 119 octave_value_typeinfo::register_cat_op (int t1, int t2, octave_value_typeinfo::cat_op_fcn f) |
120 { | 120 { |
121 return (instance_ok ()) | 121 return (instance_ok ()) |
122 ? instance->do_register_cat_op (t1, t2, f) : false; | 122 ? instance->do_register_cat_op (t1, t2, f) : false; |
123 } | 123 } |
124 | 124 |
125 bool | 125 bool |
126 octave_value_typeinfo::register_assign_op (octave_value::assign_op op, | 126 octave_value_typeinfo::register_assign_op (octave_value::assign_op op, |
127 int t_lhs, int t_rhs, | 127 int t_lhs, int t_rhs, |
128 assign_op_fcn f) | 128 octave_value_typeinfo::assign_op_fcn f) |
129 { | 129 { |
130 return (instance_ok ()) | 130 return (instance_ok ()) |
131 ? instance->do_register_assign_op (op, t_lhs, t_rhs, f) : -1; | 131 ? instance->do_register_assign_op (op, t_lhs, t_rhs, f) : -1; |
132 } | 132 } |
133 | 133 |
134 bool | 134 bool |
135 octave_value_typeinfo::register_assignany_op (octave_value::assign_op op, | 135 octave_value_typeinfo::register_assignany_op (octave_value::assign_op op, |
136 int t_lhs, assign_op_fcn f) | 136 int t_lhs, octave_value_typeinfo::assignany_op_fcn f) |
137 { | 137 { |
138 return (instance_ok ()) | 138 return (instance_ok ()) |
139 ? instance->do_register_assignany_op (op, t_lhs, f) : -1; | 139 ? instance->do_register_assignany_op (op, t_lhs, f) : -1; |
140 } | 140 } |
141 | 141 |
147 ? instance->do_register_pref_assign_conv (t_lhs, t_rhs, t_result) : false; | 147 ? instance->do_register_pref_assign_conv (t_lhs, t_rhs, t_result) : false; |
148 } | 148 } |
149 | 149 |
150 bool | 150 bool |
151 octave_value_typeinfo::register_type_conv_op (int t, int t_result, | 151 octave_value_typeinfo::register_type_conv_op (int t, int t_result, |
152 type_conv_fcn f) | 152 octave_base_value::type_conv_fcn f) |
153 { | 153 { |
154 return (instance_ok ()) | 154 return (instance_ok ()) |
155 ? instance->do_register_type_conv_op (t, t_result, f) : false; | 155 ? instance->do_register_type_conv_op (t, t_result, f) : false; |
156 } | 156 } |
157 | 157 |
158 bool | 158 bool |
159 octave_value_typeinfo::register_widening_op (int t, int t_result, | 159 octave_value_typeinfo::register_widening_op (int t, int t_result, |
160 type_conv_fcn f) | 160 octave_base_value::type_conv_fcn f) |
161 { | 161 { |
162 return (instance_ok ()) | 162 return (instance_ok ()) |
163 ? instance->do_register_widening_op (t, t_result, f) : false; | 163 ? instance->do_register_widening_op (t, t_result, f) : false; |
164 } | 164 } |
165 | 165 |
186 types.resize (len, std::string ()); | 186 types.resize (len, std::string ()); |
187 | 187 |
188 vals.resize (len, octave_value ()); | 188 vals.resize (len, octave_value ()); |
189 | 189 |
190 unary_ops.resize (static_cast<int> (octave_value::num_unary_ops), | 190 unary_ops.resize (static_cast<int> (octave_value::num_unary_ops), |
191 len, static_cast<unary_op_fcn> (0)); | 191 len, static_cast<octave_value_typeinfo::unary_op_fcn> (0)); |
192 | 192 |
193 non_const_unary_ops.resize | 193 non_const_unary_ops.resize |
194 (static_cast<int> (octave_value::num_unary_ops), | 194 (static_cast<int> (octave_value::num_unary_ops), |
195 len, static_cast<non_const_unary_op_fcn> (0)); | 195 len, static_cast<octave_value_typeinfo::non_const_unary_op_fcn> (0)); |
196 | 196 |
197 binary_ops.resize (static_cast<int> (octave_value::num_binary_ops), | 197 binary_ops.resize (static_cast<int> (octave_value::num_binary_ops), |
198 len, len, static_cast<binary_op_fcn> (0)); | 198 len, len, static_cast<octave_value_typeinfo::binary_op_fcn> (0)); |
199 | 199 |
200 cat_ops.resize (len, len, static_cast<cat_op_fcn> (0)); | 200 cat_ops.resize (len, len, static_cast<octave_value_typeinfo::cat_op_fcn> (0)); |
201 | 201 |
202 assign_ops.resize (static_cast<int> (octave_value::num_assign_ops), | 202 assign_ops.resize (static_cast<int> (octave_value::num_assign_ops), |
203 len, len, static_cast<assign_op_fcn> (0)); | 203 len, len, static_cast<octave_value_typeinfo::assign_op_fcn> (0)); |
204 | 204 |
205 assignany_ops.resize (static_cast<int> (octave_value::num_assign_ops), | 205 assignany_ops.resize (static_cast<int> (octave_value::num_assign_ops), |
206 len, static_cast<assign_op_fcn> (0)); | 206 len, static_cast<octave_value_typeinfo::assignany_op_fcn> (0)); |
207 | 207 |
208 pref_assign_conv.resize (len, len, -1); | 208 pref_assign_conv.resize (len, len, -1); |
209 | 209 |
210 type_conv_ops.resize (len, len, static_cast<type_conv_fcn> (0)); | 210 type_conv_ops.resize (len, len, static_cast<octave_base_value::type_conv_fcn> (0)); |
211 | 211 |
212 widening_ops.resize (len, len, static_cast<type_conv_fcn> (0)); | 212 widening_ops.resize (len, len, static_cast<octave_base_value::type_conv_fcn> (0)); |
213 } | 213 } |
214 | 214 |
215 types (i) = t_name; | 215 types (i) = t_name; |
216 | 216 |
217 vals (i) = val; | 217 vals (i) = val; |
221 return i; | 221 return i; |
222 } | 222 } |
223 | 223 |
224 bool | 224 bool |
225 octave_value_typeinfo::do_register_unary_op (octave_value::unary_op op, | 225 octave_value_typeinfo::do_register_unary_op (octave_value::unary_op op, |
226 int t, unary_op_fcn f) | 226 int t, octave_value_typeinfo::unary_op_fcn f) |
227 { | 227 { |
228 if (lookup_unary_op (op, t)) | 228 if (lookup_unary_op (op, t)) |
229 { | 229 { |
230 std::string op_name = octave_value::unary_op_as_string (op); | 230 std::string op_name = octave_value::unary_op_as_string (op); |
231 std::string type_name = types(t); | 231 std::string type_name = types(t); |
239 return false; | 239 return false; |
240 } | 240 } |
241 | 241 |
242 bool | 242 bool |
243 octave_value_typeinfo::do_register_non_const_unary_op | 243 octave_value_typeinfo::do_register_non_const_unary_op |
244 (octave_value::unary_op op, int t, non_const_unary_op_fcn f) | 244 (octave_value::unary_op op, int t, octave_value_typeinfo::non_const_unary_op_fcn f) |
245 { | 245 { |
246 if (lookup_non_const_unary_op (op, t)) | 246 if (lookup_non_const_unary_op (op, t)) |
247 { | 247 { |
248 std::string op_name = octave_value::unary_op_as_string (op); | 248 std::string op_name = octave_value::unary_op_as_string (op); |
249 std::string type_name = types(t); | 249 std::string type_name = types(t); |
258 } | 258 } |
259 | 259 |
260 bool | 260 bool |
261 octave_value_typeinfo::do_register_binary_op (octave_value::binary_op op, | 261 octave_value_typeinfo::do_register_binary_op (octave_value::binary_op op, |
262 int t1, int t2, | 262 int t1, int t2, |
263 binary_op_fcn f) | 263 octave_value_typeinfo::binary_op_fcn f) |
264 { | 264 { |
265 if (lookup_binary_op (op, t1, t2)) | 265 if (lookup_binary_op (op, t1, t2)) |
266 { | 266 { |
267 std::string op_name = octave_value::binary_op_as_string (op); | 267 std::string op_name = octave_value::binary_op_as_string (op); |
268 std::string t1_name = types(t1); | 268 std::string t1_name = types(t1); |
276 | 276 |
277 return false; | 277 return false; |
278 } | 278 } |
279 | 279 |
280 bool | 280 bool |
281 octave_value_typeinfo::do_register_cat_op (int t1, int t2, cat_op_fcn f) | 281 octave_value_typeinfo::do_register_cat_op (int t1, int t2, octave_value_typeinfo::cat_op_fcn f) |
282 { | 282 { |
283 if (lookup_cat_op (t1, t2)) | 283 if (lookup_cat_op (t1, t2)) |
284 { | 284 { |
285 std::string t1_name = types(t1); | 285 std::string t1_name = types(t1); |
286 std::string t2_name = types(t2); | 286 std::string t2_name = types(t2); |
295 } | 295 } |
296 | 296 |
297 bool | 297 bool |
298 octave_value_typeinfo::do_register_assign_op (octave_value::assign_op op, | 298 octave_value_typeinfo::do_register_assign_op (octave_value::assign_op op, |
299 int t_lhs, int t_rhs, | 299 int t_lhs, int t_rhs, |
300 assign_op_fcn f) | 300 octave_value_typeinfo::assign_op_fcn f) |
301 { | 301 { |
302 if (lookup_assign_op (op, t_lhs, t_rhs)) | 302 if (lookup_assign_op (op, t_lhs, t_rhs)) |
303 { | 303 { |
304 std::string op_name = octave_value::assign_op_as_string (op); | 304 std::string op_name = octave_value::assign_op_as_string (op); |
305 std::string t_lhs_name = types(t_lhs); | 305 std::string t_lhs_name = types(t_lhs); |
314 return false; | 314 return false; |
315 } | 315 } |
316 | 316 |
317 bool | 317 bool |
318 octave_value_typeinfo::do_register_assignany_op (octave_value::assign_op op, | 318 octave_value_typeinfo::do_register_assignany_op (octave_value::assign_op op, |
319 int t_lhs, assign_op_fcn f) | 319 int t_lhs, octave_value_typeinfo::assignany_op_fcn f) |
320 { | 320 { |
321 if (lookup_assignany_op (op, t_lhs)) | 321 if (lookup_assignany_op (op, t_lhs)) |
322 { | 322 { |
323 std::string op_name = octave_value::assign_op_as_string (op); | 323 std::string op_name = octave_value::assign_op_as_string (op); |
324 std::string t_lhs_name = types(t_lhs); | 324 std::string t_lhs_name = types(t_lhs); |
350 return false; | 350 return false; |
351 } | 351 } |
352 | 352 |
353 bool | 353 bool |
354 octave_value_typeinfo::do_register_type_conv_op | 354 octave_value_typeinfo::do_register_type_conv_op |
355 (int t, int t_result, type_conv_fcn f) | 355 (int t, int t_result, octave_base_value::type_conv_fcn f) |
356 { | 356 { |
357 if (lookup_type_conv_op (t, t_result)) | 357 if (lookup_type_conv_op (t, t_result)) |
358 { | 358 { |
359 std::string t_name = types(t); | 359 std::string t_name = types(t); |
360 std::string t_result_name = types(t_result); | 360 std::string t_result_name = types(t_result); |
368 return false; | 368 return false; |
369 } | 369 } |
370 | 370 |
371 bool | 371 bool |
372 octave_value_typeinfo::do_register_widening_op | 372 octave_value_typeinfo::do_register_widening_op |
373 (int t, int t_result, type_conv_fcn f) | 373 (int t, int t_result, octave_base_value::type_conv_fcn f) |
374 { | 374 { |
375 if (lookup_widening_op (t, t_result)) | 375 if (lookup_widening_op (t, t_result)) |
376 { | 376 { |
377 std::string t_name = types(t); | 377 std::string t_name = types(t); |
378 std::string t_result_name = types(t_result); | 378 std::string t_result_name = types(t_result); |
402 } | 402 } |
403 | 403 |
404 return retval; | 404 return retval; |
405 } | 405 } |
406 | 406 |
407 unary_op_fcn | 407 octave_value_typeinfo::unary_op_fcn |
408 octave_value_typeinfo::do_lookup_unary_op (octave_value::unary_op op, int t) | 408 octave_value_typeinfo::do_lookup_unary_op (octave_value::unary_op op, int t) |
409 { | 409 { |
410 return unary_ops.checkelem (static_cast<int> (op), t); | 410 return unary_ops.checkelem (static_cast<int> (op), t); |
411 } | 411 } |
412 | 412 |
413 non_const_unary_op_fcn | 413 octave_value_typeinfo::non_const_unary_op_fcn |
414 octave_value_typeinfo::do_lookup_non_const_unary_op | 414 octave_value_typeinfo::do_lookup_non_const_unary_op |
415 (octave_value::unary_op op, int t) | 415 (octave_value::unary_op op, int t) |
416 { | 416 { |
417 return non_const_unary_ops.checkelem (static_cast<int> (op), t); | 417 return non_const_unary_ops.checkelem (static_cast<int> (op), t); |
418 } | 418 } |
419 | 419 |
420 binary_op_fcn | 420 octave_value_typeinfo::binary_op_fcn |
421 octave_value_typeinfo::do_lookup_binary_op (octave_value::binary_op op, | 421 octave_value_typeinfo::do_lookup_binary_op (octave_value::binary_op op, |
422 int t1, int t2) | 422 int t1, int t2) |
423 { | 423 { |
424 return binary_ops.checkelem (static_cast<int> (op), t1, t2); | 424 return binary_ops.checkelem (static_cast<int> (op), t1, t2); |
425 } | 425 } |
426 | 426 |
427 cat_op_fcn | 427 octave_value_typeinfo::cat_op_fcn |
428 octave_value_typeinfo::do_lookup_cat_op (int t1, int t2) | 428 octave_value_typeinfo::do_lookup_cat_op (int t1, int t2) |
429 { | 429 { |
430 return cat_ops.checkelem (t1, t2); | 430 return cat_ops.checkelem (t1, t2); |
431 } | 431 } |
432 | 432 |
433 assign_op_fcn | 433 octave_value_typeinfo::assign_op_fcn |
434 octave_value_typeinfo::do_lookup_assign_op (octave_value::assign_op op, | 434 octave_value_typeinfo::do_lookup_assign_op (octave_value::assign_op op, |
435 int t_lhs, int t_rhs) | 435 int t_lhs, int t_rhs) |
436 { | 436 { |
437 return assign_ops.checkelem (static_cast<int> (op), t_lhs, t_rhs); | 437 return assign_ops.checkelem (static_cast<int> (op), t_lhs, t_rhs); |
438 } | 438 } |
439 | 439 |
440 assign_op_fcn | 440 octave_value_typeinfo::assignany_op_fcn |
441 octave_value_typeinfo::do_lookup_assignany_op (octave_value::assign_op op, | 441 octave_value_typeinfo::do_lookup_assignany_op (octave_value::assign_op op, |
442 int t_lhs) | 442 int t_lhs) |
443 { | 443 { |
444 return assignany_ops.checkelem (static_cast<int> (op), t_lhs); | 444 return assignany_ops.checkelem (static_cast<int> (op), t_lhs); |
445 } | 445 } |
448 octave_value_typeinfo::do_lookup_pref_assign_conv (int t_lhs, int t_rhs) | 448 octave_value_typeinfo::do_lookup_pref_assign_conv (int t_lhs, int t_rhs) |
449 { | 449 { |
450 return pref_assign_conv.checkelem (t_lhs, t_rhs); | 450 return pref_assign_conv.checkelem (t_lhs, t_rhs); |
451 } | 451 } |
452 | 452 |
453 type_conv_fcn | 453 octave_base_value::type_conv_fcn |
454 octave_value_typeinfo::do_lookup_type_conv_op (int t, int t_result) | 454 octave_value_typeinfo::do_lookup_type_conv_op (int t, int t_result) |
455 { | 455 { |
456 return type_conv_ops.checkelem (t, t_result); | 456 return type_conv_ops.checkelem (t, t_result); |
457 } | 457 } |
458 | 458 |
459 type_conv_fcn | 459 octave_base_value::type_conv_fcn |
460 octave_value_typeinfo::do_lookup_widening_op (int t, int t_result) | 460 octave_value_typeinfo::do_lookup_widening_op (int t, int t_result) |
461 { | 461 { |
462 return widening_ops.checkelem (t, t_result); | 462 return widening_ops.checkelem (t, t_result); |
463 } | 463 } |
464 | 464 |