2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_value_h) |
|
24 #define octave_value_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <cstdlib> |
|
31 |
3503
|
32 #include <iostream> |
2376
|
33 #include <string> |
|
34 |
|
35 #include "Range.h" |
|
36 #include "idx-vector.h" |
|
37 #include "mx-base.h" |
2477
|
38 #include "oct-alloc.h" |
2942
|
39 #include "str-vec.h" |
|
40 |
3351
|
41 class Cell; |
2376
|
42 class Octave_map; |
2903
|
43 class octave_stream; |
2974
|
44 class octave_function; |
2376
|
45 class octave_value_list; |
2979
|
46 class octave_lvalue; |
2376
|
47 |
|
48 // Constants. |
|
49 |
|
50 // This just provides a way to avoid infinite recursion when building |
|
51 // octave_value objects. |
|
52 |
|
53 class |
|
54 octave_xvalue |
|
55 { |
|
56 public: |
|
57 |
|
58 octave_xvalue (void) { } |
|
59 }; |
|
60 |
2427
|
61 class octave_value; |
|
62 |
|
63 // XXX FIXME XXX -- these should probably really be inside the scope |
|
64 // of the octave_value class, but the cygwin32 beta16 version of g++ |
3203
|
65 // can't handle that. |
|
66 |
|
67 typedef octave_value (*unary_op_fcn) |
|
68 (const octave_value&); |
|
69 |
|
70 typedef void (*non_const_unary_op_fcn) |
|
71 (octave_value&); |
2427
|
72 |
|
73 typedef octave_value (*binary_op_fcn) |
|
74 (const octave_value&, const octave_value&); |
|
75 |
|
76 typedef octave_value (*assign_op_fcn) |
|
77 (octave_value&, const octave_value_list&, const octave_value&); |
|
78 |
|
79 typedef octave_value * (*type_conv_fcn) (const octave_value&); |
|
80 |
2376
|
81 class |
2974
|
82 octave_value |
2376
|
83 { |
|
84 public: |
|
85 |
3203
|
86 enum unary_op |
|
87 { |
|
88 not, |
|
89 uminus, |
|
90 transpose, |
|
91 hermitian, |
|
92 incr, |
|
93 decr, |
|
94 num_unary_ops, |
|
95 unknown_unary_op |
|
96 }; |
|
97 |
2376
|
98 enum binary_op |
|
99 { |
|
100 add, |
|
101 sub, |
|
102 mul, |
|
103 div, |
|
104 pow, |
|
105 ldiv, |
2903
|
106 lshift, |
|
107 rshift, |
2376
|
108 lt, |
|
109 le, |
|
110 eq, |
|
111 ge, |
|
112 gt, |
|
113 ne, |
|
114 el_mul, |
|
115 el_div, |
|
116 el_pow, |
|
117 el_ldiv, |
|
118 el_and, |
|
119 el_or, |
|
120 struct_ref, |
|
121 num_binary_ops, |
|
122 unknown_binary_op |
|
123 }; |
|
124 |
2880
|
125 enum assign_op |
|
126 { |
|
127 asn_eq, |
|
128 add_eq, |
|
129 sub_eq, |
|
130 mul_eq, |
|
131 div_eq, |
3204
|
132 ldiv_eq, |
2903
|
133 lshift_eq, |
|
134 rshift_eq, |
2880
|
135 el_mul_eq, |
|
136 el_div_eq, |
3204
|
137 el_ldiv_eq, |
2880
|
138 el_and_eq, |
|
139 el_or_eq, |
|
140 num_assign_ops, |
|
141 unknown_assign_op |
|
142 }; |
|
143 |
3203
|
144 static string unary_op_as_string (unary_op); |
|
145 |
2376
|
146 static string binary_op_as_string (binary_op); |
|
147 |
2880
|
148 static string assign_op_as_string (assign_op); |
|
149 |
2376
|
150 enum magic_colon { magic_colon_t }; |
|
151 enum all_va_args { all_va_args_t }; |
|
152 |
|
153 octave_value (void); |
|
154 octave_value (double d); |
3351
|
155 octave_value (const Cell& m); |
2376
|
156 octave_value (const Matrix& m); |
|
157 octave_value (const DiagMatrix& d); |
3418
|
158 octave_value (const RowVector& v); |
|
159 octave_value (const ColumnVector& v); |
2376
|
160 octave_value (const Complex& C); |
|
161 octave_value (const ComplexMatrix& m); |
|
162 octave_value (const ComplexDiagMatrix& d); |
3418
|
163 octave_value (const ComplexRowVector& v); |
|
164 octave_value (const ComplexColumnVector& v); |
2825
|
165 octave_value (bool b); |
|
166 octave_value (const boolMatrix& bm); |
3189
|
167 octave_value (char c); |
2376
|
168 octave_value (const char *s); |
|
169 octave_value (const string& s); |
|
170 octave_value (const string_vector& s); |
|
171 octave_value (const charMatrix& chm, bool is_string = false); |
|
172 octave_value (double base, double limit, double inc); |
|
173 octave_value (const Range& r); |
|
174 octave_value (const Octave_map& m); |
3340
|
175 octave_value (const octave_stream& s, int n); |
2974
|
176 octave_value (octave_function *f); |
2880
|
177 octave_value (const octave_value_list& m); |
2376
|
178 octave_value (octave_value::magic_colon); |
|
179 octave_value (octave_value::all_va_args); |
|
180 |
|
181 octave_value (octave_value *new_rep); |
|
182 |
|
183 // Copy constructor. |
|
184 |
|
185 octave_value (const octave_value& a) |
|
186 { |
|
187 rep = a.rep; |
|
188 rep->count++; |
|
189 } |
|
190 |
|
191 // Delete the representation of this constant if the count drops to |
|
192 // zero. |
|
193 |
|
194 virtual ~octave_value (void); |
|
195 |
|
196 // This should only be called for derived types. |
|
197 |
2880
|
198 virtual octave_value *clone (void); |
2376
|
199 |
|
200 void make_unique (void) |
|
201 { |
|
202 if (rep->count > 1) |
|
203 { |
|
204 --rep->count; |
|
205 rep = rep->clone (); |
|
206 rep->count = 1; |
|
207 } |
|
208 } |
|
209 |
|
210 // Simple assignment. |
|
211 |
|
212 octave_value& operator = (const octave_value& a) |
|
213 { |
|
214 if (rep != a.rep) |
|
215 { |
|
216 if (--rep->count == 0) |
|
217 delete rep; |
|
218 |
|
219 rep = a.rep; |
|
220 rep->count++; |
|
221 } |
|
222 |
|
223 return *this; |
|
224 } |
|
225 |
3240
|
226 int get_count (void) { return rep->count; } |
3239
|
227 |
2409
|
228 virtual type_conv_fcn numeric_conversion_function (void) const |
2376
|
229 { return rep->numeric_conversion_function (); } |
|
230 |
2409
|
231 void maybe_mutate (void); |
|
232 |
2410
|
233 virtual octave_value *try_narrowing_conversion (void) |
|
234 { return rep->try_narrowing_conversion (); } |
2409
|
235 |
2974
|
236 virtual octave_value do_index_op (const octave_value_list& idx) |
2963
|
237 { return rep->do_index_op (idx); } |
2376
|
238 |
2974
|
239 virtual octave_value_list |
|
240 do_index_op (int nargout, const octave_value_list& idx); |
|
241 |
2963
|
242 void assign (assign_op, const octave_value& rhs); |
2880
|
243 |
2963
|
244 void assign (assign_op, const octave_value_list& idx, |
|
245 const octave_value& rhs); |
2376
|
246 |
2948
|
247 virtual void |
|
248 assign_struct_elt (assign_op, const string& elt_nm, |
|
249 const octave_value& rhs); |
|
250 |
|
251 virtual void |
|
252 assign_struct_elt (assign_op, const string& elt_nm, |
|
253 const octave_value_list& idx, const octave_value& rhs); |
|
254 |
2376
|
255 virtual idx_vector index_vector (void) const |
|
256 { return rep->index_vector (); } |
|
257 |
2420
|
258 virtual octave_value |
2963
|
259 do_struct_elt_index_op (const string& nm, bool silent = false) |
|
260 { return rep->do_struct_elt_index_op (nm, silent); } |
|
261 |
|
262 virtual octave_value |
|
263 do_struct_elt_index_op (const string& nm, const octave_value_list& idx, |
|
264 bool silent = false) |
|
265 { return rep->do_struct_elt_index_op (nm, idx, silent); } |
2376
|
266 |
2979
|
267 octave_lvalue struct_elt_ref (const string& nm); |
2948
|
268 |
2979
|
269 virtual octave_lvalue |
2948
|
270 struct_elt_ref (octave_value *parent, const string& nm); |
2376
|
271 |
|
272 // Size. |
|
273 |
|
274 virtual int rows (void) const |
|
275 { return rep->rows (); } |
|
276 |
|
277 virtual int columns (void) const |
|
278 { return rep->columns (); } |
|
279 |
3195
|
280 virtual int length (void) const |
|
281 { return rep->length (); } |
|
282 |
2376
|
283 // Does this constant have a type? Both of these are provided since |
|
284 // it is sometimes more natural to write is_undefined() instead of |
|
285 // ! is_defined(). |
|
286 |
|
287 virtual bool is_defined (void) const |
|
288 { return rep->is_defined (); } |
|
289 |
|
290 bool is_undefined (void) const |
|
291 { return ! is_defined (); } |
|
292 |
3351
|
293 virtual bool is_cell (void) const |
|
294 { return rep->is_cell (); } |
|
295 |
2376
|
296 virtual bool is_real_scalar (void) const |
|
297 { return rep->is_real_scalar (); } |
|
298 |
|
299 virtual bool is_real_matrix (void) const |
|
300 { return rep->is_real_matrix (); } |
|
301 |
|
302 virtual bool is_complex_scalar (void) const |
|
303 { return rep->is_complex_scalar (); } |
|
304 |
|
305 virtual bool is_complex_matrix (void) const |
|
306 { return rep->is_complex_matrix (); } |
|
307 |
|
308 virtual bool is_char_matrix (void) const |
|
309 { return rep->is_char_matrix (); } |
|
310 |
|
311 virtual bool is_string (void) const |
|
312 { return rep->is_string (); } |
|
313 |
|
314 virtual bool is_range (void) const |
|
315 { return rep->is_range (); } |
|
316 |
|
317 virtual bool is_map (void) const |
|
318 { return rep->is_map (); } |
|
319 |
3340
|
320 virtual bool is_stream (void) const |
|
321 { return rep->is_stream (); } |
|
322 |
2880
|
323 virtual bool is_list (void) const |
|
324 { return rep->is_list (); } |
|
325 |
2376
|
326 virtual bool is_magic_colon (void) const |
|
327 { return rep->is_magic_colon (); } |
|
328 |
|
329 virtual bool is_all_va_args (void) const |
|
330 { return rep->is_all_va_args (); } |
|
331 |
|
332 // Are any or all of the elements in this constant nonzero? |
|
333 |
|
334 virtual octave_value all (void) const |
|
335 { return rep->all (); } |
|
336 |
|
337 virtual octave_value any (void) const |
|
338 { return rep->any (); } |
|
339 |
|
340 // Other type stuff. |
|
341 |
3209
|
342 virtual bool is_bool_type (void) const |
|
343 { return rep->is_bool_type (); } |
|
344 |
2376
|
345 virtual bool is_real_type (void) const |
|
346 { return rep->is_real_type (); } |
|
347 |
|
348 virtual bool is_complex_type (void) const |
|
349 { return rep->is_complex_type (); } |
|
350 |
|
351 virtual bool is_scalar_type (void) const |
|
352 { return rep->is_scalar_type (); } |
|
353 |
|
354 virtual bool is_matrix_type (void) const |
|
355 { return rep->is_matrix_type (); } |
|
356 |
|
357 virtual bool is_numeric_type (void) const |
|
358 { return rep->is_numeric_type (); } |
|
359 |
|
360 virtual bool valid_as_scalar_index (void) const |
|
361 { return rep->valid_as_scalar_index (); } |
|
362 |
|
363 virtual bool valid_as_zero_index (void) const |
|
364 { return rep->valid_as_zero_index (); } |
|
365 |
|
366 // Does this constant correspond to a truth value? |
|
367 |
|
368 virtual bool is_true (void) const |
|
369 { return rep->is_true (); } |
|
370 |
|
371 // Is at least one of the dimensions of this constant zero? |
|
372 |
|
373 virtual bool is_empty (void) const |
|
374 { return rep->is_empty (); } |
|
375 |
|
376 // Are the dimensions of this constant zero by zero? |
|
377 |
|
378 virtual bool is_zero_by_zero (void) const |
|
379 { return rep->is_zero_by_zero (); } |
|
380 |
2974
|
381 virtual bool is_constant (void) const |
|
382 { return rep->is_constant (); } |
|
383 |
|
384 virtual bool is_function (void) const |
|
385 { return rep->is_function (); } |
2891
|
386 |
3325
|
387 virtual bool is_builtin_function (void) const |
|
388 { return rep->is_builtin_function (); } |
|
389 |
|
390 virtual bool is_dld_function (void) const |
|
391 { return rep->is_dld_function (); } |
|
392 |
2376
|
393 // Values. |
|
394 |
2891
|
395 octave_value eval (void) { return *this; } |
|
396 |
3202
|
397 virtual int int_value (bool req_int = false, bool frc_str_conv = false) const |
|
398 { return rep->int_value (req_int, frc_str_conv); } |
|
399 |
|
400 virtual int nint_value (bool frc_str_conv = false) const |
|
401 { return rep->nint_value (frc_str_conv); } |
|
402 |
2376
|
403 virtual double double_value (bool frc_str_conv = false) const |
|
404 { return rep->double_value (frc_str_conv); } |
|
405 |
2916
|
406 virtual double scalar_value (bool frc_str_conv = false) const |
|
407 { return rep->scalar_value (frc_str_conv); } |
|
408 |
3351
|
409 virtual Cell cell_value (void) const; |
|
410 |
2376
|
411 virtual Matrix matrix_value (bool frc_str_conv = false) const |
|
412 { return rep->matrix_value (frc_str_conv); } |
|
413 |
|
414 virtual Complex complex_value (bool frc_str_conv = false) const |
|
415 { return rep->complex_value (frc_str_conv); } |
|
416 |
|
417 virtual ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const |
|
418 { return rep->complex_matrix_value (frc_str_conv); } |
|
419 |
|
420 virtual charMatrix char_matrix_value (bool frc_str_conv = false) const |
|
421 { return rep->char_matrix_value (frc_str_conv); } |
|
422 |
2493
|
423 virtual string_vector all_strings (void) const |
2376
|
424 { return rep->all_strings (); } |
|
425 |
|
426 virtual string string_value (void) const |
|
427 { return rep->string_value (); } |
|
428 |
|
429 virtual Range range_value (void) const |
|
430 { return rep->range_value (); } |
|
431 |
|
432 virtual Octave_map map_value (void) const; |
|
433 |
3340
|
434 virtual octave_stream stream_value (void) const; |
2903
|
435 |
|
436 virtual int stream_number (void) const; |
|
437 |
2974
|
438 virtual octave_function *function_value (bool silent = false); |
|
439 |
2880
|
440 virtual octave_value_list list_value (void) const; |
|
441 |
2825
|
442 virtual bool bool_value (void) const |
|
443 { return rep->bool_value (); } |
|
444 |
|
445 virtual boolMatrix bool_matrix_value (void) const |
|
446 { return rep->bool_matrix_value (); } |
|
447 |
3419
|
448 ColumnVector column_vector_value (bool frc_str_conv = false, |
2376
|
449 bool frc_vec_conv = false) const; |
|
450 |
|
451 ComplexColumnVector |
3419
|
452 complex_column_vector_value (bool frc_str_conv = false, |
2376
|
453 bool frc_vec_conv = false) const; |
|
454 |
3419
|
455 RowVector row_vector_value (bool frc_str_conv = false, |
|
456 bool frc_vec_conv = false) const; |
|
457 |
|
458 ComplexRowVector |
|
459 complex_row_vector_value (bool frc_str_conv = false, |
|
460 bool frc_vec_conv = false) const; |
|
461 |
|
462 Array<double> vector_value (bool frc_str_conv = false, |
|
463 bool frc_vec_conv = false) const; |
|
464 |
|
465 Array<Complex> complex_vector_value (bool frc_str_conv = false, |
|
466 bool frc_vec_conv = false) const; |
|
467 |
2376
|
468 // Conversions. These should probably be private. If a user of this |
|
469 // class wants a certain kind of constant, he should simply ask for |
|
470 // it, and we should convert it if possible. |
|
471 |
|
472 virtual octave_value convert_to_str (void) const |
|
473 { return rep->convert_to_str (); } |
|
474 |
|
475 virtual void convert_to_row_or_column_vector (void) |
|
476 { rep->convert_to_row_or_column_vector (); } |
|
477 |
2903
|
478 virtual void print (ostream& os, bool pr_as_read_syntax = false) const |
2466
|
479 { rep->print (os, pr_as_read_syntax); } |
2376
|
480 |
2903
|
481 virtual void print_raw (ostream& os, bool pr_as_read_syntax = false) const |
|
482 { rep->print_raw (os, pr_as_read_syntax); } |
|
483 |
|
484 virtual bool print_name_tag (ostream& os, const string& name) const |
|
485 { return rep->print_name_tag (os, name); } |
2376
|
486 |
|
487 void print_with_name (ostream& os, const string& name, |
2903
|
488 bool print_padding = true) const; |
2376
|
489 |
|
490 virtual int type_id (void) const { return rep->type_id (); } |
|
491 |
|
492 virtual string type_name (void) const { return rep->type_name (); } |
|
493 |
3203
|
494 // Unary and binary operations. |
|
495 |
|
496 friend octave_value do_unary_op (octave_value::unary_op, |
|
497 const octave_value&); |
|
498 |
|
499 void do_non_const_unary_op (octave_value::unary_op); |
2376
|
500 |
3205
|
501 void do_non_const_unary_op (octave_value::unary_op, |
|
502 const octave_value_list& idx); |
|
503 |
2575
|
504 friend octave_value do_binary_op (octave_value::binary_op, |
|
505 const octave_value&, |
|
506 const octave_value&); |
2376
|
507 |
3301
|
508 const octave_value& get_rep (void) const { return *rep; } |
|
509 |
2376
|
510 protected: |
|
511 |
|
512 octave_value (const octave_xvalue&) : rep (0) { } |
|
513 |
2903
|
514 void reset_indent_level (void) const |
|
515 { curr_print_indent_level = 0; } |
|
516 |
|
517 void increment_indent_level (void) const |
|
518 { curr_print_indent_level += 2; } |
|
519 |
|
520 void decrement_indent_level (void) const |
|
521 { curr_print_indent_level -= 2; } |
|
522 |
|
523 int current_print_indent_level (void) const |
|
524 { return curr_print_indent_level; } |
|
525 |
|
526 void newline (ostream& os) const; |
|
527 |
|
528 void indent (ostream& os) const; |
|
529 |
|
530 void reset (void) const; |
|
531 |
2376
|
532 private: |
|
533 |
|
534 union |
|
535 { |
|
536 octave_value *rep; // The real representation. |
|
537 int count; // A reference count. |
|
538 }; |
2413
|
539 |
2880
|
540 bool convert_and_assign (assign_op, const octave_value_list& idx, |
2413
|
541 const octave_value& rhs); |
|
542 |
2880
|
543 bool try_assignment_with_conversion (assign_op, |
|
544 const octave_value_list& idx, |
2413
|
545 const octave_value& rhs); |
|
546 |
2880
|
547 bool try_assignment (assign_op, const octave_value_list& idx, |
2413
|
548 const octave_value& rhs); |
2903
|
549 |
|
550 static int curr_print_indent_level; |
|
551 static bool beginning_of_line; |
3204
|
552 |
3205
|
553 assign_op unary_op_to_assign_op (unary_op op); |
|
554 |
3204
|
555 binary_op op_eq_to_binary_op (assign_op op); |
|
556 |
|
557 void simple_assign (assign_op orig_op, const octave_value_list& idx, |
|
558 const octave_value& rhs); |
3219
|
559 |
|
560 DECLARE_OCTAVE_ALLOCATOR |
2376
|
561 }; |
|
562 |
3203
|
563 #define OV_UNOP_FN(name) \ |
|
564 inline octave_value \ |
|
565 name (const octave_value& a) \ |
|
566 { \ |
|
567 return do_unary_op (octave_value::name, a); \ |
|
568 } |
|
569 |
|
570 #define OV_UNOP_OP(name, op) \ |
|
571 inline octave_value \ |
|
572 operator op (const octave_value& a) \ |
|
573 { \ |
|
574 return name (a); \ |
|
575 } |
|
576 |
|
577 #define OV_UNOP_FN_OP(name, op) \ |
|
578 OV_UNOP_FN (name) \ |
|
579 OV_UNOP_OP (name, op) |
|
580 |
|
581 OV_UNOP_FN_OP (not, !) |
|
582 OV_UNOP_FN_OP (uminus, -) |
|
583 |
|
584 OV_UNOP_FN (transpose) |
|
585 OV_UNOP_FN (hermitian) |
|
586 |
|
587 // No simple way to define these for prefix and suffix ops? |
|
588 // |
|
589 // incr |
|
590 // decr |
|
591 |
|
592 #define OV_BINOP_FN(name) \ |
|
593 inline octave_value \ |
|
594 name (const octave_value& a1, const octave_value& a2) \ |
|
595 { \ |
|
596 return do_binary_op (octave_value::name, a1, a2); \ |
|
597 } |
|
598 |
|
599 #define OV_BINOP_OP(name, op) \ |
|
600 inline octave_value \ |
|
601 operator op (const octave_value& a1, const octave_value& a2) \ |
|
602 { \ |
|
603 return name (a1, a2); \ |
|
604 } |
|
605 |
|
606 #define OV_BINOP_FN_OP(name, op) \ |
|
607 OV_BINOP_FN (name) \ |
|
608 OV_BINOP_OP (name, op) |
|
609 |
|
610 OV_BINOP_FN_OP (add, +) |
|
611 OV_BINOP_FN_OP (sub, -) |
|
612 OV_BINOP_FN_OP (mul, *) |
|
613 OV_BINOP_FN_OP (div, /) |
|
614 |
|
615 OV_BINOP_FN (pow) |
|
616 OV_BINOP_FN (ldiv) |
|
617 OV_BINOP_FN (lshift) |
|
618 OV_BINOP_FN (rshift) |
|
619 |
|
620 OV_BINOP_FN_OP (lt, <) |
|
621 OV_BINOP_FN_OP (le, <=) |
|
622 OV_BINOP_FN_OP (eq, ==) |
|
623 OV_BINOP_FN_OP (ge, >=) |
|
624 OV_BINOP_FN_OP (gt, >) |
|
625 OV_BINOP_FN_OP (ne, !=) |
|
626 |
|
627 OV_BINOP_FN (el_mul) |
|
628 OV_BINOP_FN (el_div) |
|
629 OV_BINOP_FN (el_pow) |
|
630 OV_BINOP_FN (el_ldiv) |
|
631 OV_BINOP_FN (el_and) |
|
632 OV_BINOP_FN (el_or) |
|
633 |
|
634 OV_BINOP_FN (struct_ref) |
|
635 |
3219
|
636 // T_ID is the type id of struct objects, set by register_type(). |
|
637 // T_NAME is the type name of struct objects. |
|
638 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA \ |
|
639 public: \ |
|
640 int type_id (void) const { return t_id; } \ |
|
641 string type_name (void) const { return t_name; } \ |
3301
|
642 static volatile int static_type_id (void) { return t_id; } \ |
3219
|
643 static void register_type (void) \ |
|
644 { t_id = octave_value_typeinfo::register_type (t_name); } \ |
|
645 \ |
|
646 private: \ |
3301
|
647 static volatile int t_id; \ |
3219
|
648 static const string t_name; |
|
649 |
|
650 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n) \ |
3301
|
651 volatile int t::t_id (-1); \ |
3219
|
652 const string t::t_name (n) |
|
653 |
2376
|
654 // If TRUE, allow assignments like |
|
655 // |
|
656 // octave> A(1) = 3; A(2) = 5 |
|
657 // |
|
658 // for A already defined and a matrix type. |
|
659 extern bool Vdo_fortran_indexing; |
|
660 |
|
661 // Should we allow things like: |
|
662 // |
|
663 // octave> 'abc' + 0 |
|
664 // 97 98 99 |
|
665 // |
|
666 // to happen? A positive value means yes. A negative value means |
|
667 // yes, but print a warning message. Zero means it should be |
|
668 // considered an error. |
|
669 extern int Vimplicit_str_to_num_ok; |
|
670 |
|
671 // Should we allow silent conversion of complex to real when a real |
|
672 // type is what we're really looking for? A positive value means yes. |
|
673 // A negative value means yes, but print a warning message. Zero |
|
674 // means it should be considered an error. |
|
675 extern int Vok_to_lose_imaginary_part; |
|
676 |
|
677 // If TRUE, print the name along with the value. |
|
678 extern bool Vprint_answer_id_name; |
|
679 |
|
680 // Should operations on empty matrices return empty matrices or an |
|
681 // error? A positive value means yes. A negative value means yes, |
|
682 // but print a warning message. Zero means it should be considered an |
|
683 // error. |
|
684 extern int Vpropagate_empty_matrices; |
|
685 |
|
686 // How many levels of structure elements should we print? |
|
687 extern int Vstruct_levels_to_print; |
|
688 |
|
689 // Allow divide by zero errors to be suppressed. |
|
690 extern bool Vwarn_divide_by_zero; |
|
691 |
3195
|
692 // If TRUE, resize matrices when performing and indexed assignment and |
|
693 // the indices are outside the current bounds. |
|
694 extern bool Vresize_on_range_error; |
|
695 |
2376
|
696 // Indentation level for structures. |
|
697 extern int struct_indent; |
|
698 |
|
699 extern void increment_struct_indent (void); |
|
700 extern void decrement_struct_indent (void); |
|
701 |
2880
|
702 // Indentation level for lists. |
|
703 extern int list_indent; |
|
704 |
|
705 extern void increment_list_indent (void); |
|
706 extern void decrement_list_indent (void); |
|
707 |
2376
|
708 extern void install_types (void); |
|
709 |
|
710 #endif |
|
711 |
|
712 /* |
|
713 ;; Local Variables: *** |
|
714 ;; mode: C++ *** |
|
715 ;; End: *** |
|
716 */ |