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