Mercurial > hg > octave-lyh
annotate src/ov.h @ 7761:5adeea5de26c
symbol table reporting functions
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 May 2008 05:51:17 -0400 |
parents | 39930366b709 |
children | 82be108cc558 |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
4 2006, 2007 John W. Eaton | |
2376 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2376 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_value_h) | |
25 #define octave_value_h 1 | |
26 | |
27 #include <cstdlib> | |
28 | |
3503 | 29 #include <iostream> |
2376 | 30 #include <string> |
4219 | 31 #include <list> |
2376 | 32 |
4687 | 33 #if defined (HAVE_HDF5) |
34 #include <hdf5.h> | |
35 #endif | |
4507 | 36 |
2376 | 37 #include "Range.h" |
5828 | 38 #include "data-conv.h" |
2376 | 39 #include "idx-vector.h" |
5828 | 40 #include "mach-info.h" |
5900 | 41 #include "mxarray.h" |
2376 | 42 #include "mx-base.h" |
2477 | 43 #include "oct-alloc.h" |
4254 | 44 #include "oct-time.h" |
2942 | 45 #include "str-vec.h" |
46 | |
7433 | 47 #include "oct-sort.h" |
48 | |
3351 | 49 class Cell; |
4643 | 50 class streamoff_array; |
2376 | 51 class Octave_map; |
2903 | 52 class octave_stream; |
4643 | 53 class octave_streamoff; |
2974 | 54 class octave_function; |
4700 | 55 class octave_user_function; |
4342 | 56 class octave_fcn_handle; |
4933 | 57 class octave_fcn_inline; |
2376 | 58 class octave_value_list; |
2979 | 59 class octave_lvalue; |
2376 | 60 |
5759 | 61 #include "ov-base.h" |
2376 | 62 |
5759 | 63 // Constants. |
2376 | 64 |
2427 | 65 class octave_value; |
66 | |
2376 | 67 class |
6109 | 68 OCTINTERP_API |
2974 | 69 octave_value |
2376 | 70 { |
71 public: | |
72 | |
3203 | 73 enum unary_op |
74 { | |
6518 | 75 op_not, // not |
76 op_uplus, // uplus | |
77 op_uminus, // uminus | |
78 op_transpose, // transpose | |
79 op_hermitian, // ctranspose | |
3525 | 80 op_incr, |
81 op_decr, | |
3203 | 82 num_unary_ops, |
83 unknown_unary_op | |
84 }; | |
85 | |
2376 | 86 enum binary_op |
87 { | |
6518 | 88 op_add, // plus |
89 op_sub, // minus | |
90 op_mul, // mtimes | |
91 op_div, // mrdivide | |
92 op_pow, // mpower | |
93 op_ldiv, // mldivide | |
3525 | 94 op_lshift, |
95 op_rshift, | |
6518 | 96 op_lt, // lt |
97 op_le, // le | |
98 op_eq, // eq | |
99 op_ge, // ge | |
100 op_gt, // gt | |
101 op_ne, // ne | |
102 op_el_mul, // times | |
103 op_el_div, // rdivide | |
104 op_el_pow, // power | |
105 op_el_ldiv, // ldivide | |
106 op_el_and, // and | |
107 op_el_or, // or | |
3525 | 108 op_struct_ref, |
2376 | 109 num_binary_ops, |
110 unknown_binary_op | |
111 }; | |
112 | |
2880 | 113 enum assign_op |
114 { | |
3525 | 115 op_asn_eq, |
116 op_add_eq, | |
117 op_sub_eq, | |
118 op_mul_eq, | |
119 op_div_eq, | |
120 op_ldiv_eq, | |
4018 | 121 op_pow_eq, |
3525 | 122 op_lshift_eq, |
123 op_rshift_eq, | |
124 op_el_mul_eq, | |
125 op_el_div_eq, | |
126 op_el_ldiv_eq, | |
4018 | 127 op_el_pow_eq, |
3525 | 128 op_el_and_eq, |
129 op_el_or_eq, | |
2880 | 130 num_assign_ops, |
131 unknown_assign_op | |
132 }; | |
133 | |
3523 | 134 static std::string unary_op_as_string (unary_op); |
7336 | 135 static std::string unary_op_fcn_name (unary_op); |
3203 | 136 |
3523 | 137 static std::string binary_op_as_string (binary_op); |
7336 | 138 static std::string binary_op_fcn_name (binary_op); |
2376 | 139 |
3523 | 140 static std::string assign_op_as_string (assign_op); |
2880 | 141 |
3933 | 142 static octave_value empty_conv (const std::string& type, |
143 const octave_value& rhs = octave_value ()); | |
144 | |
2376 | 145 enum magic_colon { magic_colon_t }; |
146 | |
147 octave_value (void); | |
4254 | 148 octave_value (short int i); |
149 octave_value (unsigned short int i); | |
4233 | 150 octave_value (int i); |
4254 | 151 octave_value (unsigned int i); |
152 octave_value (long int i); | |
153 octave_value (unsigned long int i); | |
4353 | 154 |
5775 | 155 // FIXME -- these are kluges. They turn into doubles |
4353 | 156 // internally, which will break for very large values. We just use |
157 // them to store things like 64-bit ino_t, etc, and hope that those | |
158 // values are never actually larger than can be represented exactly | |
159 // in a double. | |
160 | |
161 #if defined (HAVE_LONG_LONG_INT) | |
162 octave_value (long long int i); | |
163 #endif | |
4356 | 164 #if defined (HAVE_UNSIGNED_LONG_LONG_INT) |
4353 | 165 octave_value (unsigned long long int i); |
166 #endif | |
167 | |
4254 | 168 octave_value (octave_time t); |
2376 | 169 octave_value (double d); |
5147 | 170 octave_value (const ArrayN<octave_value>& a, bool is_cs_list = false); |
4532 | 171 octave_value (const Cell& c, bool is_cs_list = false); |
5785 | 172 octave_value (const Matrix& m, const MatrixType& t = MatrixType()); |
4513 | 173 octave_value (const NDArray& nda); |
4911 | 174 octave_value (const ArrayN<double>& m); |
2376 | 175 octave_value (const DiagMatrix& d); |
3418 | 176 octave_value (const RowVector& v); |
177 octave_value (const ColumnVector& v); | |
2376 | 178 octave_value (const Complex& C); |
5785 | 179 octave_value (const ComplexMatrix& m, const MatrixType& t = MatrixType()); |
4513 | 180 octave_value (const ComplexNDArray& cnda); |
4478 | 181 octave_value (const ArrayN<Complex>& m); |
2376 | 182 octave_value (const ComplexDiagMatrix& d); |
3418 | 183 octave_value (const ComplexRowVector& v); |
184 octave_value (const ComplexColumnVector& v); | |
2825 | 185 octave_value (bool b); |
5785 | 186 octave_value (const boolMatrix& bm, const MatrixType& t = MatrixType()); |
4513 | 187 octave_value (const boolNDArray& bnda); |
7433 | 188 octave_value (const ArrayN<bool>& bnda); |
5279 | 189 octave_value (char c, char type = '"'); |
190 octave_value (const char *s, char type = '"'); | |
191 octave_value (const std::string& s, char type = '"'); | |
192 octave_value (const string_vector& s, char type = '"'); | |
193 octave_value (const charMatrix& chm, bool is_string = false, | |
194 char type = '"'); | |
195 octave_value (const charNDArray& chnda, bool is_string = false, | |
196 char type = '"'); | |
197 octave_value (const ArrayN<char>& chnda, bool is_string = false, | |
198 char type = '"'); | |
5785 | 199 octave_value (const SparseMatrix& m, const MatrixType& t = MatrixType ()); |
6863 | 200 octave_value (const Sparse<double>& m, const MatrixType& t = MatrixType ()); |
5164 | 201 octave_value (const SparseComplexMatrix& m, |
5785 | 202 const MatrixType& t = MatrixType ()); |
6863 | 203 octave_value (const Sparse<Complex>& m, const MatrixType& t = MatrixType ()); |
5164 | 204 octave_value (const SparseBoolMatrix& bm, |
5785 | 205 const MatrixType& t = MatrixType ()); |
7433 | 206 octave_value (const Sparse<bool>& m, const MatrixType& t = MatrixType ()); |
4901 | 207 octave_value (const octave_int8& i); |
4910 | 208 octave_value (const octave_int16& i); |
209 octave_value (const octave_int32& i); | |
210 octave_value (const octave_int64& i); | |
4901 | 211 octave_value (const octave_uint8& i); |
212 octave_value (const octave_uint16& i); | |
213 octave_value (const octave_uint32& i); | |
214 octave_value (const octave_uint64& i); | |
215 octave_value (const int8NDArray& inda); | |
7064 | 216 octave_value (const ArrayN<octave_int8>& inda); |
4910 | 217 octave_value (const int16NDArray& inda); |
7064 | 218 octave_value (const ArrayN<octave_int16>& inda); |
4910 | 219 octave_value (const int32NDArray& inda); |
7064 | 220 octave_value (const ArrayN<octave_int32>& inda); |
4910 | 221 octave_value (const int64NDArray& inda); |
7064 | 222 octave_value (const ArrayN<octave_int64>& inda); |
4901 | 223 octave_value (const uint8NDArray& inda); |
7064 | 224 octave_value (const ArrayN<octave_uint8>& inda); |
4901 | 225 octave_value (const uint16NDArray& inda); |
7064 | 226 octave_value (const ArrayN<octave_uint16>& inda); |
4901 | 227 octave_value (const uint32NDArray& inda); |
7064 | 228 octave_value (const ArrayN<octave_uint32>& inda); |
4901 | 229 octave_value (const uint64NDArray& inda); |
7064 | 230 octave_value (const ArrayN<octave_uint64>& inda); |
2376 | 231 octave_value (double base, double limit, double inc); |
232 octave_value (const Range& r); | |
233 octave_value (const Octave_map& m); | |
7336 | 234 octave_value (const Octave_map& m, const std::string& id); |
4643 | 235 octave_value (const streamoff_array& off); |
7433 | 236 octave_value (const ArrayN<std::streamoff>& inda); |
3977 | 237 octave_value (const octave_value_list& m, bool is_cs_list = false); |
2376 | 238 octave_value (octave_value::magic_colon); |
239 | |
5759 | 240 octave_value (octave_base_value *new_rep); |
7336 | 241 octave_value (octave_base_value *new_rep, int xcount); |
2376 | 242 |
243 // Copy constructor. | |
244 | |
245 octave_value (const octave_value& a) | |
246 { | |
247 rep = a.rep; | |
248 rep->count++; | |
249 } | |
250 | |
3933 | 251 // This should only be called for derived types. |
252 | |
5759 | 253 octave_base_value *clone (void) const; |
3933 | 254 |
5759 | 255 octave_base_value *empty_clone (void) const |
3933 | 256 { return rep->empty_clone (); } |
257 | |
2376 | 258 // Delete the representation of this constant if the count drops to |
259 // zero. | |
260 | |
6338 | 261 ~octave_value (void) |
262 { | |
263 if (--rep->count == 0) | |
264 delete rep; | |
265 } | |
2376 | 266 |
267 void make_unique (void) | |
268 { | |
269 if (rep->count > 1) | |
270 { | |
271 --rep->count; | |
272 rep = rep->clone (); | |
273 rep->count = 1; | |
274 } | |
275 } | |
276 | |
277 // Simple assignment. | |
278 | |
279 octave_value& operator = (const octave_value& a) | |
280 { | |
281 if (rep != a.rep) | |
282 { | |
283 if (--rep->count == 0) | |
284 delete rep; | |
285 | |
286 rep = a.rep; | |
287 rep->count++; | |
288 } | |
289 | |
290 return *this; | |
291 } | |
292 | |
3933 | 293 int get_count (void) const { return rep->count; } |
3239 | 294 |
5759 | 295 octave_base_value::type_conv_fcn numeric_conversion_function (void) const |
2376 | 296 { return rep->numeric_conversion_function (); } |
297 | |
2409 | 298 void maybe_mutate (void); |
299 | |
5759 | 300 octave_value squeeze (void) const |
4532 | 301 { return rep->squeeze (); } |
302 | |
5759 | 303 octave_base_value *try_narrowing_conversion (void) |
2410 | 304 { return rep->try_narrowing_conversion (); } |
2409 | 305 |
4271 | 306 octave_value single_subsref (const std::string& type, |
307 const octave_value_list& idx); | |
308 | |
5759 | 309 octave_value subsref (const std::string& type, |
4219 | 310 const std::list<octave_value_list>& idx) |
3933 | 311 { return rep->subsref (type, idx); } |
312 | |
5759 | 313 octave_value_list subsref (const std::string& type, |
4219 | 314 const std::list<octave_value_list>& idx, |
3933 | 315 int nargout); |
316 | |
4247 | 317 octave_value next_subsref (const std::string& type, const |
4219 | 318 std::list<octave_value_list>& idx, |
4233 | 319 size_t skip = 1); |
3933 | 320 |
4994 | 321 octave_value_list next_subsref (int nargout, |
322 const std::string& type, const | |
323 std::list<octave_value_list>& idx, | |
324 size_t skip = 1); | |
325 | |
5759 | 326 octave_value do_index_op (const octave_value_list& idx, |
5885 | 327 bool resize_ok = false) |
3933 | 328 { return rep->do_index_op (idx, resize_ok); } |
329 | |
5759 | 330 octave_value_list |
3544 | 331 do_multi_index_op (int nargout, const octave_value_list& idx); |
2974 | 332 |
5759 | 333 octave_value subsasgn (const std::string& type, |
4219 | 334 const std::list<octave_value_list>& idx, |
3933 | 335 const octave_value& rhs); |
2376 | 336 |
4247 | 337 octave_value assign (assign_op op, const std::string& type, |
4219 | 338 const std::list<octave_value_list>& idx, |
3933 | 339 const octave_value& rhs); |
2948 | 340 |
3933 | 341 const octave_value& assign (assign_op, const octave_value& rhs); |
2948 | 342 |
5759 | 343 idx_vector index_vector (void) const |
2376 | 344 { return rep->index_vector (); } |
345 | |
346 // Size. | |
347 | |
5759 | 348 dim_vector dims (void) const |
4513 | 349 { return rep->dims (); } |
350 | |
5759 | 351 octave_idx_type rows (void) const { return rep->rows (); } |
4563 | 352 |
5759 | 353 octave_idx_type columns (void) const { return rep->columns (); } |
3195 | 354 |
5275 | 355 octave_idx_type length (void) const; |
4554 | 356 |
5759 | 357 int ndims (void) const { return rep->ndims (); } |
4563 | 358 |
5164 | 359 bool all_zero_dims (void) const { return dims().all_zero (); } |
360 | |
5759 | 361 octave_idx_type numel (void) const |
5080 | 362 { return rep->numel (); } |
4559 | 363 |
5759 | 364 octave_idx_type capacity (void) const |
5164 | 365 { return rep->capacity (); } |
366 | |
5659 | 367 Matrix size (void) const; |
368 | |
5759 | 369 size_t byte_size (void) const |
4791 | 370 { return rep->byte_size (); } |
371 | |
5759 | 372 octave_idx_type nnz (void) const { return rep->nnz (); } |
5602 | 373 |
5759 | 374 octave_idx_type nzmax (void) const { return rep->nzmax (); } |
5604 | 375 |
5900 | 376 octave_idx_type nfields (void) const { return rep->nfields (); } |
377 | |
5759 | 378 octave_value reshape (const dim_vector& dv) const |
4587 | 379 { return rep->reshape (dv); } |
4567 | 380 |
5759 | 381 octave_value permute (const Array<int>& vec, bool inv = false) const |
4593 | 382 { return rep->permute (vec, inv); } |
383 | |
384 octave_value ipermute (const Array<int>& vec) const | |
385 { return rep->permute (vec, true); } | |
386 | |
5759 | 387 octave_value resize (const dim_vector& dv, bool fill = false) const |
388 { return rep->resize (dv, fill);} | |
4915 | 389 |
5785 | 390 MatrixType matrix_type (void) const |
391 { return rep->matrix_type (); } | |
392 | |
393 MatrixType matrix_type (const MatrixType& typ) const | |
394 { return rep->matrix_type (typ); } | |
395 | |
2376 | 396 // Does this constant have a type? Both of these are provided since |
397 // it is sometimes more natural to write is_undefined() instead of | |
398 // ! is_defined(). | |
399 | |
5759 | 400 bool is_defined (void) const |
2376 | 401 { return rep->is_defined (); } |
402 | |
403 bool is_undefined (void) const | |
404 { return ! is_defined (); } | |
405 | |
4559 | 406 bool is_empty (void) const |
5759 | 407 { return rep->is_empty (); } |
4559 | 408 |
5759 | 409 bool is_cell (void) const |
3351 | 410 { return rep->is_cell (); } |
411 | |
6116 | 412 bool is_cellstr (void) const |
413 { return rep->is_cellstr (); } | |
414 | |
5759 | 415 bool is_real_scalar (void) const |
2376 | 416 { return rep->is_real_scalar (); } |
417 | |
5759 | 418 bool is_real_matrix (void) const |
2376 | 419 { return rep->is_real_matrix (); } |
420 | |
5759 | 421 bool is_real_nd_array (void) const |
4505 | 422 { return rep->is_real_nd_array (); } |
423 | |
5759 | 424 bool is_complex_scalar (void) const |
2376 | 425 { return rep->is_complex_scalar (); } |
426 | |
5759 | 427 bool is_complex_matrix (void) const |
2376 | 428 { return rep->is_complex_matrix (); } |
429 | |
5881 | 430 bool is_bool_scalar (void) const |
431 { return rep->is_bool_scalar (); } | |
432 | |
5759 | 433 bool is_bool_matrix (void) const |
4587 | 434 { return rep->is_bool_matrix (); } |
435 | |
5759 | 436 bool is_char_matrix (void) const |
2376 | 437 { return rep->is_char_matrix (); } |
438 | |
5759 | 439 bool is_string (void) const |
2376 | 440 { return rep->is_string (); } |
441 | |
5759 | 442 bool is_sq_string (void) const |
5279 | 443 { return rep->is_sq_string (); } |
444 | |
5280 | 445 bool is_dq_string (void) const |
446 { return rep->is_string () && ! rep->is_sq_string (); } | |
447 | |
5759 | 448 bool is_range (void) const |
2376 | 449 { return rep->is_range (); } |
450 | |
5759 | 451 bool is_map (void) const |
2376 | 452 { return rep->is_map (); } |
453 | |
7336 | 454 bool is_object (void) const |
455 { return rep->is_object (); } | |
456 | |
5759 | 457 bool is_streamoff (void) const |
4643 | 458 { return rep->is_streamoff (); } |
459 | |
5759 | 460 bool is_cs_list (void) const |
3977 | 461 { return rep->is_cs_list (); } |
462 | |
5759 | 463 bool is_list (void) const |
2880 | 464 { return rep->is_list (); } |
465 | |
5759 | 466 bool is_magic_colon (void) const |
2376 | 467 { return rep->is_magic_colon (); } |
468 | |
469 // Are any or all of the elements in this constant nonzero? | |
470 | |
5759 | 471 octave_value all (int dim = 0) const |
4015 | 472 { return rep->all (dim); } |
2376 | 473 |
5759 | 474 octave_value any (int dim = 0) const |
4015 | 475 { return rep->any (dim); } |
2376 | 476 |
5895 | 477 // Floating point types. |
478 | |
479 bool is_double_type (void) const | |
480 { return rep->is_double_type (); } | |
481 | |
482 bool is_single_type (void) const | |
483 { return rep->is_single_type (); } | |
484 | |
7576 | 485 bool is_float_type (void) const |
486 { return rep->is_float_type (); } | |
487 | |
5895 | 488 // Integer types. |
489 | |
490 bool is_int8_type (void) const | |
491 { return rep->is_int8_type (); } | |
492 | |
493 bool is_int16_type (void) const | |
494 { return rep->is_int16_type (); } | |
495 | |
496 bool is_int32_type (void) const | |
497 { return rep->is_int32_type (); } | |
498 | |
499 bool is_int64_type (void) const | |
500 { return rep->is_int64_type (); } | |
501 | |
502 bool is_uint8_type (void) const | |
503 { return rep->is_uint8_type (); } | |
504 | |
505 bool is_uint16_type (void) const | |
506 { return rep->is_uint16_type (); } | |
507 | |
508 bool is_uint32_type (void) const | |
509 { return rep->is_uint32_type (); } | |
510 | |
511 bool is_uint64_type (void) const | |
512 { return rep->is_uint64_type (); } | |
513 | |
2376 | 514 // Other type stuff. |
515 | |
5759 | 516 bool is_bool_type (void) const |
3209 | 517 { return rep->is_bool_type (); } |
518 | |
6223 | 519 bool is_integer_type (void) const |
520 { return rep->is_integer_type (); } | |
521 | |
5759 | 522 bool is_real_type (void) const |
2376 | 523 { return rep->is_real_type (); } |
524 | |
5759 | 525 bool is_complex_type (void) const |
2376 | 526 { return rep->is_complex_type (); } |
527 | |
5759 | 528 bool is_scalar_type (void) const |
2376 | 529 { return rep->is_scalar_type (); } |
530 | |
5759 | 531 bool is_matrix_type (void) const |
2376 | 532 { return rep->is_matrix_type (); } |
533 | |
5759 | 534 bool is_numeric_type (void) const |
2376 | 535 { return rep->is_numeric_type (); } |
536 | |
5759 | 537 bool is_sparse_type (void) const |
5631 | 538 { return rep->is_sparse_type (); } |
539 | |
5759 | 540 bool valid_as_scalar_index (void) const |
2376 | 541 { return rep->valid_as_scalar_index (); } |
542 | |
5759 | 543 bool valid_as_zero_index (void) const |
2376 | 544 { return rep->valid_as_zero_index (); } |
545 | |
546 // Does this constant correspond to a truth value? | |
547 | |
5759 | 548 bool is_true (void) const |
2376 | 549 { return rep->is_true (); } |
550 | |
551 // Are the dimensions of this constant zero by zero? | |
552 | |
5759 | 553 bool is_zero_by_zero (void) const |
554 { return (rows () == 0 && columns () == 0); } | |
2376 | 555 |
5759 | 556 bool is_constant (void) const |
2974 | 557 { return rep->is_constant (); } |
558 | |
5759 | 559 bool is_function_handle (void) const |
4654 | 560 { return rep->is_function_handle (); } |
561 | |
5759 | 562 bool is_inline_function (void) const |
4954 | 563 { return rep->is_inline_function (); } |
564 | |
5759 | 565 bool is_function (void) const |
2974 | 566 { return rep->is_function (); } |
2891 | 567 |
7336 | 568 bool is_user_script (void) const |
569 { return rep->is_user_script (); } | |
570 | |
571 bool is_user_function (void) const | |
572 { return rep->is_user_function (); } | |
573 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
574 bool is_user_code (void) const |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
575 { return rep->is_user_code (); } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
576 |
5759 | 577 bool is_builtin_function (void) const |
3325 | 578 { return rep->is_builtin_function (); } |
579 | |
5759 | 580 bool is_dld_function (void) const |
3325 | 581 { return rep->is_dld_function (); } |
582 | |
5864 | 583 bool is_mex_function (void) const |
584 { return rep->is_mex_function (); } | |
585 | |
2376 | 586 // Values. |
587 | |
2891 | 588 octave_value eval (void) { return *this; } |
589 | |
5759 | 590 short int |
4254 | 591 short_value (bool req_int = false, bool frc_str_conv = false) const |
592 { return rep->short_value (req_int, frc_str_conv); } | |
593 | |
5759 | 594 unsigned short int |
4254 | 595 ushort_value (bool req_int = false, bool frc_str_conv = false) const |
596 { return rep->ushort_value (req_int, frc_str_conv); } | |
597 | |
5759 | 598 int int_value (bool req_int = false, bool frc_str_conv = false) const |
3202 | 599 { return rep->int_value (req_int, frc_str_conv); } |
600 | |
5759 | 601 unsigned int |
4254 | 602 uint_value (bool req_int = false, bool frc_str_conv = false) const |
603 { return rep->uint_value (req_int, frc_str_conv); } | |
604 | |
5759 | 605 int nint_value (bool frc_str_conv = false) const |
3202 | 606 { return rep->nint_value (frc_str_conv); } |
607 | |
5759 | 608 long int |
4254 | 609 long_value (bool req_int = false, bool frc_str_conv = false) const |
610 { return rep->long_value (req_int, frc_str_conv); } | |
611 | |
5759 | 612 unsigned long int |
4254 | 613 ulong_value (bool req_int = false, bool frc_str_conv = false) const |
614 { return rep->ulong_value (req_int, frc_str_conv); } | |
615 | |
6133 | 616 octave_idx_type |
617 idx_type_value (bool req_int = false, bool frc_str_conv = false) const | |
618 { | |
619 #if SIZEOF_OCTAVE_IDX_TYPE == SIZEOF_LONG | |
620 return long_value (req_int, frc_str_conv); | |
621 #elif SIZEOF_OCTAVE_IDX_TYPE == SIZEOF_INT | |
622 return int_value (req_int, frc_str_conv); | |
623 #else | |
624 #error "no octave_value extractor for octave_idx_type" | |
625 #endif | |
626 } | |
627 | |
5759 | 628 double double_value (bool frc_str_conv = false) const |
2376 | 629 { return rep->double_value (frc_str_conv); } |
630 | |
5759 | 631 double scalar_value (bool frc_str_conv = false) const |
2916 | 632 { return rep->scalar_value (frc_str_conv); } |
633 | |
5759 | 634 Cell cell_value (void) const; |
3351 | 635 |
5759 | 636 Matrix matrix_value (bool frc_str_conv = false) const |
2376 | 637 { return rep->matrix_value (frc_str_conv); } |
638 | |
5759 | 639 NDArray array_value (bool frc_str_conv = false) const |
4550 | 640 { return rep->array_value (frc_str_conv); } |
4505 | 641 |
5759 | 642 Complex complex_value (bool frc_str_conv = false) const |
2376 | 643 { return rep->complex_value (frc_str_conv); } |
644 | |
5759 | 645 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const |
2376 | 646 { return rep->complex_matrix_value (frc_str_conv); } |
647 | |
5759 | 648 ComplexNDArray complex_array_value (bool frc_str_conv = false) const |
4550 | 649 { return rep->complex_array_value (frc_str_conv); } |
650 | |
5943 | 651 bool bool_value (bool warn = false) const |
652 { return rep->bool_value (warn); } | |
4550 | 653 |
5943 | 654 boolMatrix bool_matrix_value (bool warn = false) const |
655 { return rep->bool_matrix_value (warn); } | |
4550 | 656 |
5943 | 657 boolNDArray bool_array_value (bool warn = false) const |
658 { return rep->bool_array_value (warn); } | |
4550 | 659 |
5759 | 660 charMatrix char_matrix_value (bool frc_str_conv = false) const |
2376 | 661 { return rep->char_matrix_value (frc_str_conv); } |
662 | |
5759 | 663 charNDArray char_array_value (bool frc_str_conv = false) const |
4550 | 664 { return rep->char_array_value (frc_str_conv); } |
665 | |
5759 | 666 SparseMatrix sparse_matrix_value (bool frc_str_conv = false) const |
667 { return rep->sparse_matrix_value (frc_str_conv); } | |
5164 | 668 |
5759 | 669 SparseComplexMatrix sparse_complex_matrix_value (bool frc_str_conv = false) const |
670 { return rep->sparse_complex_matrix_value (frc_str_conv); } | |
5164 | 671 |
5759 | 672 SparseBoolMatrix sparse_bool_matrix_value (bool frc_str_conv = false) const |
673 { return rep->sparse_bool_matrix_value (frc_str_conv); } | |
5164 | 674 |
5759 | 675 octave_int8 int8_scalar_value (void) const |
4910 | 676 { return rep->int8_scalar_value (); } |
677 | |
5759 | 678 octave_int16 int16_scalar_value (void) const |
4910 | 679 { return rep->int16_scalar_value (); } |
680 | |
5759 | 681 octave_int32 int32_scalar_value (void) const |
4910 | 682 { return rep->int32_scalar_value (); } |
683 | |
5759 | 684 octave_int64 int64_scalar_value (void) const |
4910 | 685 { return rep->int64_scalar_value (); } |
686 | |
5759 | 687 octave_uint8 uint8_scalar_value (void) const |
4910 | 688 { return rep->uint8_scalar_value (); } |
689 | |
5759 | 690 octave_uint16 uint16_scalar_value (void) const |
4910 | 691 { return rep->uint16_scalar_value (); } |
692 | |
5759 | 693 octave_uint32 uint32_scalar_value (void) const |
4910 | 694 { return rep->uint32_scalar_value (); } |
695 | |
5759 | 696 octave_uint64 uint64_scalar_value (void) const |
4910 | 697 { return rep->uint64_scalar_value (); } |
698 | |
5759 | 699 int8NDArray int8_array_value (void) const |
4906 | 700 { return rep->int8_array_value (); } |
701 | |
5759 | 702 int16NDArray int16_array_value (void) const |
4906 | 703 { return rep->int16_array_value (); } |
704 | |
5759 | 705 int32NDArray int32_array_value (void) const |
4906 | 706 { return rep->int32_array_value (); } |
707 | |
5759 | 708 int64NDArray int64_array_value (void) const |
4906 | 709 { return rep->int64_array_value (); } |
710 | |
5759 | 711 uint8NDArray uint8_array_value (void) const |
4906 | 712 { return rep->uint8_array_value (); } |
713 | |
5759 | 714 uint16NDArray uint16_array_value (void) const |
4906 | 715 { return rep->uint16_array_value (); } |
716 | |
5759 | 717 uint32NDArray uint32_array_value (void) const |
4906 | 718 { return rep->uint32_array_value (); } |
719 | |
5759 | 720 uint64NDArray uint64_array_value (void) const |
4906 | 721 { return rep->uint64_array_value (); } |
722 | |
5759 | 723 string_vector all_strings (bool pad = false) const |
5715 | 724 { return rep->all_strings (pad); } |
2376 | 725 |
5759 | 726 std::string string_value (bool force = false) const |
4665 | 727 { return rep->string_value (force); } |
2376 | 728 |
5759 | 729 Range range_value (void) const |
2376 | 730 { return rep->range_value (); } |
731 | |
5759 | 732 Octave_map map_value (void) const; |
2376 | 733 |
5759 | 734 string_vector map_keys (void) const |
3933 | 735 { return rep->map_keys (); } |
736 | |
5759 | 737 std::streamoff streamoff_value (void) const; |
4645 | 738 |
5759 | 739 streamoff_array streamoff_array_value (void) const; |
4643 | 740 |
5759 | 741 octave_function *function_value (bool silent = false); |
2974 | 742 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
743 const octave_function *function_value (bool silent = false) const; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
744 |
5759 | 745 octave_user_function *user_function_value (bool silent = false); |
4700 | 746 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
747 octave_user_script *user_script_value (bool silent = false); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
748 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
749 octave_user_code *user_code_value (bool silent = false); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7638
diff
changeset
|
750 |
5759 | 751 octave_fcn_handle *fcn_handle_value (bool silent = false); |
4343 | 752 |
5759 | 753 octave_fcn_inline *fcn_inline_value (bool silent = false); |
4933 | 754 |
5759 | 755 octave_value_list list_value (void) const; |
2880 | 756 |
3419 | 757 ColumnVector column_vector_value (bool frc_str_conv = false, |
2376 | 758 bool frc_vec_conv = false) const; |
759 | |
760 ComplexColumnVector | |
3419 | 761 complex_column_vector_value (bool frc_str_conv = false, |
2376 | 762 bool frc_vec_conv = false) const; |
763 | |
3419 | 764 RowVector row_vector_value (bool frc_str_conv = false, |
765 bool frc_vec_conv = false) const; | |
766 | |
767 ComplexRowVector | |
768 complex_row_vector_value (bool frc_str_conv = false, | |
769 bool frc_vec_conv = false) const; | |
770 | |
4044 | 771 Array<int> int_vector_value (bool req_int = false, |
772 bool frc_str_conv = false, | |
773 bool frc_vec_conv = false) const; | |
774 | |
3419 | 775 Array<double> vector_value (bool frc_str_conv = false, |
776 bool frc_vec_conv = false) const; | |
777 | |
778 Array<Complex> complex_vector_value (bool frc_str_conv = false, | |
779 bool frc_vec_conv = false) const; | |
780 | |
2376 | 781 // Conversions. These should probably be private. If a user of this |
782 // class wants a certain kind of constant, he should simply ask for | |
783 // it, and we should convert it if possible. | |
784 | |
5279 | 785 octave_value convert_to_str (bool pad = false, bool force = false, |
5759 | 786 char type = '"') const |
787 { return rep->convert_to_str (pad, force, type); } | |
4452 | 788 |
5759 | 789 octave_value |
5279 | 790 convert_to_str_internal (bool pad, bool force, char type) const |
791 { return rep->convert_to_str_internal (pad, force, type); } | |
2376 | 792 |
5759 | 793 void convert_to_row_or_column_vector (void) |
2376 | 794 { rep->convert_to_row_or_column_vector (); } |
795 | |
5759 | 796 bool print_as_scalar (void) const |
4604 | 797 { return rep->print_as_scalar (); } |
798 | |
5759 | 799 void print (std::ostream& os, bool pr_as_read_syntax = false) const |
2466 | 800 { rep->print (os, pr_as_read_syntax); } |
2376 | 801 |
5759 | 802 void print_raw (std::ostream& os, |
4457 | 803 bool pr_as_read_syntax = false) const |
2903 | 804 { rep->print_raw (os, pr_as_read_syntax); } |
805 | |
5759 | 806 bool print_name_tag (std::ostream& os, const std::string& name) const |
2903 | 807 { return rep->print_name_tag (os, name); } |
2376 | 808 |
3523 | 809 void print_with_name (std::ostream& os, const std::string& name, |
5759 | 810 bool print_padding = true) const |
811 { rep->print_with_name (os, name, print_padding); } | |
2376 | 812 |
5759 | 813 int type_id (void) const { return rep->type_id (); } |
2376 | 814 |
5759 | 815 std::string type_name (void) const { return rep->type_name (); } |
816 | |
817 std::string class_name (void) const { return rep->class_name (); } | |
4612 | 818 |
3203 | 819 // Unary and binary operations. |
820 | |
6109 | 821 friend OCTINTERP_API octave_value do_unary_op (unary_op op, |
3933 | 822 const octave_value& a); |
3203 | 823 |
3933 | 824 const octave_value& do_non_const_unary_op (unary_op op); |
825 | |
826 void do_non_const_unary_op (unary_op op, const octave_value_list& idx); | |
2376 | 827 |
4247 | 828 octave_value do_non_const_unary_op (unary_op op, const std::string& type, |
4219 | 829 const std::list<octave_value_list>& idx); |
3205 | 830 |
6109 | 831 friend OCTINTERP_API octave_value do_binary_op (binary_op op, |
3933 | 832 const octave_value& a, |
833 const octave_value& b); | |
2376 | 834 |
6109 | 835 friend OCTINTERP_API octave_value do_cat_op (const octave_value& a, |
4915 | 836 const octave_value& b, |
6867 | 837 const Array<octave_idx_type>& ra_idx); |
4915 | 838 |
5759 | 839 const octave_base_value& get_rep (void) const { return *rep; } |
3301 | 840 |
5759 | 841 void print_info (std::ostream& os, |
3933 | 842 const std::string& prefix = std::string ()) const; |
843 | |
6974 | 844 bool save_ascii (std::ostream& os) { return rep->save_ascii (os); } |
4687 | 845 |
6974 | 846 bool load_ascii (std::istream& is) { return rep->load_ascii (is); } |
4687 | 847 |
5759 | 848 bool save_binary (std::ostream& os, bool& save_as_floats) |
4687 | 849 { return rep->save_binary (os, save_as_floats); } |
850 | |
5759 | 851 bool load_binary (std::istream& is, bool swap, |
4687 | 852 oct_mach_info::float_format fmt) |
853 { return rep->load_binary (is, swap, fmt); } | |
854 | |
855 #if defined (HAVE_HDF5) | |
5759 | 856 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) |
4687 | 857 { return rep->save_hdf5 (loc_id, name, save_as_floats); } |
858 | |
5759 | 859 bool load_hdf5 (hid_t loc_id, const char *name, |
4687 | 860 bool have_h5giterate_bug) |
861 { return rep->load_hdf5 (loc_id, name, have_h5giterate_bug); } | |
862 #endif | |
863 | |
5759 | 864 int write (octave_stream& os, int block_size, |
4944 | 865 oct_data_conv::data_type output_type, int skip, |
866 oct_mach_info::float_format flt_fmt) const; | |
867 | |
5759 | 868 octave_base_value *internal_rep (void) const { return rep; } |
4901 | 869 |
5900 | 870 // Unsafe. These functions exist to support the MEX interface. |
871 // You should not use them anywhere else. | |
872 void *mex_get_data (void) const { return rep->mex_get_data (); } | |
873 | |
874 octave_idx_type *mex_get_ir (void) const { return rep->mex_get_ir (); } | |
875 | |
876 octave_idx_type *mex_get_jc (void) const { return rep->mex_get_jc (); } | |
877 | |
878 mxArray *as_mxArray (void) const { return rep->as_mxArray (); } | |
879 | |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7576
diff
changeset
|
880 octave_value diag (octave_idx_type k = 0) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7576
diff
changeset
|
881 { return rep->diag (k); } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7576
diff
changeset
|
882 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
883 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 884 { return rep->sort (dim, mode); } |
885 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, | |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
886 sortmode mode = ASCENDING) const |
7433 | 887 { return rep->sort (sidx, dim, mode); } |
888 | |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
889 void lock (void) { rep->lock (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
890 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
891 void unlock (void) { rep->unlock (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
892 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
893 bool islocked (void) const { return rep->islocked (); } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7463
diff
changeset
|
894 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
895 void dump (std::ostream& os) const { rep->dump (os); } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
896 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
897 #define MAPPER_FORWARD(F) \ |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
898 octave_value F (void) const { return rep->F (); } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
899 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
900 MAPPER_FORWARD (abs) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
901 MAPPER_FORWARD (acos) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
902 MAPPER_FORWARD (acosh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
903 MAPPER_FORWARD (angle) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
904 MAPPER_FORWARD (arg) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
905 MAPPER_FORWARD (asin) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
906 MAPPER_FORWARD (asinh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
907 MAPPER_FORWARD (atan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
908 MAPPER_FORWARD (atanh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
909 MAPPER_FORWARD (ceil) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
910 MAPPER_FORWARD (conj) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
911 MAPPER_FORWARD (cos) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
912 MAPPER_FORWARD (cosh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
913 MAPPER_FORWARD (erf) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
914 MAPPER_FORWARD (erfc) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
915 MAPPER_FORWARD (exp) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
916 MAPPER_FORWARD (expm1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
917 MAPPER_FORWARD (finite) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
918 MAPPER_FORWARD (fix) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
919 MAPPER_FORWARD (floor) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
920 MAPPER_FORWARD (gamma) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
921 MAPPER_FORWARD (imag) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
922 MAPPER_FORWARD (isinf) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
923 MAPPER_FORWARD (isna) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
924 MAPPER_FORWARD (isnan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
925 MAPPER_FORWARD (lgamma) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
926 MAPPER_FORWARD (log) |
7740 | 927 MAPPER_FORWARD (log2) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
928 MAPPER_FORWARD (log10) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
929 MAPPER_FORWARD (log1p) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
930 MAPPER_FORWARD (real) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
931 MAPPER_FORWARD (round) |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
932 MAPPER_FORWARD (roundb) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
933 MAPPER_FORWARD (signum) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
934 MAPPER_FORWARD (sin) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
935 MAPPER_FORWARD (sinh) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
936 MAPPER_FORWARD (sqrt) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
937 MAPPER_FORWARD (tan) |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
938 MAPPER_FORWARD (tanh) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
939 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
940 // These functions are prefixed with X to avoid potential macro |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
941 // conflicts. |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
942 |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
943 MAPPER_FORWARD (xisalnum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
944 MAPPER_FORWARD (xisalpha) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
945 MAPPER_FORWARD (xisascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
946 MAPPER_FORWARD (xiscntrl) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
947 MAPPER_FORWARD (xisdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
948 MAPPER_FORWARD (xisgraph) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
949 MAPPER_FORWARD (xislower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
950 MAPPER_FORWARD (xisprint) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
951 MAPPER_FORWARD (xispunct) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
952 MAPPER_FORWARD (xisspace) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
953 MAPPER_FORWARD (xisupper) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
954 MAPPER_FORWARD (xisxdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
955 MAPPER_FORWARD (xtoascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
956 MAPPER_FORWARD (xtolower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
957 MAPPER_FORWARD (xtoupper) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
958 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
959 #undef MAPPER_FORWARD |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
960 |
2376 | 961 protected: |
962 | |
5759 | 963 // The real representation. |
964 octave_base_value *rep; | |
2413 | 965 |
3933 | 966 private: |
2903 | 967 |
3205 | 968 assign_op unary_op_to_assign_op (unary_op op); |
969 | |
3204 | 970 binary_op op_eq_to_binary_op (assign_op op); |
971 | |
3219 | 972 DECLARE_OCTAVE_ALLOCATOR |
2376 | 973 }; |
974 | |
5508 | 975 // Publish externally used friend functions. |
976 | |
6109 | 977 extern OCTINTERP_API octave_value |
5508 | 978 do_unary_op (octave_value::unary_op op, const octave_value& a); |
979 | |
6109 | 980 extern OCTINTERP_API octave_value |
5508 | 981 do_binary_op (octave_value::binary_op op, |
982 const octave_value& a, const octave_value& b); | |
983 | |
3203 | 984 #define OV_UNOP_FN(name) \ |
985 inline octave_value \ | |
986 name (const octave_value& a) \ | |
987 { \ | |
988 return do_unary_op (octave_value::name, a); \ | |
989 } | |
990 | |
991 #define OV_UNOP_OP(name, op) \ | |
992 inline octave_value \ | |
993 operator op (const octave_value& a) \ | |
994 { \ | |
995 return name (a); \ | |
996 } | |
997 | |
998 #define OV_UNOP_FN_OP(name, op) \ | |
999 OV_UNOP_FN (name) \ | |
1000 OV_UNOP_OP (name, op) | |
1001 | |
3525 | 1002 OV_UNOP_FN_OP (op_not, !) |
6518 | 1003 OV_UNOP_FN_OP (op_uplus, +) |
3525 | 1004 OV_UNOP_FN_OP (op_uminus, -) |
3203 | 1005 |
3525 | 1006 OV_UNOP_FN (op_transpose) |
1007 OV_UNOP_FN (op_hermitian) | |
3203 | 1008 |
1009 // No simple way to define these for prefix and suffix ops? | |
1010 // | |
1011 // incr | |
1012 // decr | |
1013 | |
1014 #define OV_BINOP_FN(name) \ | |
1015 inline octave_value \ | |
1016 name (const octave_value& a1, const octave_value& a2) \ | |
1017 { \ | |
1018 return do_binary_op (octave_value::name, a1, a2); \ | |
1019 } | |
1020 | |
1021 #define OV_BINOP_OP(name, op) \ | |
1022 inline octave_value \ | |
1023 operator op (const octave_value& a1, const octave_value& a2) \ | |
1024 { \ | |
1025 return name (a1, a2); \ | |
1026 } | |
1027 | |
1028 #define OV_BINOP_FN_OP(name, op) \ | |
1029 OV_BINOP_FN (name) \ | |
1030 OV_BINOP_OP (name, op) | |
1031 | |
3525 | 1032 OV_BINOP_FN_OP (op_add, +) |
1033 OV_BINOP_FN_OP (op_sub, -) | |
1034 OV_BINOP_FN_OP (op_mul, *) | |
1035 OV_BINOP_FN_OP (op_div, /) | |
3203 | 1036 |
3525 | 1037 OV_BINOP_FN (op_pow) |
1038 OV_BINOP_FN (op_ldiv) | |
1039 OV_BINOP_FN (op_lshift) | |
1040 OV_BINOP_FN (op_rshift) | |
3203 | 1041 |
3525 | 1042 OV_BINOP_FN_OP (op_lt, <) |
1043 OV_BINOP_FN_OP (op_le, <=) | |
1044 OV_BINOP_FN_OP (op_eq, ==) | |
1045 OV_BINOP_FN_OP (op_ge, >=) | |
1046 OV_BINOP_FN_OP (op_gt, >) | |
1047 OV_BINOP_FN_OP (op_ne, !=) | |
3203 | 1048 |
3525 | 1049 OV_BINOP_FN (op_el_mul) |
1050 OV_BINOP_FN (op_el_div) | |
1051 OV_BINOP_FN (op_el_pow) | |
1052 OV_BINOP_FN (op_el_ldiv) | |
1053 OV_BINOP_FN (op_el_and) | |
1054 OV_BINOP_FN (op_el_or) | |
3203 | 1055 |
3525 | 1056 OV_BINOP_FN (op_struct_ref) |
3203 | 1057 |
6109 | 1058 extern OCTINTERP_API void install_types (void); |
2376 | 1059 |
5775 | 1060 // FIXME -- these trait classes probably belong somehwere else... |
4946 | 1061 |
1062 template <typename T> | |
1063 class | |
1064 octave_type_traits | |
1065 { | |
1066 public: | |
1067 typedef T val_type; | |
1068 }; | |
1069 | |
1070 #define OCTAVE_TYPE_TRAIT(T, VAL_T) \ | |
1071 template <> \ | |
1072 class \ | |
1073 octave_type_traits<T> \ | |
1074 { \ | |
1075 public: \ | |
1076 typedef VAL_T val_type; \ | |
1077 } | |
1078 | |
1079 OCTAVE_TYPE_TRAIT (octave_int8, octave_int8::val_type); | |
1080 OCTAVE_TYPE_TRAIT (octave_uint8, octave_uint8::val_type); | |
1081 OCTAVE_TYPE_TRAIT (octave_int16, octave_int16::val_type); | |
1082 OCTAVE_TYPE_TRAIT (octave_uint16, octave_uint16::val_type); | |
1083 OCTAVE_TYPE_TRAIT (octave_int32, octave_int32::val_type); | |
1084 OCTAVE_TYPE_TRAIT (octave_uint32, octave_uint32::val_type); | |
1085 OCTAVE_TYPE_TRAIT (octave_int64, octave_int64::val_type); | |
1086 OCTAVE_TYPE_TRAIT (octave_uint64, octave_uint64::val_type); | |
1087 | |
1088 template <typename T> | |
1089 class octave_array_type_traits | |
1090 { | |
1091 public: | |
1092 typedef T element_type; | |
1093 }; | |
1094 | |
1095 #define OCTAVE_ARRAY_TYPE_TRAIT(T, ELT_T) \ | |
1096 template <> \ | |
1097 class \ | |
1098 octave_array_type_traits<T> \ | |
1099 { \ | |
1100 public: \ | |
1101 typedef ELT_T element_type; \ | |
1102 } | |
1103 | |
1104 OCTAVE_ARRAY_TYPE_TRAIT (charNDArray, char); | |
4970 | 1105 OCTAVE_ARRAY_TYPE_TRAIT (boolNDArray, bool); |
4946 | 1106 OCTAVE_ARRAY_TYPE_TRAIT (int8NDArray, octave_int8); |
1107 OCTAVE_ARRAY_TYPE_TRAIT (uint8NDArray, octave_uint8); | |
1108 OCTAVE_ARRAY_TYPE_TRAIT (int16NDArray, octave_int16); | |
1109 OCTAVE_ARRAY_TYPE_TRAIT (uint16NDArray, octave_uint16); | |
1110 OCTAVE_ARRAY_TYPE_TRAIT (int32NDArray, octave_int32); | |
1111 OCTAVE_ARRAY_TYPE_TRAIT (uint32NDArray, octave_uint32); | |
1112 OCTAVE_ARRAY_TYPE_TRAIT (int64NDArray, octave_int64); | |
1113 OCTAVE_ARRAY_TYPE_TRAIT (uint64NDArray, octave_uint64); | |
1114 OCTAVE_ARRAY_TYPE_TRAIT (NDArray, double); | |
1115 | |
5759 | 1116 // This will eventually go away, but for now it can be used to |
1117 // simplify the transition to the new octave_value class hierarchy, | |
1118 // which uses octave_base_value instead of octave_value for the type | |
1119 // of octave_value::rep. | |
1120 #define OV_REP_TYPE octave_base_value | |
1121 | |
2376 | 1122 #endif |
1123 | |
1124 /* | |
6705 | 1125 ;;; Local Variables: *** |
1126 ;;; mode: C++ *** | |
1127 ;;; End: *** | |
2376 | 1128 */ |