Mercurial > hg > octave-lyh
annotate src/ov-typeinfo.cc @ 10315:57a59eae83cc
untabify src C++ source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:41:46 -0500 |
parents | cd96d29c5efa |
children | 12884915a8e4 |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008, 2009 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 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "ov-typeinfo.h" | |
29 | |
30 #include "defun.h" | |
31 #include "error.h" | |
32 | |
2479 | 33 const int |
34 octave_value_typeinfo::init_tab_sz (16); | |
35 | |
36 octave_value_typeinfo * | |
37 octave_value_typeinfo::instance (0); | |
2376 | 38 |
4515 | 39 #include <Array.h> |
40 #include <Array2.h> | |
41 #include <Array3.h> | |
42 | |
2926 | 43 bool |
44 octave_value_typeinfo::instance_ok (void) | |
45 { | |
46 bool retval = true; | |
47 if (! instance) | |
48 instance = new octave_value_typeinfo (); | |
49 | |
50 if (! instance) | |
51 { | |
52 ::error ("unable to create value type info object!"); | |
53 | |
54 retval = false; | |
55 } | |
56 | |
57 return retval; | |
58 } | |
59 | |
2376 | 60 int |
4612 | 61 octave_value_typeinfo::register_type (const std::string& t_name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
62 const std::string& c_name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
63 const octave_value& val) |
2376 | 64 { |
2926 | 65 return (instance_ok ()) |
4640 | 66 ? instance->do_register_type (t_name, c_name, val) : -1; |
2376 | 67 } |
68 | |
69 bool | |
7336 | 70 octave_value_typeinfo::register_unary_class_op (octave_value::unary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
71 octave_value_typeinfo::unary_class_op_fcn f) |
7336 | 72 { |
73 return (instance_ok ()) | |
74 ? instance->do_register_unary_class_op (op, f) : false; | |
75 } | |
76 | |
77 bool | |
3203 | 78 octave_value_typeinfo::register_unary_op (octave_value::unary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
79 int t, octave_value_typeinfo::unary_op_fcn f) |
3203 | 80 { |
81 return (instance_ok ()) | |
82 ? instance->do_register_unary_op (op, t, f) : false; | |
83 } | |
84 | |
85 bool | |
86 octave_value_typeinfo::register_non_const_unary_op (octave_value::unary_op op, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
87 int t, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
88 octave_value_typeinfo::non_const_unary_op_fcn f) |
3203 | 89 { |
90 return (instance_ok ()) | |
91 ? instance->do_register_non_const_unary_op (op, t, f) : false; | |
92 } | |
93 | |
94 bool | |
7336 | 95 octave_value_typeinfo::register_binary_class_op (octave_value::binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
96 octave_value_typeinfo::binary_class_op_fcn f) |
7336 | 97 { |
98 return (instance_ok ()) | |
99 ? instance->do_register_binary_class_op (op, f) : false; | |
100 } | |
101 | |
102 bool | |
2376 | 103 octave_value_typeinfo::register_binary_op (octave_value::binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
104 int t1, int t2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
105 octave_value_typeinfo::binary_op_fcn f) |
2376 | 106 { |
2926 | 107 return (instance_ok ()) |
108 ? instance->do_register_binary_op (op, t1, t2, f) : false; | |
2376 | 109 } |
110 | |
111 bool | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
112 octave_value_typeinfo::register_binary_class_op (octave_value::compound_binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
113 octave_value_typeinfo::binary_class_op_fcn f) |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
114 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
115 return (instance_ok ()) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
116 ? instance->do_register_binary_class_op (op, f) : false; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
117 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
118 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
119 bool |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
120 octave_value_typeinfo::register_binary_op (octave_value::compound_binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
121 int t1, int t2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
122 octave_value_typeinfo::binary_op_fcn f) |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
123 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
124 return (instance_ok ()) |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
125 ? instance->do_register_binary_op (op, t1, t2, f) : false; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
126 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
127 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
128 bool |
5759 | 129 octave_value_typeinfo::register_cat_op (int t1, int t2, octave_value_typeinfo::cat_op_fcn f) |
4915 | 130 { |
131 return (instance_ok ()) | |
132 ? instance->do_register_cat_op (t1, t2, f) : false; | |
133 } | |
134 | |
135 bool | |
2882 | 136 octave_value_typeinfo::register_assign_op (octave_value::assign_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
137 int t_lhs, int t_rhs, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
138 octave_value_typeinfo::assign_op_fcn f) |
2376 | 139 { |
2926 | 140 return (instance_ok ()) |
141 ? instance->do_register_assign_op (op, t_lhs, t_rhs, f) : -1; | |
2376 | 142 } |
143 | |
144 bool | |
3196 | 145 octave_value_typeinfo::register_assignany_op (octave_value::assign_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
146 int t_lhs, octave_value_typeinfo::assignany_op_fcn f) |
3196 | 147 { |
148 return (instance_ok ()) | |
149 ? instance->do_register_assignany_op (op, t_lhs, f) : -1; | |
150 } | |
151 | |
152 bool | |
2376 | 153 octave_value_typeinfo::register_pref_assign_conv (int t_lhs, int t_rhs, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
154 int t_result) |
2376 | 155 { |
2926 | 156 return (instance_ok ()) |
157 ? instance->do_register_pref_assign_conv (t_lhs, t_rhs, t_result) : false; | |
2376 | 158 } |
159 | |
160 bool | |
4901 | 161 octave_value_typeinfo::register_type_conv_op (int t, int t_result, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
162 octave_base_value::type_conv_fcn f) |
4901 | 163 { |
164 return (instance_ok ()) | |
165 ? instance->do_register_type_conv_op (t, t_result, f) : false; | |
166 } | |
167 | |
168 bool | |
2376 | 169 octave_value_typeinfo::register_widening_op (int t, int t_result, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
170 octave_base_value::type_conv_fcn f) |
2376 | 171 { |
2926 | 172 return (instance_ok ()) |
173 ? instance->do_register_widening_op (t, t_result, f) : false; | |
2376 | 174 } |
175 | |
5775 | 176 // FIXME -- we should also store all class names and provide a |
4687 | 177 // way to list them (calling class with nargin == 0?). |
178 | |
2376 | 179 int |
4612 | 180 octave_value_typeinfo::do_register_type (const std::string& t_name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
181 const std::string& /* c_name */, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
182 const octave_value& val) |
2376 | 183 { |
184 int i = 0; | |
185 | |
186 for (i = 0; i < num_types; i++) | |
4612 | 187 if (t_name == types (i)) |
2376 | 188 return i; |
189 | |
190 int len = types.length (); | |
191 | |
192 if (i == len) | |
193 { | |
194 len *= 2; | |
195 | |
4625 | 196 types.resize (len, std::string ()); |
2376 | 197 |
4640 | 198 vals.resize (len, octave_value ()); |
199 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
200 unary_ops.resize (static_cast<int> (octave_value::num_unary_ops), len, 0); |
3203 | 201 |
202 non_const_unary_ops.resize | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
203 (static_cast<int> (octave_value::num_unary_ops), len, 0); |
3203 | 204 |
2800 | 205 binary_ops.resize (static_cast<int> (octave_value::num_binary_ops), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
206 len, len, 0); |
2376 | 207 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
208 compound_binary_ops.resize (static_cast<int> (octave_value::num_compound_binary_ops), |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
209 len, len, 0); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
210 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
211 cat_ops.resize (len, len, 0); |
4915 | 212 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
213 assign_ops.resize (static_cast<int> (octave_value::num_assign_ops), len, len, 0); |
2376 | 214 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
215 assignany_ops.resize (static_cast<int> (octave_value::num_assign_ops), len, 0); |
3196 | 216 |
2376 | 217 pref_assign_conv.resize (len, len, -1); |
218 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
219 type_conv_ops.resize (len, len, 0); |
4901 | 220 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
221 widening_ops.resize (len, len, 0); |
2376 | 222 } |
223 | |
4612 | 224 types (i) = t_name; |
2376 | 225 |
4640 | 226 vals (i) = val; |
227 | |
2376 | 228 num_types++; |
229 | |
230 return i; | |
231 } | |
232 | |
233 bool | |
7336 | 234 octave_value_typeinfo::do_register_unary_class_op (octave_value::unary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
235 octave_value_typeinfo::unary_class_op_fcn f) |
7336 | 236 { |
237 if (lookup_unary_class_op (op)) | |
238 { | |
239 std::string op_name = octave_value::unary_op_as_string (op); | |
240 | |
241 warning ("duplicate unary operator `%s' for class dispatch", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
242 op_name.c_str ()); |
7336 | 243 } |
244 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
245 unary_class_ops.checkelem (static_cast<int> (op)) = reinterpret_cast<void *> (f); |
7336 | 246 |
247 return false; | |
248 } | |
249 | |
250 bool | |
3203 | 251 octave_value_typeinfo::do_register_unary_op (octave_value::unary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
252 int t, octave_value_typeinfo::unary_op_fcn f) |
3203 | 253 { |
4508 | 254 if (lookup_unary_op (op, t)) |
255 { | |
256 std::string op_name = octave_value::unary_op_as_string (op); | |
257 std::string type_name = types(t); | |
258 | |
259 warning ("duplicate unary operator `%s' for type `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
260 op_name.c_str (), type_name.c_str ()); |
4508 | 261 } |
262 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
263 unary_ops.checkelem (static_cast<int> (op), t) = reinterpret_cast<void *> (f); |
3203 | 264 |
265 return false; | |
266 } | |
267 | |
268 bool | |
269 octave_value_typeinfo::do_register_non_const_unary_op | |
5759 | 270 (octave_value::unary_op op, int t, octave_value_typeinfo::non_const_unary_op_fcn f) |
3203 | 271 { |
4508 | 272 if (lookup_non_const_unary_op (op, t)) |
273 { | |
274 std::string op_name = octave_value::unary_op_as_string (op); | |
275 std::string type_name = types(t); | |
276 | |
277 warning ("duplicate unary operator `%s' for type `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
278 op_name.c_str (), type_name.c_str ()); |
4508 | 279 } |
280 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
281 non_const_unary_ops.checkelem (static_cast<int> (op), t) = reinterpret_cast<void *> (f); |
3203 | 282 |
283 return false; | |
284 } | |
285 | |
286 bool | |
7336 | 287 octave_value_typeinfo::do_register_binary_class_op (octave_value::binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
288 octave_value_typeinfo::binary_class_op_fcn f) |
7336 | 289 { |
290 if (lookup_binary_class_op (op)) | |
291 { | |
292 std::string op_name = octave_value::binary_op_as_string (op); | |
293 | |
294 warning ("duplicate binary operator `%s' for class dispatch", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
295 op_name.c_str ()); |
7336 | 296 } |
297 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
298 binary_class_ops.checkelem (static_cast<int> (op)) = reinterpret_cast<void *> (f); |
7336 | 299 |
300 return false; | |
301 } | |
302 | |
303 bool | |
2376 | 304 octave_value_typeinfo::do_register_binary_op (octave_value::binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
305 int t1, int t2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
306 octave_value_typeinfo::binary_op_fcn f) |
2376 | 307 { |
4508 | 308 if (lookup_binary_op (op, t1, t2)) |
309 { | |
310 std::string op_name = octave_value::binary_op_as_string (op); | |
311 std::string t1_name = types(t1); | |
312 std::string t2_name = types(t2); | |
313 | |
314 warning ("duplicate binary operator `%s' for types `%s' and `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
315 op_name.c_str (), t1_name.c_str (), t1_name.c_str ()); |
4508 | 316 } |
317 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
318 binary_ops.checkelem (static_cast<int> (op), t1, t2) = reinterpret_cast<void *> (f); |
2376 | 319 |
320 return false; | |
321 } | |
322 | |
323 bool | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
324 octave_value_typeinfo::do_register_binary_class_op (octave_value::compound_binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
325 octave_value_typeinfo::binary_class_op_fcn f) |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
326 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
327 if (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:
7433
diff
changeset
|
328 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
329 std::string op_name = octave_value::binary_op_fcn_name (op); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
330 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
331 warning ("duplicate compound binary operator `%s' for class dispatch", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
332 op_name.c_str ()); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
333 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
334 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
335 compound_binary_class_ops.checkelem (static_cast<int> (op)) = reinterpret_cast<void *> (f); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
336 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
337 return false; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
338 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
339 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
340 bool |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
341 octave_value_typeinfo::do_register_binary_op (octave_value::compound_binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
342 int t1, int t2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
343 octave_value_typeinfo::binary_op_fcn f) |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
344 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
345 if (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:
7433
diff
changeset
|
346 { |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
347 std::string op_name = octave_value::binary_op_fcn_name (op); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
348 std::string t1_name = types(t1); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
349 std::string t2_name = types(t2); |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
350 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
351 warning ("duplicate compound binary operator `%s' for types `%s' and `%s'", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
352 op_name.c_str (), t1_name.c_str (), t1_name.c_str ()); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
353 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
354 |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
355 compound_binary_ops.checkelem (static_cast<int> (op), t1, t2) = reinterpret_cast<void *> (f); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
356 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
357 return false; |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
358 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
359 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
360 bool |
5759 | 361 octave_value_typeinfo::do_register_cat_op (int t1, int t2, octave_value_typeinfo::cat_op_fcn f) |
4915 | 362 { |
363 if (lookup_cat_op (t1, t2)) | |
364 { | |
365 std::string t1_name = types(t1); | |
366 std::string t2_name = types(t2); | |
367 | |
368 warning ("duplicate concatenation operator for types `%s' and `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
369 t1_name.c_str (), t1_name.c_str ()); |
4915 | 370 } |
371 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
372 cat_ops.checkelem (t1, t2) = reinterpret_cast<void *> (f); |
4915 | 373 |
374 return false; | |
375 } | |
376 | |
377 bool | |
2882 | 378 octave_value_typeinfo::do_register_assign_op (octave_value::assign_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
379 int t_lhs, int t_rhs, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
380 octave_value_typeinfo::assign_op_fcn f) |
2376 | 381 { |
4508 | 382 if (lookup_assign_op (op, t_lhs, t_rhs)) |
383 { | |
384 std::string op_name = octave_value::assign_op_as_string (op); | |
385 std::string t_lhs_name = types(t_lhs); | |
386 std::string t_rhs_name = types(t_rhs); | |
387 | |
388 warning ("duplicate assignment operator `%s' for types `%s' and `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
389 op_name.c_str (), t_lhs_name.c_str (), t_rhs_name.c_str ()); |
4508 | 390 } |
391 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
392 assign_ops.checkelem (static_cast<int> (op), t_lhs, t_rhs) = reinterpret_cast<void *> (f); |
2376 | 393 |
394 return false; | |
395 } | |
396 | |
397 bool | |
3196 | 398 octave_value_typeinfo::do_register_assignany_op (octave_value::assign_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
399 int t_lhs, octave_value_typeinfo::assignany_op_fcn f) |
3196 | 400 { |
4508 | 401 if (lookup_assignany_op (op, t_lhs)) |
402 { | |
403 std::string op_name = octave_value::assign_op_as_string (op); | |
404 std::string t_lhs_name = types(t_lhs); | |
405 | |
406 warning ("duplicate assignment operator `%s' for types `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
407 op_name.c_str (), t_lhs_name.c_str ()); |
4508 | 408 } |
409 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
410 assignany_ops.checkelem (static_cast<int> (op), t_lhs) = reinterpret_cast<void *> (f); |
3196 | 411 |
412 return false; | |
413 } | |
414 | |
415 bool | |
2376 | 416 octave_value_typeinfo::do_register_pref_assign_conv (int t_lhs, int t_rhs, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
417 int t_result) |
2376 | 418 { |
4508 | 419 if (lookup_pref_assign_conv (t_lhs, t_rhs) >= 0) |
420 { | |
421 std::string t_lhs_name = types(t_lhs); | |
422 std::string t_rhs_name = types(t_rhs); | |
423 | |
424 warning ("overriding assignment conversion for types `%s' and `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
425 t_lhs_name.c_str (), t_rhs_name.c_str ()); |
4508 | 426 } |
427 | |
2376 | 428 pref_assign_conv.checkelem (t_lhs, t_rhs) = t_result; |
429 | |
430 return false; | |
431 } | |
432 | |
433 bool | |
4901 | 434 octave_value_typeinfo::do_register_type_conv_op |
5759 | 435 (int t, int t_result, octave_base_value::type_conv_fcn f) |
4901 | 436 { |
437 if (lookup_type_conv_op (t, t_result)) | |
438 { | |
439 std::string t_name = types(t); | |
440 std::string t_result_name = types(t_result); | |
441 | |
442 warning ("overriding type conversion op for `%s' to `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
443 t_name.c_str (), t_result_name.c_str ()); |
4901 | 444 } |
445 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
446 type_conv_ops.checkelem (t, t_result) = reinterpret_cast<void *> (f); |
4901 | 447 |
448 return false; | |
449 } | |
450 | |
451 bool | |
2376 | 452 octave_value_typeinfo::do_register_widening_op |
5759 | 453 (int t, int t_result, octave_base_value::type_conv_fcn f) |
2376 | 454 { |
4508 | 455 if (lookup_widening_op (t, t_result)) |
456 { | |
457 std::string t_name = types(t); | |
458 std::string t_result_name = types(t_result); | |
459 | |
460 warning ("overriding widening op for `%s' to `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
461 t_name.c_str (), t_result_name.c_str ()); |
4508 | 462 } |
463 | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
464 widening_ops.checkelem (t, t_result) = reinterpret_cast<void *> (f); |
2376 | 465 |
466 return false; | |
467 } | |
468 | |
4640 | 469 octave_value |
470 octave_value_typeinfo::do_lookup_type (const std::string& nm) | |
471 { | |
472 octave_value retval; | |
473 | |
474 for (int i = 0; i < num_types; i++) | |
475 { | |
476 if (nm == types(i)) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
477 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
478 retval = vals(i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
479 retval.make_unique (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
480 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
481 } |
4640 | 482 } |
483 | |
484 return retval; | |
485 } | |
486 | |
7336 | 487 octave_value_typeinfo::unary_class_op_fcn |
488 octave_value_typeinfo::do_lookup_unary_class_op (octave_value::unary_op op) | |
489 { | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
490 void *f = unary_class_ops.checkelem (static_cast<int> (op)); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
491 return reinterpret_cast<octave_value_typeinfo::unary_class_op_fcn> (f); |
7336 | 492 } |
493 | |
5759 | 494 octave_value_typeinfo::unary_op_fcn |
3203 | 495 octave_value_typeinfo::do_lookup_unary_op (octave_value::unary_op op, int t) |
496 { | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
497 void *f = unary_ops.checkelem (static_cast<int> (op), t); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
498 return reinterpret_cast<octave_value_typeinfo::unary_op_fcn> (f); |
3203 | 499 } |
500 | |
5759 | 501 octave_value_typeinfo::non_const_unary_op_fcn |
3203 | 502 octave_value_typeinfo::do_lookup_non_const_unary_op |
503 (octave_value::unary_op op, int t) | |
504 { | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
505 void *f = non_const_unary_ops.checkelem (static_cast<int> (op), t); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
506 return reinterpret_cast<octave_value_typeinfo::non_const_unary_op_fcn> (f); |
3203 | 507 } |
508 | |
7336 | 509 octave_value_typeinfo::binary_class_op_fcn |
510 octave_value_typeinfo::do_lookup_binary_class_op (octave_value::binary_op op) | |
511 { | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
512 void *f = binary_class_ops.checkelem (static_cast<int> (op)); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
513 return reinterpret_cast<octave_value_typeinfo::binary_class_op_fcn> (f); |
7336 | 514 } |
515 | |
5759 | 516 octave_value_typeinfo::binary_op_fcn |
2376 | 517 octave_value_typeinfo::do_lookup_binary_op (octave_value::binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
518 int t1, int t2) |
2376 | 519 { |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
520 void *f = binary_ops.checkelem (static_cast<int> (op), t1, t2); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
521 return reinterpret_cast<octave_value_typeinfo::binary_op_fcn> (f); |
2376 | 522 } |
523 | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
524 octave_value_typeinfo::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:
7433
diff
changeset
|
525 octave_value_typeinfo::do_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:
7433
diff
changeset
|
526 { |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
527 void *f = compound_binary_class_ops.checkelem (static_cast<int> (op)); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
528 return reinterpret_cast<octave_value_typeinfo::binary_class_op_fcn> (f); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
529 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
530 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
531 octave_value_typeinfo::binary_op_fcn |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
532 octave_value_typeinfo::do_lookup_binary_op (octave_value::compound_binary_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
533 int t1, int t2) |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
534 { |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
535 void *f = compound_binary_ops.checkelem (static_cast<int> (op), t1, t2); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
536 return reinterpret_cast<octave_value_typeinfo::binary_op_fcn> (f); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
537 } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
538 |
5759 | 539 octave_value_typeinfo::cat_op_fcn |
4915 | 540 octave_value_typeinfo::do_lookup_cat_op (int t1, int t2) |
541 { | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
542 void *f = cat_ops.checkelem (t1, t2); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
543 return reinterpret_cast<octave_value_typeinfo::cat_op_fcn> (f); |
4915 | 544 } |
545 | |
5759 | 546 octave_value_typeinfo::assign_op_fcn |
2882 | 547 octave_value_typeinfo::do_lookup_assign_op (octave_value::assign_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
548 int t_lhs, int t_rhs) |
2376 | 549 { |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
550 void *f = assign_ops.checkelem (static_cast<int> (op), t_lhs, t_rhs); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
551 return reinterpret_cast<octave_value_typeinfo::assign_op_fcn> (f); |
2376 | 552 } |
553 | |
5759 | 554 octave_value_typeinfo::assignany_op_fcn |
3196 | 555 octave_value_typeinfo::do_lookup_assignany_op (octave_value::assign_op op, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
556 int t_lhs) |
3196 | 557 { |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
558 void *f = assignany_ops.checkelem (static_cast<int> (op), t_lhs); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
559 return reinterpret_cast<octave_value_typeinfo::assignany_op_fcn> (f); |
3196 | 560 } |
561 | |
2376 | 562 int |
563 octave_value_typeinfo::do_lookup_pref_assign_conv (int t_lhs, int t_rhs) | |
564 { | |
565 return pref_assign_conv.checkelem (t_lhs, t_rhs); | |
566 } | |
567 | |
5759 | 568 octave_base_value::type_conv_fcn |
4901 | 569 octave_value_typeinfo::do_lookup_type_conv_op (int t, int t_result) |
570 { | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
571 void *f = type_conv_ops.checkelem (t, t_result); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
572 return reinterpret_cast<octave_base_value::type_conv_fcn> (f); |
4901 | 573 } |
574 | |
5759 | 575 octave_base_value::type_conv_fcn |
2376 | 576 octave_value_typeinfo::do_lookup_widening_op (int t, int t_result) |
577 { | |
9223
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
578 void *f = widening_ops.checkelem (t, t_result); |
902a4597dce8
use Array<void *> in ov-typeinfo.h
Jaroslav Hajek <highegg@gmail.com>
parents:
9219
diff
changeset
|
579 return reinterpret_cast<octave_base_value::type_conv_fcn> (f); |
2376 | 580 } |
581 | |
582 string_vector | |
583 octave_value_typeinfo::do_installed_type_names (void) | |
584 { | |
585 string_vector retval (num_types); | |
586 | |
587 for (int i = 0;i < num_types; i++) | |
588 retval (i) = types (i); | |
589 | |
590 return retval; | |
591 } | |
592 | |
2457 | 593 DEFUN (typeinfo, args, , |
3445 | 594 "-*- texinfo -*-\n\ |
595 @deftypefn {Built-in Function} {} typeinfo (@var{expr})\n\ | |
2822 | 596 \n\ |
3445 | 597 Return the type of the expression @var{expr}, as a string. If\n\ |
8474 | 598 @var{expr} is omitted, return an array of strings containing all the\n\ |
3445 | 599 currently installed data types.\n\ |
600 @end deftypefn") | |
2376 | 601 { |
602 octave_value retval; | |
603 | |
604 int nargin = args.length (); | |
605 | |
606 if (nargin == 0) | |
607 retval = octave_value_typeinfo::installed_type_names (); | |
2822 | 608 else if (nargin == 1) |
609 retval = args(0).type_name (); | |
2376 | 610 else |
5823 | 611 print_usage (); |
2376 | 612 |
613 return retval; | |
614 } |