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); |
3977
|
182 octave_value (const octave_value_list& m, bool is_cs_list = false); |
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 |
3977
|
339 virtual bool is_cs_list (void) const |
|
340 { return rep->is_cs_list (); } |
|
341 |
2880
|
342 virtual bool is_list (void) const |
|
343 { return rep->is_list (); } |
|
344 |
2376
|
345 virtual bool is_magic_colon (void) const |
|
346 { return rep->is_magic_colon (); } |
|
347 |
|
348 virtual bool is_all_va_args (void) const |
|
349 { return rep->is_all_va_args (); } |
|
350 |
|
351 // Are any or all of the elements in this constant nonzero? |
|
352 |
4015
|
353 virtual octave_value all (int dim = 0) const |
|
354 { return rep->all (dim); } |
2376
|
355 |
4015
|
356 virtual octave_value any (int dim = 0) const |
|
357 { return rep->any (dim); } |
2376
|
358 |
|
359 // Other type stuff. |
|
360 |
3209
|
361 virtual bool is_bool_type (void) const |
|
362 { return rep->is_bool_type (); } |
|
363 |
2376
|
364 virtual bool is_real_type (void) const |
|
365 { return rep->is_real_type (); } |
|
366 |
|
367 virtual bool is_complex_type (void) const |
|
368 { return rep->is_complex_type (); } |
|
369 |
|
370 virtual bool is_scalar_type (void) const |
|
371 { return rep->is_scalar_type (); } |
|
372 |
|
373 virtual bool is_matrix_type (void) const |
|
374 { return rep->is_matrix_type (); } |
|
375 |
|
376 virtual bool is_numeric_type (void) const |
|
377 { return rep->is_numeric_type (); } |
|
378 |
|
379 virtual bool valid_as_scalar_index (void) const |
|
380 { return rep->valid_as_scalar_index (); } |
|
381 |
|
382 virtual bool valid_as_zero_index (void) const |
|
383 { return rep->valid_as_zero_index (); } |
|
384 |
|
385 // Does this constant correspond to a truth value? |
|
386 |
|
387 virtual bool is_true (void) const |
|
388 { return rep->is_true (); } |
|
389 |
|
390 // Is at least one of the dimensions of this constant zero? |
|
391 |
|
392 virtual bool is_empty (void) const |
|
393 { return rep->is_empty (); } |
|
394 |
|
395 // Are the dimensions of this constant zero by zero? |
|
396 |
|
397 virtual bool is_zero_by_zero (void) const |
|
398 { return rep->is_zero_by_zero (); } |
|
399 |
2974
|
400 virtual bool is_constant (void) const |
|
401 { return rep->is_constant (); } |
|
402 |
|
403 virtual bool is_function (void) const |
|
404 { return rep->is_function (); } |
2891
|
405 |
3325
|
406 virtual bool is_builtin_function (void) const |
|
407 { return rep->is_builtin_function (); } |
|
408 |
|
409 virtual bool is_dld_function (void) const |
|
410 { return rep->is_dld_function (); } |
|
411 |
2376
|
412 // Values. |
|
413 |
2891
|
414 octave_value eval (void) { return *this; } |
|
415 |
3202
|
416 virtual int int_value (bool req_int = false, bool frc_str_conv = false) const |
|
417 { return rep->int_value (req_int, frc_str_conv); } |
|
418 |
|
419 virtual int nint_value (bool frc_str_conv = false) const |
|
420 { return rep->nint_value (frc_str_conv); } |
|
421 |
2376
|
422 virtual double double_value (bool frc_str_conv = false) const |
|
423 { return rep->double_value (frc_str_conv); } |
|
424 |
2916
|
425 virtual double scalar_value (bool frc_str_conv = false) const |
|
426 { return rep->scalar_value (frc_str_conv); } |
|
427 |
3351
|
428 virtual Cell cell_value (void) const; |
|
429 |
2376
|
430 virtual Matrix matrix_value (bool frc_str_conv = false) const |
|
431 { return rep->matrix_value (frc_str_conv); } |
|
432 |
|
433 virtual Complex complex_value (bool frc_str_conv = false) const |
|
434 { return rep->complex_value (frc_str_conv); } |
|
435 |
|
436 virtual ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const |
|
437 { return rep->complex_matrix_value (frc_str_conv); } |
|
438 |
|
439 virtual charMatrix char_matrix_value (bool frc_str_conv = false) const |
|
440 { return rep->char_matrix_value (frc_str_conv); } |
|
441 |
2493
|
442 virtual string_vector all_strings (void) const |
2376
|
443 { return rep->all_strings (); } |
|
444 |
3523
|
445 virtual std::string string_value (void) const |
2376
|
446 { return rep->string_value (); } |
|
447 |
|
448 virtual Range range_value (void) const |
|
449 { return rep->range_value (); } |
|
450 |
|
451 virtual Octave_map map_value (void) const; |
|
452 |
3933
|
453 virtual string_vector map_keys (void) const |
|
454 { return rep->map_keys (); } |
|
455 |
3340
|
456 virtual octave_stream stream_value (void) const; |
2903
|
457 |
|
458 virtual int stream_number (void) const; |
|
459 |
2974
|
460 virtual octave_function *function_value (bool silent = false); |
|
461 |
2880
|
462 virtual octave_value_list list_value (void) const; |
|
463 |
2825
|
464 virtual bool bool_value (void) const |
|
465 { return rep->bool_value (); } |
|
466 |
|
467 virtual boolMatrix bool_matrix_value (void) const |
|
468 { return rep->bool_matrix_value (); } |
|
469 |
3419
|
470 ColumnVector column_vector_value (bool frc_str_conv = false, |
2376
|
471 bool frc_vec_conv = false) const; |
|
472 |
|
473 ComplexColumnVector |
3419
|
474 complex_column_vector_value (bool frc_str_conv = false, |
2376
|
475 bool frc_vec_conv = false) const; |
|
476 |
3419
|
477 RowVector row_vector_value (bool frc_str_conv = false, |
|
478 bool frc_vec_conv = false) const; |
|
479 |
|
480 ComplexRowVector |
|
481 complex_row_vector_value (bool frc_str_conv = false, |
|
482 bool frc_vec_conv = false) const; |
|
483 |
|
484 Array<double> vector_value (bool frc_str_conv = false, |
|
485 bool frc_vec_conv = false) const; |
|
486 |
|
487 Array<Complex> complex_vector_value (bool frc_str_conv = false, |
|
488 bool frc_vec_conv = false) const; |
|
489 |
2376
|
490 // Conversions. These should probably be private. If a user of this |
|
491 // class wants a certain kind of constant, he should simply ask for |
|
492 // it, and we should convert it if possible. |
|
493 |
|
494 virtual octave_value convert_to_str (void) const |
|
495 { return rep->convert_to_str (); } |
|
496 |
|
497 virtual void convert_to_row_or_column_vector (void) |
|
498 { rep->convert_to_row_or_column_vector (); } |
|
499 |
3523
|
500 virtual void print (std::ostream& os, bool pr_as_read_syntax = false) const |
2466
|
501 { rep->print (os, pr_as_read_syntax); } |
2376
|
502 |
3523
|
503 virtual void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const |
2903
|
504 { rep->print_raw (os, pr_as_read_syntax); } |
|
505 |
3523
|
506 virtual bool print_name_tag (std::ostream& os, const std::string& name) const |
2903
|
507 { return rep->print_name_tag (os, name); } |
2376
|
508 |
3523
|
509 void print_with_name (std::ostream& os, const std::string& name, |
2903
|
510 bool print_padding = true) const; |
2376
|
511 |
|
512 virtual int type_id (void) const { return rep->type_id (); } |
|
513 |
3523
|
514 virtual std::string type_name (void) const { return rep->type_name (); } |
2376
|
515 |
3203
|
516 // Unary and binary operations. |
|
517 |
3933
|
518 friend octave_value do_unary_op (unary_op op, |
|
519 const octave_value& a); |
3203
|
520 |
3933
|
521 const octave_value& do_non_const_unary_op (unary_op op); |
|
522 |
|
523 void do_non_const_unary_op (unary_op op, const octave_value_list& idx); |
2376
|
524 |
3933
|
525 octave_value do_non_const_unary_op (unary_op op, const std::string type, |
|
526 const SLList<octave_value_list>& idx); |
3205
|
527 |
3933
|
528 friend octave_value do_binary_op (binary_op op, |
|
529 const octave_value& a, |
|
530 const octave_value& b); |
2376
|
531 |
3301
|
532 const octave_value& get_rep (void) const { return *rep; } |
|
533 |
3933
|
534 virtual void print_info (std::ostream& os, |
|
535 const std::string& prefix = std::string ()) const; |
|
536 |
2376
|
537 protected: |
|
538 |
|
539 octave_value (const octave_xvalue&) : rep (0) { } |
|
540 |
3933
|
541 // This should only be called for derived types. |
|
542 |
|
543 octave_value numeric_assign (const std::string type, |
|
544 const SLList<octave_value_list>& idx, |
|
545 const octave_value& rhs); |
|
546 |
2903
|
547 void reset_indent_level (void) const |
|
548 { curr_print_indent_level = 0; } |
|
549 |
|
550 void increment_indent_level (void) const |
|
551 { curr_print_indent_level += 2; } |
|
552 |
|
553 void decrement_indent_level (void) const |
|
554 { curr_print_indent_level -= 2; } |
|
555 |
|
556 int current_print_indent_level (void) const |
|
557 { return curr_print_indent_level; } |
|
558 |
3523
|
559 void newline (std::ostream& os) const; |
2903
|
560 |
3523
|
561 void indent (std::ostream& os) const; |
2903
|
562 |
|
563 void reset (void) const; |
|
564 |
2376
|
565 union |
|
566 { |
|
567 octave_value *rep; // The real representation. |
|
568 int count; // A reference count. |
|
569 }; |
2413
|
570 |
3933
|
571 private: |
2903
|
572 |
|
573 static int curr_print_indent_level; |
|
574 static bool beginning_of_line; |
3204
|
575 |
3205
|
576 assign_op unary_op_to_assign_op (unary_op op); |
|
577 |
3204
|
578 binary_op op_eq_to_binary_op (assign_op op); |
|
579 |
3219
|
580 DECLARE_OCTAVE_ALLOCATOR |
2376
|
581 }; |
|
582 |
3203
|
583 #define OV_UNOP_FN(name) \ |
|
584 inline octave_value \ |
|
585 name (const octave_value& a) \ |
|
586 { \ |
|
587 return do_unary_op (octave_value::name, a); \ |
|
588 } |
|
589 |
|
590 #define OV_UNOP_OP(name, op) \ |
|
591 inline octave_value \ |
|
592 operator op (const octave_value& a) \ |
|
593 { \ |
|
594 return name (a); \ |
|
595 } |
|
596 |
|
597 #define OV_UNOP_FN_OP(name, op) \ |
|
598 OV_UNOP_FN (name) \ |
|
599 OV_UNOP_OP (name, op) |
|
600 |
3525
|
601 OV_UNOP_FN_OP (op_not, !) |
|
602 OV_UNOP_FN_OP (op_uminus, -) |
3203
|
603 |
3525
|
604 OV_UNOP_FN (op_transpose) |
|
605 OV_UNOP_FN (op_hermitian) |
3203
|
606 |
|
607 // No simple way to define these for prefix and suffix ops? |
|
608 // |
|
609 // incr |
|
610 // decr |
|
611 |
|
612 #define OV_BINOP_FN(name) \ |
|
613 inline octave_value \ |
|
614 name (const octave_value& a1, const octave_value& a2) \ |
|
615 { \ |
|
616 return do_binary_op (octave_value::name, a1, a2); \ |
|
617 } |
|
618 |
|
619 #define OV_BINOP_OP(name, op) \ |
|
620 inline octave_value \ |
|
621 operator op (const octave_value& a1, const octave_value& a2) \ |
|
622 { \ |
|
623 return name (a1, a2); \ |
|
624 } |
|
625 |
|
626 #define OV_BINOP_FN_OP(name, op) \ |
|
627 OV_BINOP_FN (name) \ |
|
628 OV_BINOP_OP (name, op) |
|
629 |
3525
|
630 OV_BINOP_FN_OP (op_add, +) |
|
631 OV_BINOP_FN_OP (op_sub, -) |
|
632 OV_BINOP_FN_OP (op_mul, *) |
|
633 OV_BINOP_FN_OP (op_div, /) |
3203
|
634 |
3525
|
635 OV_BINOP_FN (op_pow) |
|
636 OV_BINOP_FN (op_ldiv) |
|
637 OV_BINOP_FN (op_lshift) |
|
638 OV_BINOP_FN (op_rshift) |
3203
|
639 |
3525
|
640 OV_BINOP_FN_OP (op_lt, <) |
|
641 OV_BINOP_FN_OP (op_le, <=) |
|
642 OV_BINOP_FN_OP (op_eq, ==) |
|
643 OV_BINOP_FN_OP (op_ge, >=) |
|
644 OV_BINOP_FN_OP (op_gt, >) |
|
645 OV_BINOP_FN_OP (op_ne, !=) |
3203
|
646 |
3525
|
647 OV_BINOP_FN (op_el_mul) |
|
648 OV_BINOP_FN (op_el_div) |
|
649 OV_BINOP_FN (op_el_pow) |
|
650 OV_BINOP_FN (op_el_ldiv) |
|
651 OV_BINOP_FN (op_el_and) |
|
652 OV_BINOP_FN (op_el_or) |
3203
|
653 |
3525
|
654 OV_BINOP_FN (op_struct_ref) |
3203
|
655 |
3219
|
656 // T_ID is the type id of struct objects, set by register_type(). |
|
657 // T_NAME is the type name of struct objects. |
|
658 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA \ |
|
659 public: \ |
|
660 int type_id (void) const { return t_id; } \ |
3523
|
661 std::string type_name (void) const { return t_name; } \ |
3301
|
662 static volatile int static_type_id (void) { return t_id; } \ |
3219
|
663 static void register_type (void) \ |
|
664 { t_id = octave_value_typeinfo::register_type (t_name); } \ |
|
665 \ |
|
666 private: \ |
3301
|
667 static volatile int t_id; \ |
3523
|
668 static const std::string t_name; |
3219
|
669 |
|
670 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n) \ |
3301
|
671 volatile int t::t_id (-1); \ |
3523
|
672 const std::string t::t_name (n) |
3219
|
673 |
2376
|
674 // If TRUE, allow assignments like |
|
675 // |
|
676 // octave> A(1) = 3; A(2) = 5 |
|
677 // |
|
678 // for A already defined and a matrix type. |
|
679 extern bool Vdo_fortran_indexing; |
|
680 |
|
681 // Should we allow things like: |
|
682 // |
|
683 // octave> 'abc' + 0 |
|
684 // 97 98 99 |
|
685 // |
|
686 // to happen? A positive value means yes. A negative value means |
|
687 // yes, but print a warning message. Zero means it should be |
|
688 // considered an error. |
|
689 extern int Vimplicit_str_to_num_ok; |
|
690 |
|
691 // Should we allow silent conversion of complex to real when a real |
|
692 // type is what we're really looking for? A positive value means yes. |
|
693 // A negative value means yes, but print a warning message. Zero |
|
694 // means it should be considered an error. |
|
695 extern int Vok_to_lose_imaginary_part; |
|
696 |
|
697 // If TRUE, print the name along with the value. |
|
698 extern bool Vprint_answer_id_name; |
|
699 |
|
700 // Should operations on empty matrices return empty matrices or an |
|
701 // error? A positive value means yes. A negative value means yes, |
|
702 // but print a warning message. Zero means it should be considered an |
|
703 // error. |
|
704 extern int Vpropagate_empty_matrices; |
|
705 |
|
706 // How many levels of structure elements should we print? |
|
707 extern int Vstruct_levels_to_print; |
|
708 |
|
709 // Allow divide by zero errors to be suppressed. |
|
710 extern bool Vwarn_divide_by_zero; |
|
711 |
3195
|
712 // If TRUE, resize matrices when performing and indexed assignment and |
|
713 // the indices are outside the current bounds. |
|
714 extern bool Vresize_on_range_error; |
|
715 |
2376
|
716 // Indentation level for structures. |
|
717 extern int struct_indent; |
|
718 |
|
719 extern void increment_struct_indent (void); |
|
720 extern void decrement_struct_indent (void); |
|
721 |
2880
|
722 // Indentation level for lists. |
|
723 extern int list_indent; |
|
724 |
|
725 extern void increment_list_indent (void); |
|
726 extern void decrement_list_indent (void); |
|
727 |
2376
|
728 extern void install_types (void); |
|
729 |
|
730 #endif |
|
731 |
|
732 /* |
|
733 ;; Local Variables: *** |
|
734 ;; mode: C++ *** |
|
735 ;; End: *** |
|
736 */ |