2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "Array-flags.h" |
2942
|
32 #include "str-vec.h" |
4153
|
33 #include "quit.h" |
2376
|
34 |
2974
|
35 #include "oct-obj.h" |
2376
|
36 #include "ov.h" |
|
37 #include "ov-base.h" |
2825
|
38 #include "ov-bool.h" |
|
39 #include "ov-bool-mat.h" |
3351
|
40 #include "ov-cell.h" |
2376
|
41 #include "ov-scalar.h" |
|
42 #include "ov-re-mat.h" |
|
43 #include "ov-complex.h" |
|
44 #include "ov-cx-mat.h" |
|
45 #include "ov-ch-mat.h" |
|
46 #include "ov-str-mat.h" |
|
47 #include "ov-range.h" |
|
48 #include "ov-struct.h" |
2903
|
49 #include "ov-file.h" |
4643
|
50 #include "ov-streamoff.h" |
2880
|
51 #include "ov-list.h" |
3977
|
52 #include "ov-cs-list.h" |
2376
|
53 #include "ov-colon.h" |
|
54 #include "ov-va-args.h" |
2974
|
55 #include "ov-builtin.h" |
|
56 #include "ov-mapper.h" |
4649
|
57 #include "ov-dld-fcn.h" |
2974
|
58 #include "ov-usr-fcn.h" |
4342
|
59 #include "ov-fcn-handle.h" |
2376
|
60 #include "ov-typeinfo.h" |
|
61 |
|
62 #include "defun.h" |
2880
|
63 #include "error.h" |
2376
|
64 #include "gripes.h" |
|
65 #include "pager.h" |
4005
|
66 #include "parse.h" |
2376
|
67 #include "pr-output.h" |
|
68 #include "utils.h" |
|
69 #include "variables.h" |
|
70 |
2477
|
71 // We are likely to have a lot of octave_value objects to allocate, so |
|
72 // make the grow_size large. |
3219
|
73 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024); |
2477
|
74 |
4005
|
75 // If TRUE, turn off printing of results in functions (as if a |
|
76 // semicolon has been appended to each statement). |
|
77 static bool Vsilent_functions; |
|
78 |
4455
|
79 // If TRUE, print a warning for assignments like |
2376
|
80 // |
|
81 // octave> A(1) = 3; A(2) = 5 |
|
82 // |
|
83 // for A already defined and a matrix type. |
4455
|
84 bool Vwarn_fortran_indexing; |
2376
|
85 |
4452
|
86 // Should we warn about conversions from complex to real? |
|
87 int Vwarn_imag_to_real; |
4257
|
88 |
4452
|
89 // Should we print a warning when converting `[97, 98, 99, "123"]' |
|
90 // to a character string? |
|
91 bool Vwarn_num_to_str; |
|
92 |
|
93 // If TRUE, warn for operations like |
2376
|
94 // |
|
95 // octave> 'abc' + 0 |
|
96 // 97 98 99 |
|
97 // |
4452
|
98 int Vwarn_str_to_num; |
2376
|
99 |
|
100 // If TRUE, print the name along with the value. |
|
101 bool Vprint_answer_id_name; |
|
102 |
|
103 // How many levels of structure elements should we print? |
|
104 int Vstruct_levels_to_print; |
|
105 |
|
106 // Allow divide by zero errors to be suppressed. |
|
107 bool Vwarn_divide_by_zero; |
|
108 |
4461
|
109 // If TRUE, print a warning when a matrix is resized by an indexed |
|
110 // assignment with indices outside the current bounds. |
|
111 bool Vwarn_resize_on_range_error; |
2948
|
112 |
2880
|
113 // XXX FIXME XXX |
|
114 |
2376
|
115 // Octave's value type. |
|
116 |
3536
|
117 std::string |
3203
|
118 octave_value::unary_op_as_string (unary_op op) |
|
119 { |
3523
|
120 std::string retval; |
3203
|
121 |
|
122 switch (op) |
|
123 { |
3533
|
124 case op_not: |
3203
|
125 retval = "!"; |
|
126 break; |
|
127 |
3533
|
128 case op_uminus: |
3203
|
129 retval = "-"; |
|
130 break; |
|
131 |
3533
|
132 case op_transpose: |
3203
|
133 retval = ".'"; |
|
134 break; |
|
135 |
3533
|
136 case op_hermitian: |
3203
|
137 retval = "'"; |
|
138 break; |
|
139 |
3533
|
140 case op_incr: |
3203
|
141 retval = "++"; |
|
142 break; |
|
143 |
3533
|
144 case op_decr: |
3203
|
145 retval = "--"; |
|
146 break; |
|
147 |
|
148 default: |
|
149 retval = "<unknown>"; |
|
150 } |
|
151 |
|
152 return retval; |
|
153 } |
|
154 |
3536
|
155 std::string |
2376
|
156 octave_value::binary_op_as_string (binary_op op) |
|
157 { |
3523
|
158 std::string retval; |
2376
|
159 |
|
160 switch (op) |
|
161 { |
3533
|
162 case op_add: |
2376
|
163 retval = "+"; |
|
164 break; |
|
165 |
3533
|
166 case op_sub: |
2376
|
167 retval = "-"; |
|
168 break; |
|
169 |
3533
|
170 case op_mul: |
2376
|
171 retval = "*"; |
|
172 break; |
|
173 |
3533
|
174 case op_div: |
2376
|
175 retval = "/"; |
|
176 break; |
|
177 |
3533
|
178 case op_pow: |
2376
|
179 retval = "^"; |
|
180 break; |
|
181 |
3533
|
182 case op_ldiv: |
2376
|
183 retval = "\\"; |
|
184 break; |
|
185 |
3533
|
186 case op_lshift: |
2903
|
187 retval = "<<"; |
|
188 break; |
|
189 |
3533
|
190 case op_rshift: |
2903
|
191 retval = ">>"; |
|
192 break; |
|
193 |
3533
|
194 case op_lt: |
2376
|
195 retval = "<"; |
|
196 break; |
|
197 |
3533
|
198 case op_le: |
2376
|
199 retval = "<="; |
|
200 break; |
|
201 |
3533
|
202 case op_eq: |
2376
|
203 retval = "=="; |
|
204 break; |
|
205 |
3533
|
206 case op_ge: |
2376
|
207 retval = ">="; |
|
208 break; |
|
209 |
3533
|
210 case op_gt: |
2376
|
211 retval = ">"; |
|
212 break; |
|
213 |
3533
|
214 case op_ne: |
2376
|
215 retval = "!="; |
|
216 break; |
|
217 |
3533
|
218 case op_el_mul: |
2376
|
219 retval = ".*"; |
|
220 break; |
|
221 |
3533
|
222 case op_el_div: |
2376
|
223 retval = "./"; |
|
224 break; |
|
225 |
3533
|
226 case op_el_pow: |
2376
|
227 retval = ".^"; |
|
228 break; |
|
229 |
3533
|
230 case op_el_ldiv: |
2376
|
231 retval = ".\\"; |
|
232 break; |
|
233 |
3533
|
234 case op_el_and: |
2376
|
235 retval = "&"; |
|
236 break; |
|
237 |
3533
|
238 case op_el_or: |
2376
|
239 retval = "|"; |
|
240 break; |
|
241 |
3533
|
242 case op_struct_ref: |
2376
|
243 retval = "."; |
|
244 break; |
|
245 |
|
246 default: |
|
247 retval = "<unknown>"; |
|
248 } |
|
249 |
|
250 return retval; |
|
251 } |
|
252 |
3536
|
253 std::string |
2880
|
254 octave_value::assign_op_as_string (assign_op op) |
|
255 { |
3523
|
256 std::string retval; |
2880
|
257 |
|
258 switch (op) |
|
259 { |
3533
|
260 case op_asn_eq: |
2880
|
261 retval = "="; |
|
262 break; |
|
263 |
3533
|
264 case op_add_eq: |
2880
|
265 retval = "+="; |
|
266 break; |
|
267 |
3533
|
268 case op_sub_eq: |
2880
|
269 retval = "-="; |
|
270 break; |
|
271 |
3533
|
272 case op_mul_eq: |
2880
|
273 retval = "*="; |
|
274 break; |
|
275 |
3533
|
276 case op_div_eq: |
2880
|
277 retval = "/="; |
|
278 break; |
|
279 |
3533
|
280 case op_ldiv_eq: |
3204
|
281 retval = "\\="; |
|
282 break; |
|
283 |
4018
|
284 case op_pow_eq: |
|
285 retval = "^="; |
|
286 break; |
|
287 |
3533
|
288 case op_lshift_eq: |
2903
|
289 retval = "<<="; |
|
290 break; |
|
291 |
3533
|
292 case op_rshift_eq: |
2903
|
293 retval = ">>="; |
|
294 break; |
|
295 |
3533
|
296 case op_el_mul_eq: |
2880
|
297 retval = ".*="; |
|
298 break; |
|
299 |
3533
|
300 case op_el_div_eq: |
2880
|
301 retval = "./="; |
|
302 break; |
|
303 |
3533
|
304 case op_el_ldiv_eq: |
3204
|
305 retval = ".\\="; |
|
306 break; |
|
307 |
4018
|
308 case op_el_pow_eq: |
|
309 retval = ".^="; |
|
310 break; |
|
311 |
3533
|
312 case op_el_and_eq: |
2880
|
313 retval = "&="; |
|
314 break; |
|
315 |
3533
|
316 case op_el_or_eq: |
2880
|
317 retval = "|="; |
|
318 break; |
|
319 |
|
320 default: |
|
321 retval = "<unknown>"; |
|
322 } |
|
323 |
|
324 return retval; |
|
325 } |
|
326 |
4513
|
327 octave_value * |
|
328 octave_value::nil_rep (void) const |
|
329 { |
|
330 static octave_base_value *nr = new octave_base_value (); |
|
331 return nr; |
|
332 } |
|
333 |
2376
|
334 octave_value::octave_value (void) |
4513
|
335 : rep (nil_rep ()) |
2825
|
336 { |
4513
|
337 rep->count++; |
2825
|
338 } |
2376
|
339 |
4254
|
340 octave_value::octave_value (short int i) |
|
341 : rep (new octave_scalar (i)) |
|
342 { |
|
343 rep->count = 1; |
|
344 } |
|
345 |
|
346 octave_value::octave_value (unsigned short int i) |
|
347 : rep (new octave_scalar (i)) |
|
348 { |
|
349 rep->count = 1; |
|
350 } |
|
351 |
4233
|
352 octave_value::octave_value (int i) |
|
353 : rep (new octave_scalar (i)) |
|
354 { |
|
355 rep->count = 1; |
|
356 } |
|
357 |
4254
|
358 octave_value::octave_value (unsigned int i) |
|
359 : rep (new octave_scalar (i)) |
|
360 { |
|
361 rep->count = 1; |
|
362 } |
|
363 |
|
364 octave_value::octave_value (long int i) |
|
365 : rep (new octave_scalar (i)) |
|
366 { |
|
367 rep->count = 1; |
|
368 } |
|
369 |
|
370 octave_value::octave_value (unsigned long int i) |
|
371 : rep (new octave_scalar (i)) |
|
372 { |
|
373 rep->count = 1; |
|
374 } |
|
375 |
4353
|
376 #if defined (HAVE_LONG_LONG_INT) |
|
377 octave_value::octave_value (long long int i) |
|
378 : rep (new octave_scalar (i)) |
|
379 { |
|
380 rep->count = 1; |
|
381 } |
|
382 #endif |
|
383 |
4355
|
384 #if defined (HAVE_UNSIGNED_LONG_LONG_INT) |
4353
|
385 octave_value::octave_value (unsigned long long int i) |
|
386 : rep (new octave_scalar (i)) |
|
387 { |
|
388 rep->count = 1; |
|
389 } |
|
390 #endif |
|
391 |
4254
|
392 octave_value::octave_value (octave_time t) |
|
393 : rep (new octave_scalar (t)) |
|
394 { |
|
395 rep->count = 1; |
|
396 } |
|
397 |
2376
|
398 octave_value::octave_value (double d) |
2825
|
399 : rep (new octave_scalar (d)) |
|
400 { |
|
401 rep->count = 1; |
|
402 } |
2376
|
403 |
4587
|
404 octave_value::octave_value (const Cell& c, bool is_csl) |
4513
|
405 : rep (0) |
3351
|
406 { |
4587
|
407 if (is_csl) |
4513
|
408 rep = new octave_cs_list (c); |
|
409 else |
|
410 rep = new octave_cell (c); |
|
411 |
3351
|
412 rep->count = 1; |
|
413 } |
|
414 |
4587
|
415 octave_value::octave_value (const ArrayN<octave_value>& a, bool is_csl) |
4532
|
416 : rep (0) |
|
417 { |
|
418 Cell c (a); |
|
419 |
4587
|
420 if (is_csl) |
4532
|
421 rep = new octave_cs_list (c); |
|
422 else |
|
423 rep = new octave_cell (c); |
|
424 |
|
425 rep->count = 1; |
|
426 } |
|
427 |
2376
|
428 octave_value::octave_value (const Matrix& m) |
2423
|
429 : rep (new octave_matrix (m)) |
|
430 { |
|
431 rep->count = 1; |
|
432 maybe_mutate (); |
|
433 } |
2376
|
434 |
4507
|
435 octave_value::octave_value (const NDArray& a) |
4513
|
436 : rep (new octave_matrix (a)) |
4478
|
437 { |
|
438 rep->count = 1; |
|
439 maybe_mutate (); |
|
440 } |
|
441 |
2376
|
442 octave_value::octave_value (const DiagMatrix& d) |
2423
|
443 : rep (new octave_matrix (d)) |
|
444 { |
|
445 rep->count = 1; |
|
446 maybe_mutate (); |
|
447 } |
2376
|
448 |
3418
|
449 octave_value::octave_value (const RowVector& v) |
|
450 : rep (new octave_matrix (v)) |
2423
|
451 { |
|
452 rep->count = 1; |
|
453 maybe_mutate (); |
|
454 } |
2376
|
455 |
3418
|
456 octave_value::octave_value (const ColumnVector& v) |
|
457 : rep (new octave_matrix (v)) |
2423
|
458 { |
|
459 rep->count = 1; |
|
460 maybe_mutate (); |
|
461 } |
2376
|
462 |
|
463 octave_value::octave_value (const Complex& C) |
2423
|
464 : rep (new octave_complex (C)) |
|
465 { |
|
466 rep->count = 1; |
|
467 maybe_mutate (); |
|
468 } |
2376
|
469 |
|
470 octave_value::octave_value (const ComplexMatrix& m) |
2423
|
471 : rep (new octave_complex_matrix (m)) |
|
472 { |
|
473 rep->count = 1; |
|
474 maybe_mutate (); |
|
475 } |
2376
|
476 |
4513
|
477 octave_value::octave_value (const ComplexNDArray& a) |
|
478 : rep (new octave_complex_matrix (a)) |
4478
|
479 { |
|
480 rep->count = 1; |
|
481 maybe_mutate (); |
|
482 } |
|
483 |
2376
|
484 octave_value::octave_value (const ComplexDiagMatrix& d) |
2423
|
485 : rep (new octave_complex_matrix (d)) |
|
486 { |
|
487 rep->count = 1; |
|
488 maybe_mutate (); |
|
489 } |
2376
|
490 |
3418
|
491 octave_value::octave_value (const ComplexRowVector& v) |
|
492 : rep (new octave_complex_matrix (v)) |
2423
|
493 { |
|
494 rep->count = 1; |
|
495 maybe_mutate (); |
|
496 } |
2376
|
497 |
3418
|
498 octave_value::octave_value (const ComplexColumnVector& v) |
|
499 : rep (new octave_complex_matrix (v)) |
2423
|
500 { |
|
501 rep->count = 1; |
|
502 maybe_mutate (); |
|
503 } |
2376
|
504 |
2825
|
505 octave_value::octave_value (bool b) |
|
506 : rep (new octave_bool (b)) |
|
507 { |
|
508 rep->count = 1; |
|
509 } |
|
510 |
|
511 octave_value::octave_value (const boolMatrix& bm) |
|
512 : rep (new octave_bool_matrix (bm)) |
|
513 { |
|
514 rep->count = 1; |
|
515 maybe_mutate (); |
|
516 } |
|
517 |
4513
|
518 octave_value::octave_value (const boolNDArray& bnda) |
|
519 : rep (new octave_bool_matrix (bnda)) |
|
520 { |
|
521 rep->count = 1; |
|
522 maybe_mutate (); |
|
523 } |
|
524 |
3189
|
525 octave_value::octave_value (char c) |
|
526 : rep (new octave_char_matrix_str (c)) |
|
527 { |
|
528 rep->count = 1; |
|
529 maybe_mutate (); |
|
530 } |
|
531 |
2376
|
532 octave_value::octave_value (const char *s) |
2423
|
533 : rep (new octave_char_matrix_str (s)) |
|
534 { |
|
535 rep->count = 1; |
|
536 maybe_mutate (); |
|
537 } |
2376
|
538 |
3523
|
539 octave_value::octave_value (const std::string& s) |
2423
|
540 : rep (new octave_char_matrix_str (s)) |
|
541 { |
|
542 rep->count = 1; |
|
543 maybe_mutate (); |
|
544 } |
2376
|
545 |
|
546 octave_value::octave_value (const string_vector& s) |
2423
|
547 : rep (new octave_char_matrix_str (s)) |
|
548 { |
|
549 rep->count = 1; |
|
550 maybe_mutate (); |
|
551 } |
2376
|
552 |
4587
|
553 octave_value::octave_value (const charMatrix& chm, bool is_str) |
|
554 : rep (is_str |
4513
|
555 ? new octave_char_matrix_str (chm) |
|
556 : new octave_char_matrix (chm)) |
2409
|
557 { |
4513
|
558 rep->count = 1; |
|
559 maybe_mutate (); |
|
560 } |
2376
|
561 |
4587
|
562 octave_value::octave_value (const charNDArray& chm, bool is_str) |
|
563 : rep (is_str |
4513
|
564 ? new octave_char_matrix_str (chm) |
|
565 : new octave_char_matrix (chm)) |
|
566 { |
2409
|
567 rep->count = 1; |
2423
|
568 maybe_mutate (); |
2409
|
569 } |
2376
|
570 |
|
571 octave_value::octave_value (double base, double limit, double inc) |
2423
|
572 : rep (new octave_range (base, limit, inc)) |
|
573 { |
|
574 rep->count = 1; |
|
575 maybe_mutate (); |
|
576 } |
2376
|
577 |
|
578 octave_value::octave_value (const Range& r) |
2423
|
579 : rep (new octave_range (r)) |
|
580 { |
|
581 rep->count = 1; |
|
582 maybe_mutate (); |
|
583 } |
2376
|
584 |
|
585 octave_value::octave_value (const Octave_map& m) |
2825
|
586 : rep (new octave_struct (m)) |
|
587 { |
|
588 rep->count = 1; |
2880
|
589 } |
|
590 |
3340
|
591 octave_value::octave_value (const octave_stream& s, int n) |
2903
|
592 : rep (new octave_file (s, n)) |
|
593 { |
|
594 rep->count = 1; |
|
595 } |
|
596 |
4643
|
597 octave_value::octave_value (const streamoff_array& off) |
|
598 : rep (new octave_streamoff (off)) |
|
599 { |
|
600 rep->count = 1; |
|
601 } |
|
602 |
2974
|
603 octave_value::octave_value (octave_function *f) |
|
604 : rep (f) |
|
605 { |
|
606 rep->count = 1; |
|
607 } |
|
608 |
4342
|
609 octave_value::octave_value (const octave_fcn_handle& fh) |
|
610 : rep (new octave_fcn_handle (fh)) |
|
611 { |
|
612 rep->count = 1; |
|
613 } |
|
614 |
4587
|
615 octave_value::octave_value (const octave_value_list& l, bool is_csl) |
4591
|
616 : rep (0) |
2880
|
617 { |
4591
|
618 if (is_csl) |
|
619 rep = new octave_cs_list (l); |
|
620 else |
|
621 rep = new octave_list (l); |
|
622 |
2880
|
623 rep->count = 1; |
|
624 } |
2376
|
625 |
|
626 octave_value::octave_value (octave_value::magic_colon) |
2825
|
627 : rep (new octave_magic_colon ()) |
|
628 { |
|
629 rep->count = 1; |
|
630 } |
2376
|
631 |
|
632 octave_value::octave_value (octave_value::all_va_args) |
2825
|
633 : rep (new octave_all_va_args ()) |
|
634 { |
|
635 rep->count = 1; |
|
636 } |
2376
|
637 |
4276
|
638 octave_value::octave_value (octave_value *new_rep, int cnt) |
2825
|
639 : rep (new_rep) |
|
640 { |
4276
|
641 rep->count = cnt; |
2825
|
642 } |
2376
|
643 |
|
644 octave_value::~octave_value (void) |
|
645 { |
|
646 #if defined (MDEBUG) |
3531
|
647 std::cerr << "~octave_value: rep: " << rep |
|
648 << " rep->count: " << rep->count << "\n"; |
2376
|
649 #endif |
|
650 |
|
651 if (rep && --rep->count == 0) |
|
652 { |
|
653 delete rep; |
|
654 rep = 0; |
|
655 } |
|
656 } |
|
657 |
2880
|
658 octave_value * |
3933
|
659 octave_value::clone (void) const |
2880
|
660 { |
|
661 panic_impossible (); |
3546
|
662 return 0; |
2880
|
663 } |
|
664 |
2409
|
665 void |
|
666 octave_value::maybe_mutate (void) |
|
667 { |
2410
|
668 octave_value *tmp = rep->try_narrowing_conversion (); |
2409
|
669 |
|
670 if (tmp && tmp != rep) |
|
671 { |
|
672 if (--rep->count == 0) |
|
673 delete rep; |
|
674 |
|
675 rep = tmp; |
|
676 rep->count = 1; |
|
677 } |
|
678 } |
|
679 |
4247
|
680 octave_value |
4271
|
681 octave_value::single_subsref (const std::string& type, |
|
682 const octave_value_list& idx) |
4247
|
683 { |
|
684 std::list<octave_value_list> i; |
|
685 |
|
686 i.push_back (idx); |
|
687 |
|
688 return rep->subsref (type, i); |
|
689 } |
|
690 |
2974
|
691 octave_value_list |
4247
|
692 octave_value::subsref (const std::string& type, |
4219
|
693 const std::list<octave_value_list>& idx, int nargout) |
3933
|
694 { |
|
695 if (is_constant ()) |
|
696 return rep->subsref (type, idx); |
|
697 else |
|
698 return rep->subsref (type, idx, nargout); |
|
699 } |
|
700 |
|
701 octave_value |
4247
|
702 octave_value::next_subsref (const std::string& type, |
4219
|
703 const std::list<octave_value_list>& idx, |
4233
|
704 size_t skip) |
3933
|
705 { |
4582
|
706 if (! error_state && idx.size () > skip) |
3933
|
707 { |
4219
|
708 std::list<octave_value_list> new_idx (idx); |
4233
|
709 for (size_t i = 0; i < skip; i++) |
4219
|
710 new_idx.erase (new_idx.begin ()); |
3933
|
711 return subsref (type.substr (skip), new_idx); |
|
712 } |
|
713 else |
|
714 return *this; |
|
715 } |
|
716 |
|
717 octave_value_list |
3544
|
718 octave_value::do_multi_index_op (int nargout, const octave_value_list& idx) |
2974
|
719 { |
3544
|
720 return rep->do_multi_index_op (nargout, idx); |
2974
|
721 } |
|
722 |
2376
|
723 static void |
3933
|
724 gripe_no_conversion (const std::string& on, const std::string& tn1, |
|
725 const std::string& tn2) |
2376
|
726 { |
3203
|
727 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", |
|
728 on.c_str (), tn2.c_str (), tn1.c_str ()); |
2376
|
729 } |
|
730 |
3933
|
731 #if 0 |
3204
|
732 static void |
3933
|
733 gripe_assign_failed (const std::string& on, const std::string& tn1, |
|
734 const std::string& tn2) |
3204
|
735 { |
|
736 error ("assignment failed for `%s %s %s'", |
|
737 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
738 } |
3933
|
739 #endif |
3204
|
740 |
|
741 static void |
3933
|
742 gripe_assign_failed_or_no_method (const std::string& on, |
|
743 const std::string& tn1, |
3523
|
744 const std::string& tn2) |
3204
|
745 { |
|
746 error ("assignment failed, or no method for `%s %s %s'", |
|
747 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
748 } |
|
749 |
3933
|
750 octave_value |
4247
|
751 octave_value::subsasgn (const std::string& type, |
4219
|
752 const std::list<octave_value_list>& idx, |
3933
|
753 const octave_value& rhs) |
|
754 { |
|
755 return rep->subsasgn (type, idx, rhs); |
|
756 } |
|
757 |
|
758 octave_value |
4247
|
759 octave_value::assign (assign_op op, const std::string& type, |
4219
|
760 const std::list<octave_value_list>& idx, |
3933
|
761 const octave_value& rhs) |
|
762 { |
|
763 octave_value retval; |
|
764 |
|
765 make_unique (); |
|
766 |
|
767 octave_value t_rhs = rhs; |
|
768 |
|
769 if (op != op_asn_eq) |
|
770 { |
|
771 // XXX FIXME XXX -- only do the following stuff if we can't find |
|
772 // a specific function to call to handle the op= operation for |
|
773 // the types we have. |
|
774 |
|
775 octave_value t = subsref (type, idx); |
|
776 |
|
777 if (! error_state) |
|
778 { |
|
779 binary_op binop = op_eq_to_binary_op (op); |
|
780 |
|
781 if (! error_state) |
|
782 t_rhs = do_binary_op (binop, t, rhs); |
|
783 } |
|
784 } |
|
785 |
|
786 if (! error_state) |
|
787 { |
|
788 if (type[0] == '.' && ! is_map ()) |
|
789 { |
|
790 octave_value tmp = Octave_map (); |
|
791 retval = tmp.subsasgn (type, idx, t_rhs); |
|
792 } |
|
793 else |
|
794 retval = subsasgn (type, idx, t_rhs); |
|
795 } |
|
796 |
|
797 if (error_state) |
|
798 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
799 type_name (), rhs.type_name ()); |
|
800 |
|
801 return retval; |
|
802 } |
|
803 |
|
804 const octave_value& |
3203
|
805 octave_value::assign (assign_op op, const octave_value& rhs) |
2880
|
806 { |
3533
|
807 if (op == op_asn_eq) |
3203
|
808 operator = (rhs); |
|
809 else |
|
810 { |
3204
|
811 // XXX FIXME XXX -- only do the following stuff if we can't find |
|
812 // a specific function to call to handle the op= operation for |
|
813 // the types we have. |
|
814 |
|
815 binary_op binop = op_eq_to_binary_op (op); |
|
816 |
|
817 if (! error_state) |
|
818 { |
|
819 octave_value t = do_binary_op (binop, *this, rhs); |
|
820 |
|
821 if (! error_state) |
|
822 operator = (t); |
|
823 } |
|
824 |
|
825 if (error_state) |
|
826 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
827 type_name (), rhs.type_name ()); |
|
828 } |
|
829 |
3933
|
830 return *this; |
2376
|
831 } |
|
832 |
4563
|
833 int |
|
834 octave_value::rows (void) const |
|
835 { |
|
836 dim_vector dv = dims (); |
|
837 |
|
838 return (dv.length () > 0) ? dv(0) : -1; |
|
839 } |
|
840 |
|
841 int |
|
842 octave_value::columns (void) const |
|
843 { |
|
844 dim_vector dv = dims (); |
|
845 |
|
846 return (dv.length () > 1) ? dv(1) : -1; |
|
847 } |
|
848 |
|
849 int |
|
850 octave_value::length (void) const |
|
851 { |
|
852 int retval = 0; |
|
853 |
|
854 dim_vector dv = dims (); |
4584
|
855 |
4563
|
856 for (int i = 0; i < dv.length (); i++) |
|
857 { |
|
858 if (dv(i) < 0) |
|
859 { |
|
860 retval = -1; |
|
861 break; |
|
862 } |
|
863 |
4584
|
864 if (dv(i) == 0) |
|
865 { |
|
866 retval = 0; |
|
867 break; |
|
868 } |
|
869 |
4563
|
870 if (dv(i) > retval) |
|
871 retval = dv(i); |
|
872 } |
|
873 |
|
874 return retval; |
|
875 } |
|
876 |
|
877 int |
|
878 octave_value::ndims (void) const |
|
879 { |
|
880 dim_vector dv = dims (); |
|
881 |
|
882 int n_dims = dv.length (); |
|
883 |
|
884 // Remove trailing singleton dimensions. |
|
885 |
|
886 for (int i = n_dims; i > 2; i--) |
|
887 { |
|
888 if (dv(i-1) == 1) |
|
889 n_dims--; |
|
890 else |
|
891 break; |
|
892 } |
|
893 |
|
894 // The result is always >= 2. |
|
895 |
|
896 if (n_dims < 2) |
|
897 n_dims = 2; |
|
898 |
|
899 return n_dims; |
|
900 } |
|
901 |
|
902 int |
|
903 octave_value::numel (void) const |
|
904 { |
|
905 dim_vector dv = dims (); |
|
906 |
4567
|
907 return dv.numel (); |
4563
|
908 } |
|
909 |
3351
|
910 Cell |
|
911 octave_value::cell_value (void) const |
|
912 { |
|
913 return rep->cell_value (); |
|
914 } |
|
915 |
2376
|
916 Octave_map |
|
917 octave_value::map_value (void) const |
|
918 { |
|
919 return rep->map_value (); |
|
920 } |
|
921 |
3340
|
922 octave_stream |
2903
|
923 octave_value::stream_value (void) const |
|
924 { |
|
925 return rep->stream_value (); |
|
926 } |
|
927 |
|
928 int |
|
929 octave_value::stream_number (void) const |
|
930 { |
|
931 return rep->stream_number (); |
|
932 } |
|
933 |
4645
|
934 std::streamoff |
4643
|
935 octave_value::streamoff_value (void) const |
|
936 { |
|
937 return rep->streamoff_value (); |
|
938 } |
|
939 |
4645
|
940 streamoff_array |
|
941 octave_value::streamoff_array_value (void) const |
|
942 { |
|
943 return rep->streamoff_array_value (); |
|
944 } |
|
945 |
2974
|
946 octave_function * |
|
947 octave_value::function_value (bool silent) |
|
948 { |
|
949 return rep->function_value (silent); |
|
950 } |
|
951 |
4346
|
952 octave_fcn_handle * |
4343
|
953 octave_value::fcn_handle_value (bool silent) |
|
954 { |
|
955 return rep->fcn_handle_value (silent); |
|
956 } |
|
957 |
2880
|
958 octave_value_list |
|
959 octave_value::list_value (void) const |
|
960 { |
|
961 return rep->list_value (); |
|
962 } |
|
963 |
2376
|
964 ColumnVector |
3419
|
965 octave_value::column_vector_value (bool force_string_conv, |
|
966 bool force_vector_conversion) const |
|
967 { |
|
968 ColumnVector retval; |
|
969 |
|
970 Matrix m = matrix_value (force_string_conv); |
|
971 |
|
972 if (error_state) |
|
973 return retval; |
|
974 |
|
975 int nr = m.rows (); |
|
976 int nc = m.columns (); |
|
977 |
|
978 if (nc == 1) |
|
979 { |
|
980 retval.resize (nr); |
|
981 for (int i = 0; i < nr; i++) |
|
982 retval (i) = m (i, 0); |
|
983 } |
|
984 else |
|
985 { |
3523
|
986 std::string tn = type_name (); |
3419
|
987 gripe_invalid_conversion (tn.c_str (), "real column vector"); |
|
988 } |
|
989 |
|
990 return retval; |
|
991 } |
|
992 |
|
993 ComplexColumnVector |
|
994 octave_value::complex_column_vector_value (bool force_string_conv, |
|
995 bool force_vector_conversion) const |
|
996 { |
|
997 ComplexColumnVector retval; |
|
998 |
|
999 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1000 |
|
1001 if (error_state) |
|
1002 return retval; |
|
1003 |
|
1004 int nr = m.rows (); |
|
1005 int nc = m.columns (); |
|
1006 |
|
1007 if (nc == 1) |
|
1008 { |
3465
|
1009 retval.resize (nr); |
|
1010 for (int i = 0; i < nr; i++) |
3419
|
1011 retval (i) = m (i, 0); |
|
1012 } |
|
1013 else |
|
1014 { |
3523
|
1015 std::string tn = type_name (); |
3419
|
1016 gripe_invalid_conversion (tn.c_str (), "complex column vector"); |
|
1017 } |
|
1018 |
|
1019 return retval; |
|
1020 } |
|
1021 |
|
1022 RowVector |
|
1023 octave_value::row_vector_value (bool force_string_conv, |
|
1024 bool force_vector_conversion) const |
|
1025 { |
|
1026 RowVector retval; |
|
1027 |
|
1028 Matrix m = matrix_value (force_string_conv); |
|
1029 |
|
1030 if (error_state) |
|
1031 return retval; |
|
1032 |
|
1033 int nr = m.rows (); |
|
1034 int nc = m.columns (); |
|
1035 |
|
1036 if (nr == 1) |
|
1037 { |
|
1038 retval.resize (nc); |
|
1039 for (int i = 0; i < nc; i++) |
|
1040 retval (i) = m (0, i); |
|
1041 } |
|
1042 else |
|
1043 { |
3523
|
1044 std::string tn = type_name (); |
3419
|
1045 gripe_invalid_conversion (tn.c_str (), "real row vector"); |
|
1046 } |
|
1047 |
|
1048 return retval; |
|
1049 } |
|
1050 |
|
1051 ComplexRowVector |
|
1052 octave_value::complex_row_vector_value (bool force_string_conv, |
|
1053 bool force_vector_conversion) const |
|
1054 { |
|
1055 ComplexRowVector retval; |
|
1056 |
|
1057 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1058 |
|
1059 if (error_state) |
|
1060 return retval; |
|
1061 |
|
1062 int nr = m.rows (); |
|
1063 int nc = m.columns (); |
|
1064 |
|
1065 if (nr == 1) |
|
1066 { |
|
1067 retval.resize (nc); |
|
1068 for (int i = 0; i < nc; i++) |
|
1069 retval (i) = m (0, i); |
|
1070 } |
|
1071 else |
|
1072 { |
3523
|
1073 std::string tn = type_name (); |
3419
|
1074 gripe_invalid_conversion (tn.c_str (), "complex row vector"); |
|
1075 } |
|
1076 |
|
1077 return retval; |
|
1078 } |
|
1079 |
|
1080 // Sloppy... |
|
1081 |
|
1082 Array<double> |
2376
|
1083 octave_value::vector_value (bool force_string_conv, |
|
1084 bool force_vector_conversion) const |
|
1085 { |
3419
|
1086 Array<double> retval; |
2376
|
1087 |
|
1088 Matrix m = matrix_value (force_string_conv); |
|
1089 |
|
1090 if (error_state) |
|
1091 return retval; |
|
1092 |
|
1093 int nr = m.rows (); |
|
1094 int nc = m.columns (); |
|
1095 |
|
1096 if (nr == 1) |
|
1097 { |
|
1098 retval.resize (nc); |
|
1099 for (int i = 0; i < nc; i++) |
|
1100 retval (i) = m (0, i); |
|
1101 } |
|
1102 else if (nc == 1) |
|
1103 { |
|
1104 retval.resize (nr); |
|
1105 for (int i = 0; i < nr; i++) |
|
1106 retval (i) = m (i, 0); |
|
1107 } |
4455
|
1108 else if (nr > 0 && nc > 0) |
2376
|
1109 { |
4455
|
1110 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1111 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1112 gripe_implicit_conversion (type_name (), "real vector"); |
|
1113 |
2376
|
1114 retval.resize (nr * nc); |
|
1115 int k = 0; |
|
1116 for (int j = 0; j < nc; j++) |
|
1117 for (int i = 0; i < nr; i++) |
4153
|
1118 { |
|
1119 OCTAVE_QUIT; |
|
1120 |
|
1121 retval (k++) = m (i, j); |
|
1122 } |
2376
|
1123 } |
|
1124 else |
|
1125 { |
3523
|
1126 std::string tn = type_name (); |
2376
|
1127 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1128 } |
|
1129 |
|
1130 return retval; |
|
1131 } |
|
1132 |
4044
|
1133 Array<int> |
|
1134 octave_value::int_vector_value (bool force_string_conv, bool require_int, |
|
1135 bool force_vector_conversion) const |
|
1136 { |
|
1137 Array<int> retval; |
|
1138 |
|
1139 Matrix m = matrix_value (force_string_conv); |
|
1140 |
|
1141 if (error_state) |
|
1142 return retval; |
|
1143 |
|
1144 int nr = m.rows (); |
|
1145 int nc = m.columns (); |
|
1146 |
|
1147 if (nr == 1) |
|
1148 { |
|
1149 retval.resize (nc); |
|
1150 for (int i = 0; i < nc; i++) |
|
1151 { |
4153
|
1152 OCTAVE_QUIT; |
|
1153 |
4044
|
1154 double d = m (0, i); |
|
1155 |
|
1156 if (require_int && D_NINT (d) != d) |
|
1157 { |
|
1158 error ("conversion to integer value failed"); |
|
1159 return retval; |
|
1160 } |
|
1161 |
|
1162 retval (i) = static_cast<int> (d); |
|
1163 } |
|
1164 } |
|
1165 else if (nc == 1) |
|
1166 { |
|
1167 retval.resize (nr); |
|
1168 for (int i = 0; i < nr; i++) |
|
1169 { |
4153
|
1170 OCTAVE_QUIT; |
|
1171 |
4044
|
1172 double d = m (i, 0); |
|
1173 |
|
1174 if (require_int && D_NINT (d) != d) |
|
1175 { |
|
1176 error ("conversion to integer value failed"); |
|
1177 return retval; |
|
1178 } |
|
1179 |
|
1180 retval (i) = static_cast<int> (d); |
|
1181 } |
|
1182 } |
4455
|
1183 else if (nr > 0 && nc > 0) |
4044
|
1184 { |
4455
|
1185 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1186 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1187 gripe_implicit_conversion (type_name (), "real vector"); |
|
1188 |
4044
|
1189 retval.resize (nr * nc); |
|
1190 int k = 0; |
|
1191 for (int j = 0; j < nc; j++) |
|
1192 { |
|
1193 for (int i = 0; i < nr; i++) |
|
1194 { |
4153
|
1195 OCTAVE_QUIT; |
|
1196 |
4044
|
1197 double d = m (i, j); |
|
1198 |
|
1199 if (require_int && D_NINT (d) != d) |
|
1200 { |
|
1201 error ("conversion to integer value failed"); |
|
1202 return retval; |
|
1203 } |
|
1204 |
|
1205 retval (k++) = static_cast<int> (d); |
|
1206 } |
|
1207 } |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 std::string tn = type_name (); |
|
1212 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1213 } |
|
1214 |
|
1215 return retval; |
|
1216 } |
|
1217 |
3419
|
1218 Array<Complex> |
2376
|
1219 octave_value::complex_vector_value (bool force_string_conv, |
|
1220 bool force_vector_conversion) const |
|
1221 { |
3419
|
1222 Array<Complex> retval; |
2376
|
1223 |
|
1224 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1225 |
|
1226 if (error_state) |
|
1227 return retval; |
|
1228 |
|
1229 int nr = m.rows (); |
|
1230 int nc = m.columns (); |
|
1231 |
|
1232 if (nr == 1) |
|
1233 { |
|
1234 retval.resize (nc); |
|
1235 for (int i = 0; i < nc; i++) |
4153
|
1236 { |
|
1237 OCTAVE_QUIT; |
|
1238 retval (i) = m (0, i); |
|
1239 } |
2376
|
1240 } |
|
1241 else if (nc == 1) |
|
1242 { |
|
1243 retval.resize (nr); |
|
1244 for (int i = 0; i < nr; i++) |
4153
|
1245 { |
|
1246 OCTAVE_QUIT; |
|
1247 retval (i) = m (i, 0); |
|
1248 } |
2376
|
1249 } |
4455
|
1250 else if (nr > 0 && nc > 0) |
2376
|
1251 { |
4455
|
1252 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1253 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1254 gripe_implicit_conversion (type_name (), "complex vector"); |
|
1255 |
2376
|
1256 retval.resize (nr * nc); |
|
1257 int k = 0; |
|
1258 for (int j = 0; j < nc; j++) |
|
1259 for (int i = 0; i < nr; i++) |
4153
|
1260 { |
|
1261 OCTAVE_QUIT; |
|
1262 retval (k++) = m (i, j); |
|
1263 } |
2376
|
1264 } |
|
1265 else |
|
1266 { |
3523
|
1267 std::string tn = type_name (); |
2376
|
1268 gripe_invalid_conversion (tn.c_str (), "complex vector"); |
|
1269 } |
|
1270 |
|
1271 return retval; |
|
1272 } |
|
1273 |
4452
|
1274 octave_value |
4457
|
1275 octave_value::convert_to_str (bool pad, bool force) const |
4452
|
1276 { |
4457
|
1277 octave_value retval = convert_to_str_internal (pad, force); |
4452
|
1278 |
4457
|
1279 if (! force && is_numeric_type () && Vwarn_num_to_str) |
4452
|
1280 gripe_implicit_conversion (type_name (), retval.type_name ()); |
|
1281 |
|
1282 return retval; |
|
1283 } |
|
1284 |
2376
|
1285 void |
4005
|
1286 octave_value::print_with_name (std::ostream& output_buf, |
|
1287 const std::string& name, |
2903
|
1288 bool print_padding) const |
2376
|
1289 { |
4005
|
1290 if (! (evaluating_function_body && Vsilent_functions)) |
|
1291 { |
|
1292 bool pad_after = print_name_tag (output_buf, name); |
2376
|
1293 |
4005
|
1294 print (output_buf); |
2376
|
1295 |
4005
|
1296 if (print_padding && pad_after) |
|
1297 newline (output_buf); |
|
1298 } |
2376
|
1299 } |
|
1300 |
|
1301 static void |
3523
|
1302 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) |
2413
|
1303 { |
2903
|
1304 error ("assignment of `%s' to indexed `%s' not implemented", |
2413
|
1305 tn2.c_str (), tn1.c_str ()); |
|
1306 } |
|
1307 |
|
1308 static void |
3933
|
1309 gripe_assign_conversion_failed (const std::string& tn1, |
|
1310 const std::string& tn2) |
2413
|
1311 { |
2903
|
1312 error ("type conversion for assignment of `%s' to indexed `%s' failed", |
2413
|
1313 tn2.c_str (), tn1.c_str ()); |
|
1314 } |
|
1315 |
3933
|
1316 octave_value |
4247
|
1317 octave_value::numeric_assign (const std::string& type, |
4219
|
1318 const std::list<octave_value_list>& idx, |
2413
|
1319 const octave_value& rhs) |
|
1320 { |
3933
|
1321 octave_value retval; |
2413
|
1322 |
|
1323 int t_lhs = type_id (); |
|
1324 int t_rhs = rhs.type_id (); |
|
1325 |
2880
|
1326 assign_op_fcn f |
3933
|
1327 = octave_value_typeinfo::lookup_assign_op (op_asn_eq, t_lhs, t_rhs); |
|
1328 |
|
1329 bool done = false; |
2413
|
1330 |
|
1331 if (f) |
|
1332 { |
3933
|
1333 f (*this, idx.front (), rhs.get_rep ()); |
2413
|
1334 |
3933
|
1335 done = (! error_state); |
2413
|
1336 } |
3933
|
1337 |
|
1338 if (done) |
|
1339 retval = octave_value (this, count + 1); |
3196
|
1340 else |
|
1341 { |
3933
|
1342 int t_result |
|
1343 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); |
|
1344 |
|
1345 if (t_result >= 0) |
|
1346 { |
|
1347 type_conv_fcn cf |
|
1348 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); |
|
1349 |
|
1350 if (cf) |
|
1351 { |
|
1352 octave_value *tmp (cf (*this)); |
3196
|
1353 |
3933
|
1354 if (tmp) |
|
1355 { |
|
1356 retval = tmp->subsasgn (type, idx, rhs); |
|
1357 |
4505
|
1358 // The assignment may have converted to a type that |
|
1359 // is wider than necessary. |
|
1360 |
|
1361 retval.maybe_mutate (); |
|
1362 |
3933
|
1363 done = (! error_state); |
|
1364 } |
|
1365 else |
|
1366 gripe_assign_conversion_failed (type_name (), |
|
1367 rhs.type_name ()); |
|
1368 } |
|
1369 else |
|
1370 gripe_indexed_assignment (type_name (), rhs.type_name ()); |
|
1371 } |
|
1372 |
|
1373 if (! (done || error_state)) |
3196
|
1374 { |
3933
|
1375 octave_value tmp_rhs; |
|
1376 type_conv_fcn cf_rhs = rhs.numeric_conversion_function (); |
|
1377 |
|
1378 if (cf_rhs) |
|
1379 { |
|
1380 octave_value *tmp = cf_rhs (rhs.get_rep ()); |
|
1381 |
|
1382 if (tmp) |
|
1383 tmp_rhs = octave_value (tmp); |
|
1384 else |
|
1385 { |
|
1386 gripe_assign_conversion_failed (type_name (), |
|
1387 rhs.type_name ()); |
|
1388 return octave_value (); |
|
1389 } |
|
1390 } |
|
1391 else |
|
1392 tmp_rhs = rhs; |
|
1393 |
|
1394 type_conv_fcn cf_this = numeric_conversion_function (); |
|
1395 |
|
1396 octave_value *tmp_lhs = this; |
3196
|
1397 |
3933
|
1398 if (cf_this) |
|
1399 { |
|
1400 octave_value *tmp = cf_this (*this); |
|
1401 |
|
1402 if (tmp) |
|
1403 tmp_lhs = tmp; |
|
1404 else |
|
1405 { |
|
1406 gripe_assign_conversion_failed (type_name (), |
|
1407 rhs.type_name ()); |
|
1408 return octave_value (); |
|
1409 } |
|
1410 } |
|
1411 |
|
1412 if (cf_this || cf_rhs) |
|
1413 { |
|
1414 retval = tmp_lhs->subsasgn (type, idx, tmp_rhs); |
|
1415 |
|
1416 done = (! error_state); |
|
1417 } |
|
1418 else |
|
1419 gripe_no_conversion (assign_op_as_string (op_asn_eq), |
|
1420 type_name (), rhs.type_name ()); |
3196
|
1421 } |
|
1422 } |
2413
|
1423 |
|
1424 return retval; |
|
1425 } |
|
1426 |
|
1427 static void |
3933
|
1428 gripe_binary_op (const std::string& on, const std::string& tn1, |
|
1429 const std::string& tn2) |
2376
|
1430 { |
2903
|
1431 error ("binary operator `%s' not implemented for `%s' by `%s' operations", |
2376
|
1432 on.c_str (), tn1.c_str (), tn2.c_str ()); |
|
1433 } |
|
1434 |
3203
|
1435 static void |
3523
|
1436 gripe_binary_op_conv (const std::string& on) |
3203
|
1437 { |
|
1438 error ("type conversion failed for binary operator `%s'", on.c_str ()); |
|
1439 } |
|
1440 |
2376
|
1441 octave_value |
3933
|
1442 do_binary_op (octave_value::binary_op op, |
|
1443 const octave_value& v1, const octave_value& v2) |
2376
|
1444 { |
|
1445 octave_value retval; |
|
1446 |
|
1447 int t1 = v1.type_id (); |
|
1448 int t2 = v2.type_id (); |
|
1449 |
2427
|
1450 binary_op_fcn f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1451 |
|
1452 if (f) |
|
1453 retval = f (*v1.rep, *v2.rep); |
|
1454 else |
|
1455 { |
|
1456 octave_value tv1; |
2427
|
1457 type_conv_fcn cf1 = v1.numeric_conversion_function (); |
2376
|
1458 |
|
1459 if (cf1) |
|
1460 { |
3203
|
1461 octave_value *tmp = cf1 (*v1.rep); |
|
1462 |
|
1463 if (tmp) |
|
1464 { |
|
1465 tv1 = octave_value (tmp); |
|
1466 t1 = tv1.type_id (); |
|
1467 } |
|
1468 else |
|
1469 { |
|
1470 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1471 return retval; |
|
1472 } |
2376
|
1473 } |
|
1474 else |
|
1475 tv1 = v1; |
|
1476 |
|
1477 octave_value tv2; |
2427
|
1478 type_conv_fcn cf2 = v2.numeric_conversion_function (); |
2376
|
1479 |
|
1480 if (cf2) |
|
1481 { |
3203
|
1482 octave_value *tmp = cf2 (*v2.rep); |
|
1483 |
|
1484 if (tmp) |
|
1485 { |
|
1486 tv2 = octave_value (tmp); |
|
1487 t2 = tv2.type_id (); |
|
1488 } |
|
1489 else |
|
1490 { |
|
1491 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1492 return retval; |
|
1493 } |
2376
|
1494 } |
|
1495 else |
|
1496 tv2 = v2; |
|
1497 |
|
1498 if (cf1 || cf2) |
|
1499 { |
4587
|
1500 f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1501 |
|
1502 if (f) |
|
1503 retval = f (*tv1.rep, *tv2.rep); |
|
1504 else |
|
1505 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1506 v1.type_name (), v2.type_name ()); |
|
1507 } |
|
1508 else |
|
1509 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1510 v1.type_name (), v2.type_name ()); |
|
1511 } |
|
1512 |
|
1513 return retval; |
|
1514 } |
|
1515 |
3933
|
1516 void |
|
1517 octave_value::print_info (std::ostream& os, const std::string& prefix) const |
|
1518 { |
|
1519 os << prefix << "type_name: " << type_name () << "\n" |
|
1520 << prefix << "count: " << get_count () << "\n" |
|
1521 << prefix << "rep info: "; |
|
1522 |
|
1523 rep->print_info (os, prefix + " "); |
|
1524 } |
|
1525 |
3203
|
1526 static void |
3523
|
1527 gripe_unary_op (const std::string& on, const std::string& tn) |
3203
|
1528 { |
|
1529 error ("unary operator `%s' not implemented for `%s' operands", |
|
1530 on.c_str (), tn.c_str ()); |
|
1531 } |
|
1532 |
|
1533 static void |
3523
|
1534 gripe_unary_op_conv (const std::string& on) |
3203
|
1535 { |
|
1536 error ("type conversion failed for unary operator `%s'", on.c_str ()); |
|
1537 } |
|
1538 |
|
1539 octave_value |
|
1540 do_unary_op (octave_value::unary_op op, const octave_value& v) |
|
1541 { |
|
1542 octave_value retval; |
|
1543 |
|
1544 int t = v.type_id (); |
|
1545 |
|
1546 unary_op_fcn f = octave_value_typeinfo::lookup_unary_op (op, t); |
|
1547 |
|
1548 if (f) |
|
1549 retval = f (*v.rep); |
|
1550 else |
|
1551 { |
|
1552 octave_value tv; |
|
1553 type_conv_fcn cf = v.numeric_conversion_function (); |
|
1554 |
|
1555 if (cf) |
|
1556 { |
|
1557 octave_value *tmp = cf (*v.rep); |
|
1558 |
|
1559 if (tmp) |
|
1560 { |
|
1561 tv = octave_value (tmp); |
|
1562 t = tv.type_id (); |
|
1563 |
4587
|
1564 f = octave_value_typeinfo::lookup_unary_op (op, t); |
3203
|
1565 |
|
1566 if (f) |
|
1567 retval = f (*tv.rep); |
|
1568 else |
|
1569 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1570 v.type_name ()); |
|
1571 } |
|
1572 else |
|
1573 gripe_unary_op_conv (octave_value::unary_op_as_string (op)); |
|
1574 } |
|
1575 else |
|
1576 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1577 v.type_name ()); |
|
1578 } |
|
1579 |
|
1580 return retval; |
|
1581 } |
|
1582 |
|
1583 static void |
3933
|
1584 gripe_unary_op_conversion_failed (const std::string& op, |
|
1585 const std::string& tn) |
3203
|
1586 { |
|
1587 error ("operator %s: type conversion for `%s' failed", |
|
1588 op.c_str (), tn.c_str ()); |
|
1589 } |
|
1590 |
3933
|
1591 const octave_value& |
|
1592 octave_value::do_non_const_unary_op (unary_op op) |
3203
|
1593 { |
|
1594 octave_value retval; |
|
1595 |
|
1596 int t = type_id (); |
|
1597 |
|
1598 non_const_unary_op_fcn f |
|
1599 = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1600 |
|
1601 if (f) |
|
1602 { |
|
1603 make_unique (); |
|
1604 |
|
1605 f (*rep); |
|
1606 } |
|
1607 else |
|
1608 { |
|
1609 type_conv_fcn cf = numeric_conversion_function (); |
|
1610 |
|
1611 if (cf) |
|
1612 { |
|
1613 octave_value *tmp = cf (*rep); |
|
1614 |
|
1615 if (tmp) |
|
1616 { |
|
1617 octave_value *old_rep = rep; |
|
1618 rep = tmp; |
|
1619 rep->count = 1; |
|
1620 |
|
1621 t = type_id (); |
|
1622 |
|
1623 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1624 |
|
1625 if (f) |
|
1626 { |
|
1627 f (*rep); |
|
1628 |
|
1629 if (old_rep && --old_rep->count == 0) |
|
1630 delete old_rep; |
|
1631 } |
|
1632 else |
|
1633 { |
|
1634 if (old_rep) |
|
1635 { |
|
1636 if (--rep->count == 0) |
|
1637 delete rep; |
|
1638 |
|
1639 rep = old_rep; |
|
1640 } |
|
1641 |
|
1642 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1643 type_name ()); |
|
1644 } |
|
1645 } |
|
1646 else |
|
1647 gripe_unary_op_conversion_failed |
|
1648 (octave_value::unary_op_as_string (op), type_name ()); |
|
1649 } |
|
1650 else |
|
1651 gripe_unary_op (octave_value::unary_op_as_string (op), type_name ()); |
|
1652 } |
3933
|
1653 |
|
1654 return *this; |
3203
|
1655 } |
|
1656 |
3933
|
1657 #if 0 |
3205
|
1658 static void |
3933
|
1659 gripe_unary_op_failed_or_no_method (const std::string& on, |
|
1660 const std::string& tn) |
3205
|
1661 { |
|
1662 error ("operator %s: no method, or unable to evaluate for %s operand", |
|
1663 on.c_str (), tn.c_str ()); |
|
1664 } |
3933
|
1665 #endif |
3205
|
1666 |
|
1667 void |
3933
|
1668 octave_value::do_non_const_unary_op (unary_op op, const octave_value_list& idx) |
3205
|
1669 { |
3933
|
1670 abort (); |
|
1671 } |
|
1672 |
|
1673 octave_value |
4247
|
1674 octave_value::do_non_const_unary_op (unary_op op, const std::string& type, |
4219
|
1675 const std::list<octave_value_list>& idx) |
3933
|
1676 { |
|
1677 octave_value retval; |
|
1678 |
|
1679 if (idx.empty ()) |
|
1680 { |
|
1681 do_non_const_unary_op (op); |
3205
|
1682 |
3933
|
1683 retval = *this; |
|
1684 } |
|
1685 else |
|
1686 { |
|
1687 // XXX FIXME XXX -- only do the following stuff if we can't find a |
|
1688 // specific function to call to handle the op= operation for the |
|
1689 // types we have. |
3205
|
1690 |
3933
|
1691 assign_op assop = unary_op_to_assign_op (op); |
|
1692 |
|
1693 retval = assign (assop, type, idx, 1.0); |
|
1694 } |
|
1695 |
|
1696 return retval; |
3205
|
1697 } |
|
1698 |
2903
|
1699 // Current indentation. |
|
1700 int octave_value::curr_print_indent_level = 0; |
|
1701 |
3018
|
1702 // TRUE means we are at the beginning of a line. |
2903
|
1703 bool octave_value::beginning_of_line = true; |
|
1704 |
|
1705 // Each print() function should call this before printing anything. |
|
1706 // |
|
1707 // This doesn't need to be fast, but isn't there a better way? |
|
1708 |
|
1709 void |
3523
|
1710 octave_value::indent (std::ostream& os) const |
2903
|
1711 { |
|
1712 assert (curr_print_indent_level >= 0); |
|
1713 |
|
1714 if (beginning_of_line) |
|
1715 { |
|
1716 // XXX FIXME XXX -- do we need this? |
|
1717 // os << prefix; |
|
1718 |
|
1719 for (int i = 0; i < curr_print_indent_level; i++) |
|
1720 os << " "; |
|
1721 |
|
1722 beginning_of_line = false; |
|
1723 } |
|
1724 } |
|
1725 |
|
1726 // All print() functions should use this to print new lines. |
|
1727 |
|
1728 void |
3523
|
1729 octave_value::newline (std::ostream& os) const |
2903
|
1730 { |
|
1731 os << "\n"; |
|
1732 |
|
1733 beginning_of_line = true; |
|
1734 } |
|
1735 |
|
1736 // For ressetting print state. |
|
1737 |
|
1738 void |
|
1739 octave_value::reset (void) const |
|
1740 { |
|
1741 beginning_of_line = true; |
|
1742 curr_print_indent_level = 0; |
|
1743 } |
|
1744 |
3205
|
1745 octave_value::assign_op |
|
1746 octave_value::unary_op_to_assign_op (unary_op op) |
|
1747 { |
|
1748 assign_op binop = unknown_assign_op; |
|
1749 |
|
1750 switch (op) |
|
1751 { |
3533
|
1752 case op_incr: |
|
1753 binop = op_add_eq; |
3205
|
1754 break; |
|
1755 |
3533
|
1756 case op_decr: |
|
1757 binop = op_sub_eq; |
3205
|
1758 break; |
|
1759 |
|
1760 default: |
|
1761 { |
3523
|
1762 std::string on = unary_op_as_string (op); |
3205
|
1763 error ("operator %s: no assign operator found", on.c_str ()); |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 return binop; |
|
1768 } |
|
1769 |
3204
|
1770 octave_value::binary_op |
|
1771 octave_value::op_eq_to_binary_op (assign_op op) |
|
1772 { |
|
1773 binary_op binop = unknown_binary_op; |
|
1774 |
|
1775 switch (op) |
|
1776 { |
3533
|
1777 case op_add_eq: |
|
1778 binop = op_add; |
3204
|
1779 break; |
|
1780 |
3533
|
1781 case op_sub_eq: |
|
1782 binop = op_sub; |
3204
|
1783 break; |
|
1784 |
3533
|
1785 case op_mul_eq: |
|
1786 binop = op_mul; |
3204
|
1787 break; |
|
1788 |
3533
|
1789 case op_div_eq: |
|
1790 binop = op_div; |
3204
|
1791 break; |
|
1792 |
3533
|
1793 case op_ldiv_eq: |
|
1794 binop = op_ldiv; |
3204
|
1795 break; |
|
1796 |
4018
|
1797 case op_pow_eq: |
|
1798 binop = op_pow; |
|
1799 break; |
|
1800 |
3533
|
1801 case op_lshift_eq: |
|
1802 binop = op_lshift; |
3204
|
1803 break; |
|
1804 |
3533
|
1805 case op_rshift_eq: |
|
1806 binop = op_rshift; |
3204
|
1807 break; |
|
1808 |
3533
|
1809 case op_el_mul_eq: |
|
1810 binop = op_el_mul; |
3204
|
1811 break; |
|
1812 |
3533
|
1813 case op_el_div_eq: |
|
1814 binop = op_el_div; |
3204
|
1815 break; |
|
1816 |
3533
|
1817 case op_el_ldiv_eq: |
|
1818 binop = op_el_ldiv; |
3204
|
1819 break; |
|
1820 |
4018
|
1821 case op_el_pow_eq: |
|
1822 binop = op_el_pow; |
|
1823 break; |
|
1824 |
3533
|
1825 case op_el_and_eq: |
|
1826 binop = op_el_and; |
3204
|
1827 break; |
|
1828 |
3533
|
1829 case op_el_or_eq: |
|
1830 binop = op_el_or; |
3204
|
1831 break; |
|
1832 |
|
1833 default: |
|
1834 { |
3523
|
1835 std::string on = assign_op_as_string (op); |
3204
|
1836 error ("operator %s: no binary operator found", on.c_str ()); |
|
1837 } |
|
1838 } |
|
1839 |
|
1840 return binop; |
|
1841 } |
|
1842 |
3933
|
1843 octave_value |
|
1844 octave_value::empty_conv (const std::string& type, const octave_value& rhs) |
|
1845 { |
|
1846 octave_value retval; |
|
1847 |
|
1848 if (type.length () > 0) |
|
1849 { |
|
1850 switch (type[0]) |
|
1851 { |
|
1852 case '(': |
|
1853 { |
|
1854 if (type.length () > 1 && type[1] == '.') |
|
1855 retval = Octave_map (); |
|
1856 else |
|
1857 retval = octave_value (rhs.empty_clone ()); |
|
1858 } |
|
1859 break; |
|
1860 |
|
1861 case '{': |
|
1862 retval = Cell (); |
|
1863 break; |
|
1864 |
|
1865 case '.': |
|
1866 retval = Octave_map (); |
|
1867 break; |
|
1868 |
|
1869 default: |
|
1870 panic_impossible (); |
|
1871 } |
|
1872 } |
|
1873 else |
|
1874 retval = octave_value (rhs.empty_clone ()); |
|
1875 |
|
1876 return retval; |
|
1877 } |
|
1878 |
2376
|
1879 void |
|
1880 install_types (void) |
|
1881 { |
|
1882 octave_base_value::register_type (); |
3928
|
1883 octave_cell::register_type (); |
2376
|
1884 octave_scalar::register_type (); |
|
1885 octave_complex::register_type (); |
|
1886 octave_matrix::register_type (); |
|
1887 octave_complex_matrix::register_type (); |
|
1888 octave_range::register_type (); |
2825
|
1889 octave_bool::register_type (); |
|
1890 octave_bool_matrix::register_type (); |
2376
|
1891 octave_char_matrix::register_type (); |
|
1892 octave_char_matrix_str::register_type (); |
|
1893 octave_struct::register_type (); |
2903
|
1894 octave_file::register_type (); |
2880
|
1895 octave_list::register_type (); |
3977
|
1896 octave_cs_list::register_type (); |
2376
|
1897 octave_all_va_args::register_type (); |
|
1898 octave_magic_colon::register_type (); |
2974
|
1899 octave_builtin::register_type (); |
|
1900 octave_mapper::register_type (); |
|
1901 octave_user_function::register_type (); |
4649
|
1902 octave_dld_function::register_type (); |
4643
|
1903 octave_fcn_handle::register_type (); |
|
1904 octave_streamoff::register_type (); |
2376
|
1905 } |
|
1906 |
|
1907 static int |
4455
|
1908 warn_fortran_indexing (void) |
2376
|
1909 { |
4455
|
1910 Vwarn_fortran_indexing = check_preference ("warn_fortran_indexing"); |
2376
|
1911 |
4455
|
1912 liboctave_wfi_flag = Vwarn_fortran_indexing; |
2376
|
1913 |
|
1914 return 0; |
|
1915 } |
|
1916 |
|
1917 static int |
4452
|
1918 warn_imag_to_real (void) |
4257
|
1919 { |
4452
|
1920 Vwarn_imag_to_real = check_preference ("warn_imag_to_real"); |
4257
|
1921 |
|
1922 return 0; |
|
1923 } |
|
1924 |
|
1925 static int |
4452
|
1926 warn_num_to_str (void) |
2376
|
1927 { |
4452
|
1928 Vwarn_num_to_str = check_preference ("warn_num_to_str"); |
2376
|
1929 |
|
1930 return 0; |
|
1931 } |
|
1932 |
|
1933 static int |
4452
|
1934 warn_str_to_num (void) |
2376
|
1935 { |
4452
|
1936 Vwarn_str_to_num = check_preference ("warn_str_to_num"); |
2376
|
1937 |
|
1938 return 0; |
|
1939 } |
|
1940 |
|
1941 static int |
|
1942 print_answer_id_name (void) |
|
1943 { |
|
1944 Vprint_answer_id_name = check_preference ("print_answer_id_name"); |
|
1945 |
|
1946 return 0; |
|
1947 } |
|
1948 |
|
1949 static int |
4461
|
1950 warn_resize_on_range_error (void) |
2376
|
1951 { |
4461
|
1952 Vwarn_resize_on_range_error |
|
1953 = check_preference ("warn_resize_on_range_error"); |
2376
|
1954 |
4461
|
1955 liboctave_wrore_flag = Vwarn_resize_on_range_error; |
2376
|
1956 |
|
1957 return 0; |
|
1958 } |
|
1959 |
|
1960 static int |
4005
|
1961 silent_functions (void) |
|
1962 { |
|
1963 Vsilent_functions = check_preference ("silent_functions"); |
|
1964 |
|
1965 return 0; |
|
1966 } |
|
1967 |
|
1968 static int |
2376
|
1969 struct_levels_to_print (void) |
|
1970 { |
|
1971 double val; |
|
1972 if (builtin_real_scalar_variable ("struct_levels_to_print", val) |
|
1973 && ! xisnan (val)) |
|
1974 { |
|
1975 int ival = NINT (val); |
3961
|
1976 if (ival == val) |
2376
|
1977 { |
|
1978 Vstruct_levels_to_print = ival; |
|
1979 return 0; |
|
1980 } |
|
1981 } |
|
1982 gripe_invalid_value_specified ("struct_levels_to_print"); |
|
1983 return -1; |
|
1984 } |
|
1985 |
|
1986 static int |
|
1987 warn_divide_by_zero (void) |
|
1988 { |
|
1989 Vwarn_divide_by_zero = check_preference ("warn_divide_by_zero"); |
|
1990 |
|
1991 return 0; |
|
1992 } |
|
1993 |
|
1994 void |
2909
|
1995 symbols_of_ov (void) |
2376
|
1996 { |
4233
|
1997 DEFVAR (print_answer_id_name, true, print_answer_id_name, |
3372
|
1998 "-*- texinfo -*-\n\ |
|
1999 @defvr {Built-in Variable} print_answer_id_name\n\ |
|
2000 If the value of @code{print_answer_id_name} is nonzero, variable\n\ |
|
2001 names are printed along with the result. Otherwise, only the result\n\ |
|
2002 values are printed. The default value is 1.\n\ |
|
2003 @end defvr"); |
2376
|
2004 |
4233
|
2005 DEFVAR (silent_functions, false, silent_functions, |
4005
|
2006 "-*- texinfo -*-\n\ |
|
2007 @defvr {Built-in Variable} silent_functions\n\ |
|
2008 If the value of @code{silent_functions} is nonzero, internal output\n\ |
|
2009 from a function is suppressed. Otherwise, the results of expressions\n\ |
|
2010 within a function body that are not terminated with a semicolon will\n\ |
|
2011 have their values printed. The default value is 0.\n\ |
|
2012 \n\ |
|
2013 For example, if the function\n\ |
|
2014 \n\ |
|
2015 @example\n\ |
|
2016 function f ()\n\ |
|
2017 2 + 2\n\ |
|
2018 endfunction\n\ |
|
2019 @end example\n\ |
|
2020 \n\ |
|
2021 @noindent\n\ |
|
2022 is executed, Octave will either print @samp{ans = 4} or nothing\n\ |
|
2023 depending on the value of @code{silent_functions}.\n\ |
|
2024 @end defvr"); |
|
2025 |
3258
|
2026 DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print, |
3361
|
2027 "-*- texinfo -*-\n\ |
|
2028 @defvr {Built-in Variable} struct_levels_to_print\n\ |
|
2029 You can tell Octave how many structure levels to display by setting the\n\ |
|
2030 built-in variable @code{struct_levels_to_print}. The default value is 2.\n\ |
3363
|
2031 @end defvr"); |
2376
|
2032 |
4233
|
2033 DEFVAR (warn_divide_by_zero, true, warn_divide_by_zero, |
3371
|
2034 "-*- texinfo -*-\n\ |
|
2035 @defvr {Built-in Variable} warn_divide_by_zero\n\ |
|
2036 If the value of @code{warn_divide_by_zero} is nonzero, a warning\n\ |
|
2037 is issued when Octave encounters a division by zero. If the value is\n\ |
|
2038 0, the warning is omitted. The default value is 1.\n\ |
|
2039 @end defvr"); |
4451
|
2040 |
4455
|
2041 DEFVAR (warn_fortran_indexing, false, warn_fortran_indexing, |
|
2042 "-*- texinfo -*-\n\ |
|
2043 @defvr {Built-in Variable} warn_fortran_indexing\n\ |
|
2044 If the value of @code{warn_fortran_indexing} is nonzero, a warning is\n\ |
|
2045 printed for expressions which select elements of a two-dimensional matrix\n\ |
|
2046 using a single index. The default value is 0.\n\ |
|
2047 @end defvr"); |
|
2048 |
4451
|
2049 DEFVAR (warn_imag_to_real, false, warn_imag_to_real, |
|
2050 "-*- texinfo -*-\n\ |
|
2051 @defvr {Built-in Variable} warn_imag_to_real\n\ |
|
2052 If the value of @code{warn_imag_to_real} is nonzero, a warning is\n\ |
|
2053 printed for implicit conversions of complex numbers to real numbers.\n\ |
|
2054 The default value is 0.\n\ |
|
2055 @end defvr"); |
4452
|
2056 |
|
2057 DEFVAR (warn_num_to_str, true, warn_num_to_str, |
|
2058 "-*- texinfo -*-\n\ |
|
2059 @defvr {Built-in Variable} warn_num_to_str\n\ |
|
2060 If the value of @code{warn_num_to_str} is nonzero, a warning is\n\ |
|
2061 printed for implicit conversions of numbers to their ASCII character\n\ |
|
2062 equivalents when strings are constructed using a mixture of strings and\n\ |
|
2063 numbers in matrix notation. For example,\n\ |
|
2064 \n\ |
|
2065 @example\n\ |
|
2066 @group\n\ |
|
2067 [ \"f\", 111, 111 ]\n\ |
|
2068 @result{} \"foo\"\n\ |
|
2069 @end group\n\ |
|
2070 @end example\n\ |
|
2071 elicits a warning if @code{warn_num_to_str} is nonzero. The default\n\ |
|
2072 value is 1.\n\ |
|
2073 @end defvr"); |
|
2074 |
4461
|
2075 DEFVAR (warn_resize_on_range_error, false, warn_resize_on_range_error, |
|
2076 "-*- texinfo -*-\n\ |
|
2077 @defvr {Built-in Variable} warn_resize_on_range_error\n\ |
|
2078 If the value of @code{warn_resize_on_range_error} is nonzero, print a\n\ |
|
2079 warning when a matrix is resized by an indexed assignment with\n\ |
|
2080 indices outside the current bounds. The default value is 0.\n\ |
|
2081 @end defvr"); |
|
2082 |
4452
|
2083 DEFVAR (warn_str_to_num, false, warn_str_to_num, |
|
2084 "-*- texinfo -*-\n\ |
|
2085 @defvr {Built-in Variable} warn_str_to_num\n\ |
|
2086 If the value of @code{warn_str_to_num} is nonzero, a warning is printed\n\ |
|
2087 for implicit conversions of strings to their numeric ASCII equivalents.\n\ |
|
2088 For example,\n\ |
|
2089 @example\n\ |
|
2090 @group\n\ |
|
2091 \"abc\" + 0\n\ |
|
2092 @result{} 97 98 99\n\ |
|
2093 @end group\n\ |
|
2094 @end example\n\ |
|
2095 elicits a warning if @code{warn_str_to_num} is nonzero. The default\n\ |
|
2096 value is 0.\n\ |
|
2097 @end defvr"); |
2376
|
2098 } |
|
2099 |
|
2100 /* |
|
2101 ;;; Local Variables: *** |
|
2102 ;;; mode: C++ *** |
|
2103 ;;; End: *** |
|
2104 */ |