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