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