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