Mercurial > octave-nkf
annotate src/ov-base.cc @ 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 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
4254 | 28 #include <climits> |
29 | |
3503 | 30 #include <iostream> |
2901 | 31 |
2376 | 32 #include "lo-ieee.h" |
4732 | 33 #include "lo-mappers.h" |
4649 | 34 #include "so-array.h" |
2376 | 35 |
5759 | 36 #include "defun.h" |
2376 | 37 #include "gripes.h" |
38 #include "oct-map.h" | |
2974 | 39 #include "oct-obj.h" |
2979 | 40 #include "oct-lvalue.h" |
3340 | 41 #include "oct-stream.h" |
2376 | 42 #include "ops.h" |
43 #include "ov-base.h" | |
3928 | 44 #include "ov-cell.h" |
45 #include "ov-ch-mat.h" | |
2376 | 46 #include "ov-complex.h" |
47 #include "ov-cx-mat.h" | |
3928 | 48 #include "ov-list.h" |
49 #include "ov-range.h" | |
50 #include "ov-re-mat.h" | |
51 #include "ov-scalar.h" | |
2376 | 52 #include "ov-str-mat.h" |
4343 | 53 #include "ov-fcn-handle.h" |
5759 | 54 #include "parse.h" |
55 #include "utils.h" | |
2948 | 56 #include "variables.h" |
2376 | 57 |
4612 | 58 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_base_value, |
59 "<unknown type>", "unknown"); | |
2376 | 60 |
5759 | 61 // If TRUE, turn off printing of results in functions (as if a |
62 // semicolon has been appended to each statement). | |
7336 | 63 bool Vsilent_functions = false; |
5759 | 64 |
7193 | 65 // TRUE means to perform automatic sparse to real mutation if there |
66 // is memory to be saved | |
67 bool Vsparse_auto_mutate = false; | |
68 | |
2376 | 69 octave_value |
4532 | 70 octave_base_value::squeeze (void) const |
71 { | |
72 std::string nm = type_name (); | |
73 error ("squeeze: invalid operation for %s type", nm.c_str ()); | |
74 return octave_value (); | |
75 } | |
76 | |
77 octave_value | |
4247 | 78 octave_base_value::subsref (const std::string&, |
4219 | 79 const std::list<octave_value_list>&) |
3933 | 80 { |
81 std::string nm = type_name (); | |
82 error ("can't perform indexing operations for %s type", nm.c_str ()); | |
83 return octave_value (); | |
84 } | |
85 | |
86 octave_value_list | |
4247 | 87 octave_base_value::subsref (const std::string&, |
4219 | 88 const std::list<octave_value_list>&, int) |
3933 | 89 { |
90 std::string nm = type_name (); | |
91 error ("can't perform indexing operations for %s type", nm.c_str ()); | |
92 return octave_value (); | |
93 } | |
94 | |
95 octave_value | |
5885 | 96 octave_base_value::do_index_op (const octave_value_list&, bool) |
2974 | 97 { |
3523 | 98 std::string nm = type_name (); |
2974 | 99 error ("can't perform indexing operations for %s type", nm.c_str ()); |
100 return octave_value (); | |
101 } | |
102 | |
103 octave_value_list | |
3544 | 104 octave_base_value::do_multi_index_op (int, const octave_value_list&) |
2376 | 105 { |
3523 | 106 std::string nm = type_name (); |
2376 | 107 error ("can't perform indexing operations for %s type", nm.c_str ()); |
108 return octave_value (); | |
109 } | |
110 | |
111 idx_vector | |
112 octave_base_value::index_vector (void) const | |
113 { | |
3523 | 114 std::string nm = type_name (); |
2376 | 115 error ("%s type invalid as index value", nm.c_str ()); |
116 return idx_vector (); | |
117 } | |
118 | |
5759 | 119 int |
120 octave_base_value::ndims (void) const | |
121 { | |
122 dim_vector dv = dims (); | |
123 | |
124 int n_dims = dv.length (); | |
125 | |
126 // Remove trailing singleton dimensions. | |
127 | |
128 for (int i = n_dims; i > 2; i--) | |
129 { | |
130 if (dv(i-1) == 1) | |
131 n_dims--; | |
132 else | |
133 break; | |
134 } | |
135 | |
136 // The result is always >= 2. | |
137 | |
138 if (n_dims < 2) | |
139 n_dims = 2; | |
140 | |
141 return n_dims; | |
142 } | |
143 | |
2376 | 144 octave_value |
4247 | 145 octave_base_value::subsasgn (const std::string& type, |
4219 | 146 const std::list<octave_value_list>& idx, |
3933 | 147 const octave_value& rhs) |
2376 | 148 { |
3933 | 149 octave_value retval; |
2376 | 150 |
3933 | 151 if (is_defined ()) |
152 { | |
4139 | 153 if (is_numeric_type ()) |
154 { | |
155 switch (type[0]) | |
156 { | |
157 case '(': | |
158 { | |
159 if (type.length () == 1) | |
160 retval = numeric_assign (type, idx, rhs); | |
4436 | 161 else if (is_empty ()) |
162 { | |
163 // Allow conversion of empty matrix to some other | |
164 // type in cases like | |
165 // | |
166 // x = []; x(i).f = rhs | |
167 | |
168 octave_value tmp = octave_value::empty_conv (type, rhs); | |
169 | |
170 retval = tmp.subsasgn (type, idx, rhs); | |
171 } | |
4139 | 172 else |
173 { | |
174 std::string nm = type_name (); | |
175 error ("in indexed assignment of %s, last rhs index must be ()", | |
176 nm.c_str ()); | |
177 } | |
178 } | |
179 break; | |
180 | |
181 case '{': | |
182 case '.': | |
183 { | |
184 std::string nm = type_name (); | |
185 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); | |
186 } | |
187 break; | |
188 | |
189 default: | |
190 panic_impossible (); | |
191 } | |
192 } | |
193 else | |
194 { | |
195 std::string nm = type_name (); | |
196 error ("can't perform indexed assignment for %s type", nm.c_str ()); | |
197 } | |
3933 | 198 } |
199 else | |
200 { | |
201 // Create new object of appropriate type for given index and rhs | |
202 // types and then call subsasgn again for that object. | |
203 | |
204 octave_value tmp = octave_value::empty_conv (type, rhs); | |
205 | |
206 retval = tmp.subsasgn (type, idx, rhs); | |
207 } | |
208 | |
209 return retval; | |
2376 | 210 } |
211 | |
5602 | 212 octave_idx_type |
213 octave_base_value::nnz (void) const | |
214 { | |
215 gripe_wrong_type_arg ("octave_base_value::nnz ()", type_name ()); | |
216 return -1; | |
217 } | |
218 | |
5604 | 219 octave_idx_type |
220 octave_base_value::nzmax (void) const | |
221 { | |
222 gripe_wrong_type_arg ("octave_base_value::nzmax ()", type_name ()); | |
223 return -1; | |
224 } | |
225 | |
5900 | 226 octave_idx_type |
227 octave_base_value::nfields (void) const | |
228 { | |
229 gripe_wrong_type_arg ("octave_base_value::nfields ()", type_name ()); | |
230 return -1; | |
231 } | |
232 | |
2376 | 233 octave_value |
4567 | 234 octave_base_value::reshape (const dim_vector&) const |
235 { | |
236 gripe_wrong_type_arg ("octave_base_value::reshape ()", type_name ()); | |
237 return octave_value (); | |
238 } | |
239 | |
240 octave_value | |
4593 | 241 octave_base_value::permute (const Array<int>&, bool) const |
242 { | |
243 gripe_wrong_type_arg ("octave_base_value::permute ()", type_name ()); | |
244 return octave_value (); | |
245 } | |
246 | |
247 octave_value | |
5731 | 248 octave_base_value::resize (const dim_vector&, bool) const |
4915 | 249 { |
250 gripe_wrong_type_arg ("octave_base_value::resize ()", type_name ()); | |
251 return octave_value (); | |
252 } | |
253 | |
5785 | 254 MatrixType |
255 octave_base_value::matrix_type (void) const | |
256 { | |
257 gripe_wrong_type_arg ("octave_base_value::matrix_type ()", type_name ()); | |
258 return MatrixType (); | |
259 } | |
260 | |
261 MatrixType | |
262 octave_base_value::matrix_type (const MatrixType&) const | |
263 { | |
264 gripe_wrong_type_arg ("octave_base_value::matrix_type ()", type_name ()); | |
265 return MatrixType (); | |
266 } | |
267 | |
4915 | 268 octave_value |
5759 | 269 octave_base_value::all (int) const |
270 { | |
271 return 0.0; | |
272 } | |
273 | |
274 octave_value | |
275 octave_base_value::any (int) const | |
276 { | |
277 return 0.0; | |
278 } | |
279 | |
280 octave_value | |
281 octave_base_value::convert_to_str (bool pad, bool force, char type) const | |
282 { | |
283 octave_value retval = convert_to_str_internal (pad, force, type); | |
284 | |
5781 | 285 if (! force && is_numeric_type ()) |
286 gripe_implicit_conversion ("Octave:num-to-str", | |
287 type_name (), retval.type_name ()); | |
5759 | 288 |
289 return retval; | |
290 } | |
291 | |
292 octave_value | |
5279 | 293 octave_base_value::convert_to_str_internal (bool, bool, char) const |
2376 | 294 { |
4452 | 295 gripe_wrong_type_arg ("octave_base_value::convert_to_str_internal ()", |
2376 | 296 type_name ()); |
297 return octave_value (); | |
298 } | |
299 | |
300 void | |
301 octave_base_value::convert_to_row_or_column_vector (void) | |
302 { | |
303 gripe_wrong_type_arg | |
304 ("octave_base_value::convert_to_row_or_column_vector ()", | |
305 type_name ()); | |
306 } | |
307 | |
308 void | |
3523 | 309 octave_base_value::print (std::ostream&, bool) const |
2376 | 310 { |
3195 | 311 gripe_wrong_type_arg ("octave_base_value::print ()", type_name ()); |
2376 | 312 } |
313 | |
2901 | 314 void |
3523 | 315 octave_base_value::print_raw (std::ostream&, bool) const |
2901 | 316 { |
3195 | 317 gripe_wrong_type_arg ("octave_base_value::print_raw ()", type_name ()); |
2901 | 318 } |
319 | |
320 bool | |
3523 | 321 octave_base_value::print_name_tag (std::ostream& os, const std::string& name) const |
2901 | 322 { |
4604 | 323 bool retval = false; |
324 | |
2901 | 325 indent (os); |
4604 | 326 |
327 if (print_as_scalar ()) | |
328 os << name << " = "; | |
329 else | |
330 { | |
331 os << name << " ="; | |
332 newline (os); | |
333 newline (os); | |
334 retval = true; | |
335 } | |
336 | |
337 return retval; | |
2901 | 338 } |
339 | |
3933 | 340 void |
5759 | 341 octave_base_value::print_with_name (std::ostream& output_buf, |
342 const std::string& name, | |
343 bool print_padding) const | |
344 { | |
345 if (! (evaluating_function_body && Vsilent_functions)) | |
346 { | |
7336 | 347 bool pad_after = print_name_tag (output_buf, name); |
5759 | 348 |
349 print (output_buf); | |
350 | |
351 if (print_padding && pad_after) | |
352 newline (output_buf); | |
353 } | |
354 } | |
355 | |
356 void | |
3933 | 357 octave_base_value::print_info (std::ostream& os, |
4661 | 358 const std::string& /* prefix */) const |
3933 | 359 { |
360 os << "no info for type: " << type_name () << "\n"; | |
361 } | |
362 | |
4254 | 363 #define INT_CONV_METHOD(T, F, MIN_LIMIT, MAX_LIMIT) \ |
364 T \ | |
365 octave_base_value::F ## _value (bool require_int, bool frc_str_conv) const \ | |
366 { \ | |
367 T retval = 0; \ | |
368 \ | |
369 double d = double_value (frc_str_conv); \ | |
370 \ | |
371 if (! error_state) \ | |
372 { \ | |
373 if (require_int && D_NINT (d) != d) \ | |
374 error ("conversion of %g to " #T " value failed", d); \ | |
5054 | 375 else if (d < MIN_LIMIT) \ |
376 retval = MIN_LIMIT; \ | |
377 else if (d > MAX_LIMIT) \ | |
378 retval = MAX_LIMIT; \ | |
4254 | 379 else \ |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
380 retval = static_cast<T> (::fix (d)); \ |
4254 | 381 } \ |
382 else \ | |
383 gripe_wrong_type_arg ("octave_base_value::" #F "_value ()", \ | |
384 type_name ()); \ | |
385 \ | |
386 return retval; \ | |
387 } | |
3202 | 388 |
4254 | 389 INT_CONV_METHOD (short int, short, SHRT_MIN, SHRT_MAX) |
390 INT_CONV_METHOD (unsigned short int, ushort, 0, USHRT_MAX) | |
3202 | 391 |
4254 | 392 INT_CONV_METHOD (int, int, INT_MIN, INT_MAX) |
393 INT_CONV_METHOD (unsigned int, uint, 0, UINT_MAX) | |
3202 | 394 |
4254 | 395 INT_CONV_METHOD (long int, long, LONG_MIN, LONG_MAX) |
396 INT_CONV_METHOD (unsigned long int, ulong, 0, ULONG_MAX) | |
3202 | 397 |
398 int | |
399 octave_base_value::nint_value (bool frc_str_conv) const | |
400 { | |
401 int retval = 0; | |
402 | |
403 double d = double_value (frc_str_conv); | |
404 | |
405 if (! error_state) | |
406 { | |
407 if (xisnan (d)) | |
408 { | |
409 error ("conversion of NaN to integer value failed"); | |
410 return retval; | |
411 } | |
412 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
413 retval = static_cast<int> (::fix (d)); |
3202 | 414 } |
415 else | |
416 gripe_wrong_type_arg ("octave_base_value::nint_value ()", type_name ()); | |
417 | |
418 return retval; | |
419 } | |
420 | |
2376 | 421 double |
422 octave_base_value::double_value (bool) const | |
423 { | |
4102 | 424 double retval = lo_ieee_nan_value (); |
2376 | 425 gripe_wrong_type_arg ("octave_base_value::double_value ()", type_name ()); |
426 return retval; | |
427 } | |
428 | |
3351 | 429 Cell |
3539 | 430 octave_base_value::cell_value () const |
3351 | 431 { |
432 Cell retval; | |
433 gripe_wrong_type_arg ("octave_base_value::cell_value()", type_name ()); | |
434 return retval; | |
435 } | |
436 | |
2376 | 437 Matrix |
438 octave_base_value::matrix_value (bool) const | |
439 { | |
440 Matrix retval; | |
441 gripe_wrong_type_arg ("octave_base_value::matrix_value()", type_name ()); | |
442 return retval; | |
443 } | |
444 | |
4507 | 445 NDArray |
4550 | 446 octave_base_value::array_value (bool) const |
4505 | 447 { |
4507 | 448 NDArray retval; |
4550 | 449 gripe_wrong_type_arg ("octave_base_value::array_value()", type_name ()); |
4505 | 450 return retval; |
451 } | |
452 | |
2376 | 453 Complex |
454 octave_base_value::complex_value (bool) const | |
455 { | |
4102 | 456 double tmp = lo_ieee_nan_value (); |
457 Complex retval (tmp, tmp); | |
2376 | 458 gripe_wrong_type_arg ("octave_base_value::complex_value()", type_name ()); |
459 return retval; | |
460 } | |
461 | |
462 ComplexMatrix | |
463 octave_base_value::complex_matrix_value (bool) const | |
464 { | |
465 ComplexMatrix retval; | |
466 gripe_wrong_type_arg ("octave_base_value::complex_matrix_value()", | |
467 type_name ()); | |
468 return retval; | |
469 } | |
470 | |
4550 | 471 ComplexNDArray |
472 octave_base_value::complex_array_value (bool) const | |
473 { | |
474 ComplexNDArray retval; | |
475 gripe_wrong_type_arg ("octave_base_value::complex_array_value()", | |
476 type_name ()); | |
477 return retval; | |
478 } | |
479 | |
480 bool | |
5943 | 481 octave_base_value::bool_value (bool) const |
4550 | 482 { |
483 bool retval = false; | |
484 gripe_wrong_type_arg ("octave_base_value::bool_value()", type_name ()); | |
485 return retval; | |
486 } | |
487 | |
488 boolMatrix | |
5943 | 489 octave_base_value::bool_matrix_value (bool) const |
4550 | 490 { |
491 boolMatrix retval; | |
492 gripe_wrong_type_arg ("octave_base_value::bool_matrix_value()", | |
493 type_name ()); | |
494 return retval; | |
495 } | |
496 | |
497 boolNDArray | |
5943 | 498 octave_base_value::bool_array_value (bool) const |
4550 | 499 { |
500 boolNDArray retval; | |
501 gripe_wrong_type_arg ("octave_base_value::bool_array_value()", | |
502 type_name ()); | |
503 return retval; | |
504 } | |
505 | |
2376 | 506 charMatrix |
4741 | 507 octave_base_value::char_matrix_value (bool force) const |
2376 | 508 { |
509 charMatrix retval; | |
4257 | 510 |
4741 | 511 octave_value tmp = convert_to_str (false, force); |
4257 | 512 |
4452 | 513 if (! error_state) |
514 retval = tmp.char_matrix_value (); | |
515 | |
2376 | 516 return retval; |
517 } | |
518 | |
4550 | 519 charNDArray |
520 octave_base_value::char_array_value (bool) const | |
521 { | |
522 charNDArray retval; | |
523 gripe_wrong_type_arg ("octave_base_value::char_array_value()", | |
524 type_name ()); | |
525 return retval; | |
526 } | |
527 | |
5164 | 528 SparseMatrix |
529 octave_base_value::sparse_matrix_value (bool) const | |
530 { | |
531 SparseMatrix retval; | |
532 gripe_wrong_type_arg ("octave_base_value::sparse_matrix_value()", type_name ()); | |
533 return retval; | |
534 } | |
535 | |
536 SparseComplexMatrix | |
537 octave_base_value::sparse_complex_matrix_value (bool) const | |
538 { | |
539 SparseComplexMatrix retval; | |
540 gripe_wrong_type_arg ("octave_base_value::sparse_complex_matrix_value()", type_name ()); | |
541 return retval; | |
542 } | |
543 | |
544 SparseBoolMatrix | |
545 octave_base_value::sparse_bool_matrix_value (bool) const | |
546 { | |
547 SparseBoolMatrix retval; | |
548 gripe_wrong_type_arg ("octave_base_value::sparse_bool_matrix_value()", type_name ()); | |
549 return retval; | |
550 } | |
551 | |
4910 | 552 octave_int8 |
553 octave_base_value::int8_scalar_value (void) const | |
554 { | |
555 octave_int8 retval; | |
556 gripe_wrong_type_arg ("octave_base_value::int8_scalar_value()", | |
557 type_name ()); | |
558 return retval; | |
559 } | |
560 | |
561 octave_int16 | |
562 octave_base_value::int16_scalar_value (void) const | |
563 { | |
564 octave_int16 retval; | |
565 gripe_wrong_type_arg ("octave_base_value::int16_scalar_value()", | |
566 type_name ()); | |
567 return retval; | |
568 } | |
569 | |
570 octave_int32 | |
571 octave_base_value::int32_scalar_value (void) const | |
572 { | |
573 octave_int32 retval; | |
574 gripe_wrong_type_arg ("octave_base_value::int32_scalar_value()", | |
575 type_name ()); | |
576 return retval; | |
577 } | |
578 | |
579 octave_int64 | |
580 octave_base_value::int64_scalar_value (void) const | |
581 { | |
582 octave_int64 retval; | |
583 gripe_wrong_type_arg ("octave_base_value::int64_scalar_value()", | |
584 type_name ()); | |
585 return retval; | |
586 } | |
587 | |
588 octave_uint8 | |
589 octave_base_value::uint8_scalar_value (void) const | |
590 { | |
591 octave_uint8 retval; | |
592 gripe_wrong_type_arg ("octave_base_value::uint8_scalar_value()", | |
593 type_name ()); | |
594 return retval; | |
595 } | |
596 | |
597 octave_uint16 | |
598 octave_base_value::uint16_scalar_value (void) const | |
599 { | |
600 octave_uint16 retval; | |
601 gripe_wrong_type_arg ("octave_base_value::uint16_scalar_value()", | |
602 type_name ()); | |
603 return retval; | |
604 } | |
605 | |
606 octave_uint32 | |
607 octave_base_value::uint32_scalar_value (void) const | |
608 { | |
609 octave_uint32 retval; | |
610 gripe_wrong_type_arg ("octave_base_value::uint32_scalar_value()", | |
611 type_name ()); | |
612 return retval; | |
613 } | |
614 | |
615 octave_uint64 | |
616 octave_base_value::uint64_scalar_value (void) const | |
617 { | |
618 octave_uint64 retval; | |
619 gripe_wrong_type_arg ("octave_base_value::uint64_scalar_value()", | |
620 type_name ()); | |
621 return retval; | |
622 } | |
623 | |
4906 | 624 int8NDArray |
625 octave_base_value::int8_array_value (void) const | |
626 { | |
627 int8NDArray retval; | |
628 gripe_wrong_type_arg ("octave_base_value::int8_array_value()", | |
629 type_name ()); | |
4910 | 630 return retval; |
4906 | 631 } |
632 | |
633 int16NDArray | |
634 octave_base_value::int16_array_value (void) const | |
635 { | |
636 int16NDArray retval; | |
637 gripe_wrong_type_arg ("octave_base_value::int16_array_value()", | |
638 type_name ()); | |
4910 | 639 return retval; |
4906 | 640 } |
641 | |
642 int32NDArray | |
643 octave_base_value::int32_array_value (void) const | |
644 { | |
645 int32NDArray retval; | |
646 gripe_wrong_type_arg ("octave_base_value::int32_array_value()", | |
647 type_name ()); | |
4910 | 648 return retval; |
4906 | 649 } |
650 | |
651 int64NDArray | |
652 octave_base_value::int64_array_value (void) const | |
653 { | |
654 int64NDArray retval; | |
655 gripe_wrong_type_arg ("octave_base_value::int64_array_value()", | |
656 type_name ()); | |
4910 | 657 return retval; |
4906 | 658 } |
659 | |
660 uint8NDArray | |
661 octave_base_value::uint8_array_value (void) const | |
662 { | |
663 uint8NDArray retval; | |
664 gripe_wrong_type_arg ("octave_base_value::uint8_array_value()", | |
665 type_name ()); | |
4910 | 666 return retval; |
4906 | 667 } |
668 | |
669 uint16NDArray | |
670 octave_base_value::uint16_array_value (void) const | |
671 { | |
672 uint16NDArray retval; | |
673 gripe_wrong_type_arg ("octave_base_value::uint16_array_value()", | |
674 type_name ()); | |
4910 | 675 return retval; |
4906 | 676 } |
677 | |
678 uint32NDArray | |
679 octave_base_value::uint32_array_value (void) const | |
680 { | |
681 uint32NDArray retval; | |
682 gripe_wrong_type_arg ("octave_base_value::uint32_array_value()", | |
683 type_name ()); | |
4910 | 684 return retval; |
4906 | 685 } |
686 | |
687 uint64NDArray | |
688 octave_base_value::uint64_array_value (void) const | |
689 { | |
690 uint64NDArray retval; | |
691 gripe_wrong_type_arg ("octave_base_value::uint64_array_value()", | |
692 type_name ()); | |
4910 | 693 return retval; |
4906 | 694 } |
695 | |
2493 | 696 string_vector |
5715 | 697 octave_base_value::all_strings (bool pad) const |
2376 | 698 { |
2493 | 699 string_vector retval; |
4257 | 700 |
5715 | 701 octave_value tmp = convert_to_str (pad, true); |
4257 | 702 |
4452 | 703 if (! error_state) |
704 retval = tmp.all_strings (); | |
4257 | 705 |
2376 | 706 return retval; |
707 } | |
708 | |
3536 | 709 std::string |
4457 | 710 octave_base_value::string_value (bool force) const |
2376 | 711 { |
3523 | 712 std::string retval; |
4257 | 713 |
4457 | 714 octave_value tmp = convert_to_str (force); |
4257 | 715 |
4452 | 716 if (! error_state) |
717 retval = tmp.string_value (); | |
4257 | 718 |
2376 | 719 return retval; |
720 } | |
721 | |
722 Range | |
723 octave_base_value::range_value (void) const | |
724 { | |
725 Range retval; | |
726 gripe_wrong_type_arg ("octave_base_value::range_value()", type_name ()); | |
727 return retval; | |
728 } | |
729 | |
730 Octave_map | |
731 octave_base_value::map_value (void) const | |
732 { | |
733 Octave_map retval; | |
734 gripe_wrong_type_arg ("octave_base_value::map_value()", type_name ()); | |
735 return retval; | |
736 } | |
737 | |
3933 | 738 string_vector |
739 octave_base_value::map_keys (void) const | |
740 { | |
741 string_vector retval; | |
742 gripe_wrong_type_arg ("octave_base_value::map_keys()", type_name ()); | |
743 return retval; | |
744 } | |
745 | |
4645 | 746 std::streamoff |
4643 | 747 octave_base_value::streamoff_value (void) const |
748 { | |
4649 | 749 std::streamoff retval (-1); |
4645 | 750 gripe_wrong_type_arg ("octave_base_value::streamoff_value()", type_name ()); |
751 return retval; | |
752 } | |
753 | |
754 streamoff_array | |
755 octave_base_value::streamoff_array_value (void) const | |
756 { | |
4643 | 757 streamoff_array retval; |
4645 | 758 gripe_wrong_type_arg ("octave_base_value::streamoff_array_value()", |
759 type_name ()); | |
4643 | 760 return retval; |
761 } | |
762 | |
2974 | 763 octave_function * |
764 octave_base_value::function_value (bool silent) | |
765 { | |
766 octave_function *retval = 0; | |
767 | |
768 if (! silent) | |
769 gripe_wrong_type_arg ("octave_base_value::function_value()", | |
770 type_name ()); | |
771 return retval; | |
772 } | |
773 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
774 const octave_function * |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
775 octave_base_value::function_value (bool silent) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
776 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
777 const octave_function *retval = 0; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
778 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
779 if (! silent) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
780 gripe_wrong_type_arg ("octave_base_value::function_value()", |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
781 type_name ()); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
782 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
783 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
784 |
4700 | 785 octave_user_function * |
786 octave_base_value::user_function_value (bool silent) | |
787 { | |
788 octave_user_function *retval = 0; | |
789 | |
790 if (! silent) | |
791 gripe_wrong_type_arg ("octave_base_value::user_function_value()", | |
792 type_name ()); | |
793 return retval; | |
794 } | |
795 | |
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
|
796 octave_user_script * |
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
|
797 octave_base_value::user_script_value (bool silent) |
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
|
798 { |
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
|
799 octave_user_script *retval = 0; |
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
|
800 |
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
|
801 if (! silent) |
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
|
802 gripe_wrong_type_arg ("octave_base_value::user_script_value()", |
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
|
803 type_name ()); |
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
|
804 return retval; |
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
|
805 } |
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
|
806 |
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
|
807 octave_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
|
808 octave_base_value::user_code_value (bool silent) |
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
|
809 { |
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
|
810 octave_user_code *retval = 0; |
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
|
811 |
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
|
812 if (! silent) |
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
|
813 gripe_wrong_type_arg ("octave_base_value::user_code_value()", |
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
|
814 type_name ()); |
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
|
815 return retval; |
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
|
816 } |
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
|
817 |
4346 | 818 octave_fcn_handle * |
4343 | 819 octave_base_value::fcn_handle_value (bool silent) |
820 { | |
4346 | 821 octave_fcn_handle *retval = 0; |
4343 | 822 |
823 if (! silent) | |
824 gripe_wrong_type_arg ("octave_base_value::fcn_handle_value()", | |
825 type_name ()); | |
826 return retval; | |
827 } | |
828 | |
4933 | 829 octave_fcn_inline * |
830 octave_base_value::fcn_inline_value (bool silent) | |
831 { | |
832 octave_fcn_inline *retval = 0; | |
833 | |
834 if (! silent) | |
835 gripe_wrong_type_arg ("octave_base_value::fcn_inline_value()", | |
836 type_name ()); | |
837 return retval; | |
838 } | |
839 | |
2882 | 840 octave_value_list |
841 octave_base_value::list_value (void) const | |
842 { | |
843 octave_value_list retval; | |
844 gripe_wrong_type_arg ("octave_base_value::list_value()", type_name ()); | |
845 return retval; | |
846 } | |
847 | |
4687 | 848 bool |
6974 | 849 octave_base_value::save_ascii (std::ostream&) |
4687 | 850 { |
851 gripe_wrong_type_arg ("octave_base_value::save_ascii()", type_name ()); | |
852 return false; | |
853 } | |
854 | |
855 bool | |
856 octave_base_value::load_ascii (std::istream&) | |
857 { | |
858 gripe_wrong_type_arg ("octave_base_value::load_ascii()", type_name ()); | |
859 return false; | |
860 } | |
861 | |
862 bool | |
863 octave_base_value::save_binary (std::ostream&, bool&) | |
864 { | |
865 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
866 return false; | |
867 } | |
868 | |
869 bool | |
870 octave_base_value::load_binary (std::istream&, bool, | |
871 oct_mach_info::float_format) | |
872 { | |
873 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
874 return false; | |
875 } | |
876 | |
877 #if defined (HAVE_HDF5) | |
4944 | 878 |
4687 | 879 bool |
880 octave_base_value::save_hdf5 (hid_t, const char *, bool) | |
881 { | |
882 gripe_wrong_type_arg ("octave_base_value::save_binary()", type_name ()); | |
883 | |
884 return false; | |
885 } | |
886 | |
887 bool | |
888 octave_base_value::load_hdf5 (hid_t, const char *, bool) | |
889 { | |
890 gripe_wrong_type_arg ("octave_base_value::load_binary()", type_name ()); | |
891 | |
892 return false; | |
893 } | |
4944 | 894 |
4687 | 895 #endif |
896 | |
4944 | 897 int |
898 octave_base_value::write (octave_stream&, int, oct_data_conv::data_type, | |
899 int, oct_mach_info::float_format) const | |
900 { | |
901 gripe_wrong_type_arg ("octave_base_value::write()", type_name ()); | |
902 | |
903 return false; | |
904 } | |
905 | |
5900 | 906 mxArray * |
907 octave_base_value::as_mxArray (void) const | |
908 { | |
909 gripe_wrong_type_arg ("octave_base_value::as_mxArray ()", type_name ()); | |
910 | |
911 return 0; | |
912 } | |
913 | |
7433 | 914 octave_value |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
915 octave_base_value::diag (octave_idx_type) const |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
916 { |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
917 gripe_wrong_type_arg ("octave_base_value::diag ()", type_name ()); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
918 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
919 return octave_value(); |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
920 } |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
921 |
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7528
diff
changeset
|
922 octave_value |
7433 | 923 octave_base_value::sort (octave_idx_type, sortmode) const |
924 { | |
925 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
926 | |
927 return octave_value(); | |
928 } | |
929 | |
930 octave_value | |
931 octave_base_value::sort (Array<octave_idx_type> &, | |
932 octave_idx_type, sortmode) const | |
933 { | |
934 gripe_wrong_type_arg ("octave_base_value::sort ()", type_name ()); | |
935 | |
936 return octave_value(); | |
937 } | |
938 | |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
939 #define UNDEFINED_MAPPER(F) \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
940 octave_value \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
941 octave_base_value::F (void) const \ |
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 gripe_wrong_type_arg ("octave_base_value::" #F " ()", type_name ()); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
944 return octave_value (); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
945 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
946 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
947 UNDEFINED_MAPPER (abs) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
948 UNDEFINED_MAPPER (acos) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
949 UNDEFINED_MAPPER (acosh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
950 UNDEFINED_MAPPER (angle) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
951 UNDEFINED_MAPPER (arg) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
952 UNDEFINED_MAPPER (asin) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
953 UNDEFINED_MAPPER (asinh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
954 UNDEFINED_MAPPER (atan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
955 UNDEFINED_MAPPER (atanh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
956 UNDEFINED_MAPPER (ceil) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
957 UNDEFINED_MAPPER (conj) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
958 UNDEFINED_MAPPER (cos) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
959 UNDEFINED_MAPPER (cosh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
960 UNDEFINED_MAPPER (erf) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
961 UNDEFINED_MAPPER (erfc) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
962 UNDEFINED_MAPPER (exp) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
963 UNDEFINED_MAPPER (expm1) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
964 UNDEFINED_MAPPER (finite) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
965 UNDEFINED_MAPPER (fix) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
966 UNDEFINED_MAPPER (floor) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
967 UNDEFINED_MAPPER (gamma) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
968 UNDEFINED_MAPPER (imag) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
969 UNDEFINED_MAPPER (isinf) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
970 UNDEFINED_MAPPER (isna) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
971 UNDEFINED_MAPPER (isnan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
972 UNDEFINED_MAPPER (lgamma) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
973 UNDEFINED_MAPPER (log) |
7740 | 974 UNDEFINED_MAPPER (log2) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
975 UNDEFINED_MAPPER (log10) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
976 UNDEFINED_MAPPER (log1p) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
977 UNDEFINED_MAPPER (real) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
978 UNDEFINED_MAPPER (round) |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
979 UNDEFINED_MAPPER (roundb) |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
980 UNDEFINED_MAPPER (signum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
981 UNDEFINED_MAPPER (sin) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
982 UNDEFINED_MAPPER (sinh) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
983 UNDEFINED_MAPPER (sqrt) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
984 UNDEFINED_MAPPER (tan) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
985 UNDEFINED_MAPPER (tanh) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
986 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
987 // String mapper functions, convert to a string |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
988 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
989 #define STRING_MAPPER(F) \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
990 octave_value \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
991 octave_base_value::F (void) const \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
992 { \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
993 octave_value tmp = octave_value (char_array_value (true), true); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
994 return error_state ? octave_value () : octave_value (tmp.F ()); \ |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
995 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
996 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
997 STRING_MAPPER (xisalnum) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
998 STRING_MAPPER (xisalpha) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
999 STRING_MAPPER (xisascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1000 STRING_MAPPER (xiscntrl) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1001 STRING_MAPPER (xisdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1002 STRING_MAPPER (xisgraph) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1003 STRING_MAPPER (xislower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1004 STRING_MAPPER (xisprint) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1005 STRING_MAPPER (xispunct) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1006 STRING_MAPPER (xisspace) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1007 STRING_MAPPER (xisupper) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1008 STRING_MAPPER (xisxdigit) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1009 STRING_MAPPER (xtoascii) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1010 STRING_MAPPER (xtolower) |
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1011 STRING_MAPPER (xtoupper) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7489
diff
changeset
|
1012 |
7489
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1013 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1014 octave_base_value::lock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1015 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1016 gripe_wrong_type_arg ("octave_base_value::lock ()", type_name ()); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1017 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1018 |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1019 void |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1020 octave_base_value::unlock (void) |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1021 { |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1022 gripe_wrong_type_arg ("octave_base_value::unlock ()", type_name ()); |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1023 } |
8e4592e49fa7
don't clear locked functions
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
1024 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1025 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1026 octave_base_value::dump (std::ostream& os) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1027 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1028 dim_vector dv = this->dims (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1029 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1030 os << "class: " << this->class_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1031 << " type: " << this->type_name () |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1032 << " dims: " << dv.str (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1033 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7740
diff
changeset
|
1034 |
5759 | 1035 static void |
1036 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) | |
1037 { | |
1038 error ("assignment of `%s' to indexed `%s' not implemented", | |
1039 tn2.c_str (), tn1.c_str ()); | |
1040 } | |
1041 | |
1042 static void | |
1043 gripe_assign_conversion_failed (const std::string& tn1, | |
1044 const std::string& tn2) | |
1045 { | |
1046 error ("type conversion for assignment of `%s' to indexed `%s' failed", | |
1047 tn2.c_str (), tn1.c_str ()); | |
1048 } | |
1049 | |
1050 static void | |
1051 gripe_no_conversion (const std::string& on, const std::string& tn1, | |
1052 const std::string& tn2) | |
1053 { | |
1054 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", | |
1055 on.c_str (), tn2.c_str (), tn1.c_str ()); | |
1056 } | |
1057 | |
1058 octave_value | |
1059 octave_base_value::numeric_assign (const std::string& type, | |
1060 const std::list<octave_value_list>& idx, | |
1061 const octave_value& rhs) | |
1062 { | |
1063 octave_value retval; | |
1064 | |
1065 int t_lhs = type_id (); | |
1066 int t_rhs = rhs.type_id (); | |
1067 | |
1068 octave_value_typeinfo::assign_op_fcn f | |
1069 = octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq, | |
1070 t_lhs, t_rhs); | |
1071 | |
1072 bool done = false; | |
1073 | |
1074 if (f) | |
1075 { | |
1076 f (*this, idx.front (), rhs.get_rep ()); | |
1077 | |
1078 done = (! error_state); | |
1079 } | |
1080 | |
1081 if (done) | |
1082 { | |
1083 count++; | |
1084 retval = octave_value (this); | |
1085 } | |
1086 else | |
1087 { | |
1088 int t_result | |
1089 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); | |
1090 | |
1091 if (t_result >= 0) | |
1092 { | |
1093 octave_base_value::type_conv_fcn cf | |
1094 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); | |
1095 | |
1096 if (cf) | |
1097 { | |
5874 | 1098 octave_base_value *tmp = cf (*this); |
5759 | 1099 |
1100 if (tmp) | |
1101 { | |
5874 | 1102 octave_value val (tmp); |
1103 | |
1104 retval = val.subsasgn (type, idx, rhs); | |
5759 | 1105 |
1106 done = (! error_state); | |
1107 } | |
1108 else | |
1109 gripe_assign_conversion_failed (type_name (), | |
1110 rhs.type_name ()); | |
1111 } | |
1112 else | |
1113 gripe_indexed_assignment (type_name (), rhs.type_name ()); | |
1114 } | |
1115 | |
1116 if (! (done || error_state)) | |
1117 { | |
1118 octave_value tmp_rhs; | |
1119 | |
1120 octave_base_value::type_conv_fcn cf_rhs | |
1121 = rhs.numeric_conversion_function (); | |
1122 | |
1123 if (cf_rhs) | |
1124 { | |
1125 octave_base_value *tmp = cf_rhs (rhs.get_rep ()); | |
1126 | |
1127 if (tmp) | |
1128 tmp_rhs = octave_value (tmp); | |
1129 else | |
1130 { | |
1131 gripe_assign_conversion_failed (type_name (), | |
1132 rhs.type_name ()); | |
1133 return octave_value (); | |
1134 } | |
1135 } | |
1136 else | |
1137 tmp_rhs = rhs; | |
1138 | |
1139 octave_base_value::type_conv_fcn cf_this | |
1140 = numeric_conversion_function (); | |
1141 | |
5897 | 1142 count++; |
1143 octave_value tmp_lhs = octave_value (this); | |
5759 | 1144 |
1145 if (cf_this) | |
1146 { | |
1147 octave_base_value *tmp = cf_this (*this); | |
1148 | |
1149 if (tmp) | |
5897 | 1150 tmp_lhs = octave_value (tmp); |
5759 | 1151 else |
1152 { | |
1153 gripe_assign_conversion_failed (type_name (), | |
1154 rhs.type_name ()); | |
1155 return octave_value (); | |
1156 } | |
1157 } | |
1158 | |
1159 if (cf_this || cf_rhs) | |
1160 { | |
5897 | 1161 retval = tmp_lhs.subsasgn (type, idx, tmp_rhs); |
5759 | 1162 |
1163 done = (! error_state); | |
1164 } | |
1165 else | |
1166 gripe_no_conversion (octave_value::assign_op_as_string (octave_value::op_asn_eq), | |
1167 type_name (), rhs.type_name ()); | |
1168 } | |
1169 } | |
1170 | |
1171 // The assignment may have converted to a type that is wider than | |
1172 // necessary. | |
1173 | |
1174 retval.maybe_mutate (); | |
1175 | |
1176 return retval; | |
1177 } | |
1178 | |
1179 // Current indentation. | |
1180 int octave_base_value::curr_print_indent_level = 0; | |
1181 | |
1182 // TRUE means we are at the beginning of a line. | |
1183 bool octave_base_value::beginning_of_line = true; | |
1184 | |
1185 // Each print() function should call this before printing anything. | |
1186 // | |
1187 // This doesn't need to be fast, but isn't there a better way? | |
1188 | |
1189 void | |
1190 octave_base_value::indent (std::ostream& os) const | |
1191 { | |
1192 assert (curr_print_indent_level >= 0); | |
1193 | |
1194 if (beginning_of_line) | |
1195 { | |
5775 | 1196 // FIXME -- do we need this? |
5759 | 1197 // os << prefix; |
1198 | |
1199 for (int i = 0; i < curr_print_indent_level; i++) | |
1200 os << " "; | |
1201 | |
1202 beginning_of_line = false; | |
1203 } | |
1204 } | |
1205 | |
1206 // All print() functions should use this to print new lines. | |
1207 | |
1208 void | |
1209 octave_base_value::newline (std::ostream& os) const | |
1210 { | |
1211 os << "\n"; | |
1212 | |
1213 beginning_of_line = true; | |
1214 } | |
1215 | |
1216 // For ressetting print state. | |
1217 | |
1218 void | |
1219 octave_base_value::reset (void) const | |
1220 { | |
1221 beginning_of_line = true; | |
1222 curr_print_indent_level = 0; | |
1223 } | |
1224 | |
3203 | 1225 CONVDECLX (matrix_conv) |
2376 | 1226 { |
1227 return new octave_matrix (); | |
1228 } | |
1229 | |
3203 | 1230 CONVDECLX (complex_matrix_conv) |
2376 | 1231 { |
1232 return new octave_complex_matrix (); | |
1233 } | |
1234 | |
3203 | 1235 CONVDECLX (string_conv) |
2376 | 1236 { |
1237 return new octave_char_matrix_str (); | |
1238 } | |
1239 | |
3928 | 1240 CONVDECLX (cell_conv) |
1241 { | |
1242 return new octave_cell (); | |
1243 } | |
1244 | |
2376 | 1245 void |
1246 install_base_type_conversions (void) | |
1247 { | |
1248 INSTALL_ASSIGNCONV (octave_base_value, octave_scalar, octave_matrix); | |
1249 INSTALL_ASSIGNCONV (octave_base_value, octave_matrix, octave_matrix); | |
1250 INSTALL_ASSIGNCONV (octave_base_value, octave_complex, octave_complex_matrix); | |
1251 INSTALL_ASSIGNCONV (octave_base_value, octave_complex_matrix, octave_complex_matrix); | |
1252 INSTALL_ASSIGNCONV (octave_base_value, octave_range, octave_matrix); | |
1253 INSTALL_ASSIGNCONV (octave_base_value, octave_char_matrix_str, octave_char_matrix_str); | |
3928 | 1254 INSTALL_ASSIGNCONV (octave_base_value, octave_cell, octave_cell); |
2376 | 1255 |
1256 INSTALL_WIDENOP (octave_base_value, octave_matrix, matrix_conv); | |
1257 INSTALL_WIDENOP (octave_base_value, octave_complex_matrix, complex_matrix_conv); | |
1258 INSTALL_WIDENOP (octave_base_value, octave_char_matrix_str, string_conv); | |
3928 | 1259 INSTALL_WIDENOP (octave_base_value, octave_cell, cell_conv); |
2376 | 1260 } |
1261 | |
5794 | 1262 DEFUN (silent_functions, args, nargout, |
1263 "-*- texinfo -*-\n\ | |
1264 @deftypefn {Built-in Function} {@var{val} =} silent_functions ()\n\ | |
1265 @deftypefnx {Built-in Function} {@var{old_val} =} silent_functions (@var{new_val})\n\ | |
1266 Query or set the internal variable that controls whether internal\n\ | |
1267 output from a function is suppressed. If this option is disabled,\n\ | |
1268 Octave will display the results produced by evaluating expressions\n\ | |
1269 within a function body that are not terminated with a semicolon.\n\ | |
1270 @end deftypefn") | |
5759 | 1271 { |
5794 | 1272 return SET_INTERNAL_VARIABLE (silent_functions); |
5759 | 1273 } |
1274 | |
7193 | 1275 DEFUN (sparse_auto_mutate, args, nargout, |
1276 "-*- texinfo -*-\n\ | |
1277 @deftypefn {Built-in Function} {@var{val} =} sparse_auto_mutate ()\n\ | |
1278 @deftypefnx {Built-in Function} {@var{old_val} =} sparse_auto_mutate (@var{new_val})\n\ | |
1279 Query or set the internal variable that controls whether Octave will\n\ | |
1280 automatically mutate sparse matrices to real matrices to save memory.\n\ | |
1281 For example,\n\ | |
1282 \n\ | |
1283 @example\n\ | |
1284 s = speye(3);\n\ | |
1285 sparse_auto_mutate (false)\n\ | |
1286 s (:, 1) = 1;\n\ | |
1287 typeinfo (s)\n\ | |
1288 @result{} sparse matrix\n\ | |
1289 sparse_auto_mutate (true)\n\ | |
1290 s (1, :) = 1;\n\ | |
1291 typeinfo (s)\n\ | |
1292 @result{} matrix\n\ | |
1293 @end example\n\ | |
1294 @end deftypefn") | |
1295 { | |
1296 return SET_INTERNAL_VARIABLE (sparse_auto_mutate); | |
1297 } | |
1298 | |
2376 | 1299 /* |
1300 ;;; Local Variables: *** | |
1301 ;;; mode: C++ *** | |
1302 ;;; End: *** | |
1303 */ |