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 { |
4219
|
693 if (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 (); |
|
842 |
|
843 for (int i = 0; i < dv.length (); i++) |
|
844 { |
|
845 if (dv(i) < 0) |
|
846 { |
|
847 retval = -1; |
|
848 break; |
|
849 } |
|
850 |
|
851 if (dv(i) > retval) |
|
852 retval = dv(i); |
|
853 } |
|
854 |
|
855 return retval; |
|
856 } |
|
857 |
|
858 int |
|
859 octave_value::ndims (void) const |
|
860 { |
|
861 dim_vector dv = dims (); |
|
862 |
|
863 int n_dims = dv.length (); |
|
864 |
|
865 // Remove trailing singleton dimensions. |
|
866 |
|
867 for (int i = n_dims; i > 2; i--) |
|
868 { |
|
869 if (dv(i-1) == 1) |
|
870 n_dims--; |
|
871 else |
|
872 break; |
|
873 } |
|
874 |
|
875 // The result is always >= 2. |
|
876 |
|
877 if (n_dims < 2) |
|
878 n_dims = 2; |
|
879 |
|
880 return n_dims; |
|
881 } |
|
882 |
|
883 int |
|
884 octave_value::numel (void) const |
|
885 { |
|
886 dim_vector dv = dims (); |
|
887 |
|
888 int n_dims = dv.length (); |
|
889 |
|
890 int retval = n_dims > 0 ? dv(0) : 0; |
|
891 |
|
892 for (int i = 1; i < n_dims; i++) |
|
893 retval *= dv(i); |
|
894 |
|
895 return retval; |
|
896 } |
|
897 |
3351
|
898 Cell |
|
899 octave_value::cell_value (void) const |
|
900 { |
|
901 return rep->cell_value (); |
|
902 } |
|
903 |
2376
|
904 Octave_map |
|
905 octave_value::map_value (void) const |
|
906 { |
|
907 return rep->map_value (); |
|
908 } |
|
909 |
3340
|
910 octave_stream |
2903
|
911 octave_value::stream_value (void) const |
|
912 { |
|
913 return rep->stream_value (); |
|
914 } |
|
915 |
|
916 int |
|
917 octave_value::stream_number (void) const |
|
918 { |
|
919 return rep->stream_number (); |
|
920 } |
|
921 |
2974
|
922 octave_function * |
|
923 octave_value::function_value (bool silent) |
|
924 { |
|
925 return rep->function_value (silent); |
|
926 } |
|
927 |
4346
|
928 octave_fcn_handle * |
4343
|
929 octave_value::fcn_handle_value (bool silent) |
|
930 { |
|
931 return rep->fcn_handle_value (silent); |
|
932 } |
|
933 |
2880
|
934 octave_value_list |
|
935 octave_value::list_value (void) const |
|
936 { |
|
937 return rep->list_value (); |
|
938 } |
|
939 |
2376
|
940 ColumnVector |
3419
|
941 octave_value::column_vector_value (bool force_string_conv, |
|
942 bool force_vector_conversion) const |
|
943 { |
|
944 ColumnVector retval; |
|
945 |
|
946 Matrix m = matrix_value (force_string_conv); |
|
947 |
|
948 if (error_state) |
|
949 return retval; |
|
950 |
|
951 int nr = m.rows (); |
|
952 int nc = m.columns (); |
|
953 |
|
954 if (nc == 1) |
|
955 { |
|
956 retval.resize (nr); |
|
957 for (int i = 0; i < nr; i++) |
|
958 retval (i) = m (i, 0); |
|
959 } |
|
960 else |
|
961 { |
3523
|
962 std::string tn = type_name (); |
3419
|
963 gripe_invalid_conversion (tn.c_str (), "real column vector"); |
|
964 } |
|
965 |
|
966 return retval; |
|
967 } |
|
968 |
|
969 ComplexColumnVector |
|
970 octave_value::complex_column_vector_value (bool force_string_conv, |
|
971 bool force_vector_conversion) const |
|
972 { |
|
973 ComplexColumnVector retval; |
|
974 |
|
975 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
976 |
|
977 if (error_state) |
|
978 return retval; |
|
979 |
|
980 int nr = m.rows (); |
|
981 int nc = m.columns (); |
|
982 |
|
983 if (nc == 1) |
|
984 { |
3465
|
985 retval.resize (nr); |
|
986 for (int i = 0; i < nr; i++) |
3419
|
987 retval (i) = m (i, 0); |
|
988 } |
|
989 else |
|
990 { |
3523
|
991 std::string tn = type_name (); |
3419
|
992 gripe_invalid_conversion (tn.c_str (), "complex column vector"); |
|
993 } |
|
994 |
|
995 return retval; |
|
996 } |
|
997 |
|
998 RowVector |
|
999 octave_value::row_vector_value (bool force_string_conv, |
|
1000 bool force_vector_conversion) const |
|
1001 { |
|
1002 RowVector retval; |
|
1003 |
|
1004 Matrix m = matrix_value (force_string_conv); |
|
1005 |
|
1006 if (error_state) |
|
1007 return retval; |
|
1008 |
|
1009 int nr = m.rows (); |
|
1010 int nc = m.columns (); |
|
1011 |
|
1012 if (nr == 1) |
|
1013 { |
|
1014 retval.resize (nc); |
|
1015 for (int i = 0; i < nc; i++) |
|
1016 retval (i) = m (0, i); |
|
1017 } |
|
1018 else |
|
1019 { |
3523
|
1020 std::string tn = type_name (); |
3419
|
1021 gripe_invalid_conversion (tn.c_str (), "real row vector"); |
|
1022 } |
|
1023 |
|
1024 return retval; |
|
1025 } |
|
1026 |
|
1027 ComplexRowVector |
|
1028 octave_value::complex_row_vector_value (bool force_string_conv, |
|
1029 bool force_vector_conversion) const |
|
1030 { |
|
1031 ComplexRowVector retval; |
|
1032 |
|
1033 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1034 |
|
1035 if (error_state) |
|
1036 return retval; |
|
1037 |
|
1038 int nr = m.rows (); |
|
1039 int nc = m.columns (); |
|
1040 |
|
1041 if (nr == 1) |
|
1042 { |
|
1043 retval.resize (nc); |
|
1044 for (int i = 0; i < nc; i++) |
|
1045 retval (i) = m (0, i); |
|
1046 } |
|
1047 else |
|
1048 { |
3523
|
1049 std::string tn = type_name (); |
3419
|
1050 gripe_invalid_conversion (tn.c_str (), "complex row vector"); |
|
1051 } |
|
1052 |
|
1053 return retval; |
|
1054 } |
|
1055 |
|
1056 // Sloppy... |
|
1057 |
|
1058 Array<double> |
2376
|
1059 octave_value::vector_value (bool force_string_conv, |
|
1060 bool force_vector_conversion) const |
|
1061 { |
3419
|
1062 Array<double> retval; |
2376
|
1063 |
|
1064 Matrix m = matrix_value (force_string_conv); |
|
1065 |
|
1066 if (error_state) |
|
1067 return retval; |
|
1068 |
|
1069 int nr = m.rows (); |
|
1070 int nc = m.columns (); |
|
1071 |
|
1072 if (nr == 1) |
|
1073 { |
|
1074 retval.resize (nc); |
|
1075 for (int i = 0; i < nc; i++) |
|
1076 retval (i) = m (0, i); |
|
1077 } |
|
1078 else if (nc == 1) |
|
1079 { |
|
1080 retval.resize (nr); |
|
1081 for (int i = 0; i < nr; i++) |
|
1082 retval (i) = m (i, 0); |
|
1083 } |
4455
|
1084 else if (nr > 0 && nc > 0) |
2376
|
1085 { |
4455
|
1086 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1087 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1088 gripe_implicit_conversion (type_name (), "real vector"); |
|
1089 |
2376
|
1090 retval.resize (nr * nc); |
|
1091 int k = 0; |
|
1092 for (int j = 0; j < nc; j++) |
|
1093 for (int i = 0; i < nr; i++) |
4153
|
1094 { |
|
1095 OCTAVE_QUIT; |
|
1096 |
|
1097 retval (k++) = m (i, j); |
|
1098 } |
2376
|
1099 } |
|
1100 else |
|
1101 { |
3523
|
1102 std::string tn = type_name (); |
2376
|
1103 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1104 } |
|
1105 |
|
1106 return retval; |
|
1107 } |
|
1108 |
4044
|
1109 Array<int> |
|
1110 octave_value::int_vector_value (bool force_string_conv, bool require_int, |
|
1111 bool force_vector_conversion) const |
|
1112 { |
|
1113 Array<int> retval; |
|
1114 |
|
1115 Matrix m = matrix_value (force_string_conv); |
|
1116 |
|
1117 if (error_state) |
|
1118 return retval; |
|
1119 |
|
1120 int nr = m.rows (); |
|
1121 int nc = m.columns (); |
|
1122 |
|
1123 if (nr == 1) |
|
1124 { |
|
1125 retval.resize (nc); |
|
1126 for (int i = 0; i < nc; i++) |
|
1127 { |
4153
|
1128 OCTAVE_QUIT; |
|
1129 |
4044
|
1130 double d = m (0, i); |
|
1131 |
|
1132 if (require_int && D_NINT (d) != d) |
|
1133 { |
|
1134 error ("conversion to integer value failed"); |
|
1135 return retval; |
|
1136 } |
|
1137 |
|
1138 retval (i) = static_cast<int> (d); |
|
1139 } |
|
1140 } |
|
1141 else if (nc == 1) |
|
1142 { |
|
1143 retval.resize (nr); |
|
1144 for (int i = 0; i < nr; i++) |
|
1145 { |
4153
|
1146 OCTAVE_QUIT; |
|
1147 |
4044
|
1148 double d = m (i, 0); |
|
1149 |
|
1150 if (require_int && D_NINT (d) != d) |
|
1151 { |
|
1152 error ("conversion to integer value failed"); |
|
1153 return retval; |
|
1154 } |
|
1155 |
|
1156 retval (i) = static_cast<int> (d); |
|
1157 } |
|
1158 } |
4455
|
1159 else if (nr > 0 && nc > 0) |
4044
|
1160 { |
4455
|
1161 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1162 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1163 gripe_implicit_conversion (type_name (), "real vector"); |
|
1164 |
4044
|
1165 retval.resize (nr * nc); |
|
1166 int k = 0; |
|
1167 for (int j = 0; j < nc; j++) |
|
1168 { |
|
1169 for (int i = 0; i < nr; i++) |
|
1170 { |
4153
|
1171 OCTAVE_QUIT; |
|
1172 |
4044
|
1173 double d = m (i, j); |
|
1174 |
|
1175 if (require_int && D_NINT (d) != d) |
|
1176 { |
|
1177 error ("conversion to integer value failed"); |
|
1178 return retval; |
|
1179 } |
|
1180 |
|
1181 retval (k++) = static_cast<int> (d); |
|
1182 } |
|
1183 } |
|
1184 } |
|
1185 else |
|
1186 { |
|
1187 std::string tn = type_name (); |
|
1188 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1189 } |
|
1190 |
|
1191 return retval; |
|
1192 } |
|
1193 |
3419
|
1194 Array<Complex> |
2376
|
1195 octave_value::complex_vector_value (bool force_string_conv, |
|
1196 bool force_vector_conversion) const |
|
1197 { |
3419
|
1198 Array<Complex> retval; |
2376
|
1199 |
|
1200 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1201 |
|
1202 if (error_state) |
|
1203 return retval; |
|
1204 |
|
1205 int nr = m.rows (); |
|
1206 int nc = m.columns (); |
|
1207 |
|
1208 if (nr == 1) |
|
1209 { |
|
1210 retval.resize (nc); |
|
1211 for (int i = 0; i < nc; i++) |
4153
|
1212 { |
|
1213 OCTAVE_QUIT; |
|
1214 retval (i) = m (0, i); |
|
1215 } |
2376
|
1216 } |
|
1217 else if (nc == 1) |
|
1218 { |
|
1219 retval.resize (nr); |
|
1220 for (int i = 0; i < nr; i++) |
4153
|
1221 { |
|
1222 OCTAVE_QUIT; |
|
1223 retval (i) = m (i, 0); |
|
1224 } |
2376
|
1225 } |
4455
|
1226 else if (nr > 0 && nc > 0) |
2376
|
1227 { |
4455
|
1228 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1229 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1230 gripe_implicit_conversion (type_name (), "complex vector"); |
|
1231 |
2376
|
1232 retval.resize (nr * nc); |
|
1233 int k = 0; |
|
1234 for (int j = 0; j < nc; j++) |
|
1235 for (int i = 0; i < nr; i++) |
4153
|
1236 { |
|
1237 OCTAVE_QUIT; |
|
1238 retval (k++) = m (i, j); |
|
1239 } |
2376
|
1240 } |
|
1241 else |
|
1242 { |
3523
|
1243 std::string tn = type_name (); |
2376
|
1244 gripe_invalid_conversion (tn.c_str (), "complex vector"); |
|
1245 } |
|
1246 |
|
1247 return retval; |
|
1248 } |
|
1249 |
4452
|
1250 octave_value |
4457
|
1251 octave_value::convert_to_str (bool pad, bool force) const |
4452
|
1252 { |
4457
|
1253 octave_value retval = convert_to_str_internal (pad, force); |
4452
|
1254 |
4457
|
1255 if (! force && is_numeric_type () && Vwarn_num_to_str) |
4452
|
1256 gripe_implicit_conversion (type_name (), retval.type_name ()); |
|
1257 |
|
1258 return retval; |
|
1259 } |
|
1260 |
2376
|
1261 void |
4005
|
1262 octave_value::print_with_name (std::ostream& output_buf, |
|
1263 const std::string& name, |
2903
|
1264 bool print_padding) const |
2376
|
1265 { |
4005
|
1266 if (! (evaluating_function_body && Vsilent_functions)) |
|
1267 { |
|
1268 bool pad_after = print_name_tag (output_buf, name); |
2376
|
1269 |
4005
|
1270 print (output_buf); |
2376
|
1271 |
4005
|
1272 if (print_padding && pad_after) |
|
1273 newline (output_buf); |
|
1274 } |
2376
|
1275 } |
|
1276 |
|
1277 static void |
3523
|
1278 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) |
2413
|
1279 { |
2903
|
1280 error ("assignment of `%s' to indexed `%s' not implemented", |
2413
|
1281 tn2.c_str (), tn1.c_str ()); |
|
1282 } |
|
1283 |
|
1284 static void |
3933
|
1285 gripe_assign_conversion_failed (const std::string& tn1, |
|
1286 const std::string& tn2) |
2413
|
1287 { |
2903
|
1288 error ("type conversion for assignment of `%s' to indexed `%s' failed", |
2413
|
1289 tn2.c_str (), tn1.c_str ()); |
|
1290 } |
|
1291 |
3933
|
1292 octave_value |
4247
|
1293 octave_value::numeric_assign (const std::string& type, |
4219
|
1294 const std::list<octave_value_list>& idx, |
2413
|
1295 const octave_value& rhs) |
|
1296 { |
3933
|
1297 octave_value retval; |
2413
|
1298 |
|
1299 int t_lhs = type_id (); |
|
1300 int t_rhs = rhs.type_id (); |
|
1301 |
2880
|
1302 assign_op_fcn f |
3933
|
1303 = octave_value_typeinfo::lookup_assign_op (op_asn_eq, t_lhs, t_rhs); |
|
1304 |
|
1305 bool done = false; |
2413
|
1306 |
|
1307 if (f) |
|
1308 { |
3933
|
1309 f (*this, idx.front (), rhs.get_rep ()); |
2413
|
1310 |
3933
|
1311 done = (! error_state); |
2413
|
1312 } |
3933
|
1313 |
|
1314 if (done) |
|
1315 retval = octave_value (this, count + 1); |
3196
|
1316 else |
|
1317 { |
3933
|
1318 int t_result |
|
1319 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); |
|
1320 |
|
1321 if (t_result >= 0) |
|
1322 { |
|
1323 type_conv_fcn cf |
|
1324 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); |
|
1325 |
|
1326 if (cf) |
|
1327 { |
|
1328 octave_value *tmp (cf (*this)); |
3196
|
1329 |
3933
|
1330 if (tmp) |
|
1331 { |
|
1332 retval = tmp->subsasgn (type, idx, rhs); |
|
1333 |
4505
|
1334 // The assignment may have converted to a type that |
|
1335 // is wider than necessary. |
|
1336 |
|
1337 retval.maybe_mutate (); |
|
1338 |
3933
|
1339 done = (! error_state); |
|
1340 } |
|
1341 else |
|
1342 gripe_assign_conversion_failed (type_name (), |
|
1343 rhs.type_name ()); |
|
1344 } |
|
1345 else |
|
1346 gripe_indexed_assignment (type_name (), rhs.type_name ()); |
|
1347 } |
|
1348 |
|
1349 if (! (done || error_state)) |
3196
|
1350 { |
3933
|
1351 octave_value tmp_rhs; |
|
1352 type_conv_fcn cf_rhs = rhs.numeric_conversion_function (); |
|
1353 |
|
1354 if (cf_rhs) |
|
1355 { |
|
1356 octave_value *tmp = cf_rhs (rhs.get_rep ()); |
|
1357 |
|
1358 if (tmp) |
|
1359 tmp_rhs = octave_value (tmp); |
|
1360 else |
|
1361 { |
|
1362 gripe_assign_conversion_failed (type_name (), |
|
1363 rhs.type_name ()); |
|
1364 return octave_value (); |
|
1365 } |
|
1366 } |
|
1367 else |
|
1368 tmp_rhs = rhs; |
|
1369 |
|
1370 type_conv_fcn cf_this = numeric_conversion_function (); |
|
1371 |
|
1372 octave_value *tmp_lhs = this; |
3196
|
1373 |
3933
|
1374 if (cf_this) |
|
1375 { |
|
1376 octave_value *tmp = cf_this (*this); |
|
1377 |
|
1378 if (tmp) |
|
1379 tmp_lhs = tmp; |
|
1380 else |
|
1381 { |
|
1382 gripe_assign_conversion_failed (type_name (), |
|
1383 rhs.type_name ()); |
|
1384 return octave_value (); |
|
1385 } |
|
1386 } |
|
1387 |
|
1388 if (cf_this || cf_rhs) |
|
1389 { |
|
1390 retval = tmp_lhs->subsasgn (type, idx, tmp_rhs); |
|
1391 |
|
1392 done = (! error_state); |
|
1393 } |
|
1394 else |
|
1395 gripe_no_conversion (assign_op_as_string (op_asn_eq), |
|
1396 type_name (), rhs.type_name ()); |
3196
|
1397 } |
|
1398 } |
2413
|
1399 |
|
1400 return retval; |
|
1401 } |
|
1402 |
|
1403 static void |
3933
|
1404 gripe_binary_op (const std::string& on, const std::string& tn1, |
|
1405 const std::string& tn2) |
2376
|
1406 { |
2903
|
1407 error ("binary operator `%s' not implemented for `%s' by `%s' operations", |
2376
|
1408 on.c_str (), tn1.c_str (), tn2.c_str ()); |
|
1409 } |
|
1410 |
3203
|
1411 static void |
3523
|
1412 gripe_binary_op_conv (const std::string& on) |
3203
|
1413 { |
|
1414 error ("type conversion failed for binary operator `%s'", on.c_str ()); |
|
1415 } |
|
1416 |
2376
|
1417 octave_value |
3933
|
1418 do_binary_op (octave_value::binary_op op, |
|
1419 const octave_value& v1, const octave_value& v2) |
2376
|
1420 { |
|
1421 octave_value retval; |
|
1422 |
|
1423 int t1 = v1.type_id (); |
|
1424 int t2 = v2.type_id (); |
|
1425 |
2427
|
1426 binary_op_fcn f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1427 |
|
1428 if (f) |
|
1429 retval = f (*v1.rep, *v2.rep); |
|
1430 else |
|
1431 { |
|
1432 octave_value tv1; |
2427
|
1433 type_conv_fcn cf1 = v1.numeric_conversion_function (); |
2376
|
1434 |
|
1435 if (cf1) |
|
1436 { |
3203
|
1437 octave_value *tmp = cf1 (*v1.rep); |
|
1438 |
|
1439 if (tmp) |
|
1440 { |
|
1441 tv1 = octave_value (tmp); |
|
1442 t1 = tv1.type_id (); |
|
1443 } |
|
1444 else |
|
1445 { |
|
1446 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1447 return retval; |
|
1448 } |
2376
|
1449 } |
|
1450 else |
|
1451 tv1 = v1; |
|
1452 |
|
1453 octave_value tv2; |
2427
|
1454 type_conv_fcn cf2 = v2.numeric_conversion_function (); |
2376
|
1455 |
|
1456 if (cf2) |
|
1457 { |
3203
|
1458 octave_value *tmp = cf2 (*v2.rep); |
|
1459 |
|
1460 if (tmp) |
|
1461 { |
|
1462 tv2 = octave_value (tmp); |
|
1463 t2 = tv2.type_id (); |
|
1464 } |
|
1465 else |
|
1466 { |
|
1467 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1468 return retval; |
|
1469 } |
2376
|
1470 } |
|
1471 else |
|
1472 tv2 = v2; |
|
1473 |
|
1474 if (cf1 || cf2) |
|
1475 { |
2427
|
1476 binary_op_fcn f |
2376
|
1477 = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
|
1478 |
|
1479 if (f) |
|
1480 retval = f (*tv1.rep, *tv2.rep); |
|
1481 else |
|
1482 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1483 v1.type_name (), v2.type_name ()); |
|
1484 } |
|
1485 else |
|
1486 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1487 v1.type_name (), v2.type_name ()); |
|
1488 } |
|
1489 |
|
1490 return retval; |
|
1491 } |
|
1492 |
3933
|
1493 void |
|
1494 octave_value::print_info (std::ostream& os, const std::string& prefix) const |
|
1495 { |
|
1496 os << prefix << "type_name: " << type_name () << "\n" |
|
1497 << prefix << "count: " << get_count () << "\n" |
|
1498 << prefix << "rep info: "; |
|
1499 |
|
1500 rep->print_info (os, prefix + " "); |
|
1501 } |
|
1502 |
3203
|
1503 static void |
3523
|
1504 gripe_unary_op (const std::string& on, const std::string& tn) |
3203
|
1505 { |
|
1506 error ("unary operator `%s' not implemented for `%s' operands", |
|
1507 on.c_str (), tn.c_str ()); |
|
1508 } |
|
1509 |
|
1510 static void |
3523
|
1511 gripe_unary_op_conv (const std::string& on) |
3203
|
1512 { |
|
1513 error ("type conversion failed for unary operator `%s'", on.c_str ()); |
|
1514 } |
|
1515 |
|
1516 octave_value |
|
1517 do_unary_op (octave_value::unary_op op, const octave_value& v) |
|
1518 { |
|
1519 octave_value retval; |
|
1520 |
|
1521 int t = v.type_id (); |
|
1522 |
|
1523 unary_op_fcn f = octave_value_typeinfo::lookup_unary_op (op, t); |
|
1524 |
|
1525 if (f) |
|
1526 retval = f (*v.rep); |
|
1527 else |
|
1528 { |
|
1529 octave_value tv; |
|
1530 type_conv_fcn cf = v.numeric_conversion_function (); |
|
1531 |
|
1532 if (cf) |
|
1533 { |
|
1534 octave_value *tmp = cf (*v.rep); |
|
1535 |
|
1536 if (tmp) |
|
1537 { |
|
1538 tv = octave_value (tmp); |
|
1539 t = tv.type_id (); |
|
1540 |
|
1541 unary_op_fcn f = octave_value_typeinfo::lookup_unary_op (op, t); |
|
1542 |
|
1543 if (f) |
|
1544 retval = f (*tv.rep); |
|
1545 else |
|
1546 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1547 v.type_name ()); |
|
1548 } |
|
1549 else |
|
1550 gripe_unary_op_conv (octave_value::unary_op_as_string (op)); |
|
1551 } |
|
1552 else |
|
1553 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1554 v.type_name ()); |
|
1555 } |
|
1556 |
|
1557 return retval; |
|
1558 } |
|
1559 |
|
1560 static void |
3933
|
1561 gripe_unary_op_conversion_failed (const std::string& op, |
|
1562 const std::string& tn) |
3203
|
1563 { |
|
1564 error ("operator %s: type conversion for `%s' failed", |
|
1565 op.c_str (), tn.c_str ()); |
|
1566 } |
|
1567 |
3933
|
1568 const octave_value& |
|
1569 octave_value::do_non_const_unary_op (unary_op op) |
3203
|
1570 { |
|
1571 octave_value retval; |
|
1572 |
|
1573 int t = type_id (); |
|
1574 |
|
1575 non_const_unary_op_fcn f |
|
1576 = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1577 |
|
1578 if (f) |
|
1579 { |
|
1580 make_unique (); |
|
1581 |
|
1582 f (*rep); |
|
1583 } |
|
1584 else |
|
1585 { |
|
1586 type_conv_fcn cf = numeric_conversion_function (); |
|
1587 |
|
1588 if (cf) |
|
1589 { |
|
1590 octave_value *tmp = cf (*rep); |
|
1591 |
|
1592 if (tmp) |
|
1593 { |
|
1594 octave_value *old_rep = rep; |
|
1595 rep = tmp; |
|
1596 rep->count = 1; |
|
1597 |
|
1598 t = type_id (); |
|
1599 |
|
1600 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1601 |
|
1602 if (f) |
|
1603 { |
|
1604 f (*rep); |
|
1605 |
|
1606 if (old_rep && --old_rep->count == 0) |
|
1607 delete old_rep; |
|
1608 } |
|
1609 else |
|
1610 { |
|
1611 if (old_rep) |
|
1612 { |
|
1613 if (--rep->count == 0) |
|
1614 delete rep; |
|
1615 |
|
1616 rep = old_rep; |
|
1617 } |
|
1618 |
|
1619 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1620 type_name ()); |
|
1621 } |
|
1622 } |
|
1623 else |
|
1624 gripe_unary_op_conversion_failed |
|
1625 (octave_value::unary_op_as_string (op), type_name ()); |
|
1626 } |
|
1627 else |
|
1628 gripe_unary_op (octave_value::unary_op_as_string (op), type_name ()); |
|
1629 } |
3933
|
1630 |
|
1631 return *this; |
3203
|
1632 } |
|
1633 |
3933
|
1634 #if 0 |
3205
|
1635 static void |
3933
|
1636 gripe_unary_op_failed_or_no_method (const std::string& on, |
|
1637 const std::string& tn) |
3205
|
1638 { |
|
1639 error ("operator %s: no method, or unable to evaluate for %s operand", |
|
1640 on.c_str (), tn.c_str ()); |
|
1641 } |
3933
|
1642 #endif |
3205
|
1643 |
|
1644 void |
3933
|
1645 octave_value::do_non_const_unary_op (unary_op op, const octave_value_list& idx) |
3205
|
1646 { |
3933
|
1647 abort (); |
|
1648 } |
|
1649 |
|
1650 octave_value |
4247
|
1651 octave_value::do_non_const_unary_op (unary_op op, const std::string& type, |
4219
|
1652 const std::list<octave_value_list>& idx) |
3933
|
1653 { |
|
1654 octave_value retval; |
|
1655 |
|
1656 if (idx.empty ()) |
|
1657 { |
|
1658 do_non_const_unary_op (op); |
3205
|
1659 |
3933
|
1660 retval = *this; |
|
1661 } |
|
1662 else |
|
1663 { |
|
1664 // XXX FIXME XXX -- only do the following stuff if we can't find a |
|
1665 // specific function to call to handle the op= operation for the |
|
1666 // types we have. |
3205
|
1667 |
3933
|
1668 assign_op assop = unary_op_to_assign_op (op); |
|
1669 |
|
1670 retval = assign (assop, type, idx, 1.0); |
|
1671 } |
|
1672 |
|
1673 return retval; |
3205
|
1674 } |
|
1675 |
2903
|
1676 // Current indentation. |
|
1677 int octave_value::curr_print_indent_level = 0; |
|
1678 |
3018
|
1679 // TRUE means we are at the beginning of a line. |
2903
|
1680 bool octave_value::beginning_of_line = true; |
|
1681 |
|
1682 // Each print() function should call this before printing anything. |
|
1683 // |
|
1684 // This doesn't need to be fast, but isn't there a better way? |
|
1685 |
|
1686 void |
3523
|
1687 octave_value::indent (std::ostream& os) const |
2903
|
1688 { |
|
1689 assert (curr_print_indent_level >= 0); |
|
1690 |
|
1691 if (beginning_of_line) |
|
1692 { |
|
1693 // XXX FIXME XXX -- do we need this? |
|
1694 // os << prefix; |
|
1695 |
|
1696 for (int i = 0; i < curr_print_indent_level; i++) |
|
1697 os << " "; |
|
1698 |
|
1699 beginning_of_line = false; |
|
1700 } |
|
1701 } |
|
1702 |
|
1703 // All print() functions should use this to print new lines. |
|
1704 |
|
1705 void |
3523
|
1706 octave_value::newline (std::ostream& os) const |
2903
|
1707 { |
|
1708 os << "\n"; |
|
1709 |
|
1710 beginning_of_line = true; |
|
1711 } |
|
1712 |
|
1713 // For ressetting print state. |
|
1714 |
|
1715 void |
|
1716 octave_value::reset (void) const |
|
1717 { |
|
1718 beginning_of_line = true; |
|
1719 curr_print_indent_level = 0; |
|
1720 } |
|
1721 |
3205
|
1722 octave_value::assign_op |
|
1723 octave_value::unary_op_to_assign_op (unary_op op) |
|
1724 { |
|
1725 assign_op binop = unknown_assign_op; |
|
1726 |
|
1727 switch (op) |
|
1728 { |
3533
|
1729 case op_incr: |
|
1730 binop = op_add_eq; |
3205
|
1731 break; |
|
1732 |
3533
|
1733 case op_decr: |
|
1734 binop = op_sub_eq; |
3205
|
1735 break; |
|
1736 |
|
1737 default: |
|
1738 { |
3523
|
1739 std::string on = unary_op_as_string (op); |
3205
|
1740 error ("operator %s: no assign operator found", on.c_str ()); |
|
1741 } |
|
1742 } |
|
1743 |
|
1744 return binop; |
|
1745 } |
|
1746 |
3204
|
1747 octave_value::binary_op |
|
1748 octave_value::op_eq_to_binary_op (assign_op op) |
|
1749 { |
|
1750 binary_op binop = unknown_binary_op; |
|
1751 |
|
1752 switch (op) |
|
1753 { |
3533
|
1754 case op_add_eq: |
|
1755 binop = op_add; |
3204
|
1756 break; |
|
1757 |
3533
|
1758 case op_sub_eq: |
|
1759 binop = op_sub; |
3204
|
1760 break; |
|
1761 |
3533
|
1762 case op_mul_eq: |
|
1763 binop = op_mul; |
3204
|
1764 break; |
|
1765 |
3533
|
1766 case op_div_eq: |
|
1767 binop = op_div; |
3204
|
1768 break; |
|
1769 |
3533
|
1770 case op_ldiv_eq: |
|
1771 binop = op_ldiv; |
3204
|
1772 break; |
|
1773 |
4018
|
1774 case op_pow_eq: |
|
1775 binop = op_pow; |
|
1776 break; |
|
1777 |
3533
|
1778 case op_lshift_eq: |
|
1779 binop = op_lshift; |
3204
|
1780 break; |
|
1781 |
3533
|
1782 case op_rshift_eq: |
|
1783 binop = op_rshift; |
3204
|
1784 break; |
|
1785 |
3533
|
1786 case op_el_mul_eq: |
|
1787 binop = op_el_mul; |
3204
|
1788 break; |
|
1789 |
3533
|
1790 case op_el_div_eq: |
|
1791 binop = op_el_div; |
3204
|
1792 break; |
|
1793 |
3533
|
1794 case op_el_ldiv_eq: |
|
1795 binop = op_el_ldiv; |
3204
|
1796 break; |
|
1797 |
4018
|
1798 case op_el_pow_eq: |
|
1799 binop = op_el_pow; |
|
1800 break; |
|
1801 |
3533
|
1802 case op_el_and_eq: |
|
1803 binop = op_el_and; |
3204
|
1804 break; |
|
1805 |
3533
|
1806 case op_el_or_eq: |
|
1807 binop = op_el_or; |
3204
|
1808 break; |
|
1809 |
|
1810 default: |
|
1811 { |
3523
|
1812 std::string on = assign_op_as_string (op); |
3204
|
1813 error ("operator %s: no binary operator found", on.c_str ()); |
|
1814 } |
|
1815 } |
|
1816 |
|
1817 return binop; |
|
1818 } |
|
1819 |
3933
|
1820 octave_value |
|
1821 octave_value::empty_conv (const std::string& type, const octave_value& rhs) |
|
1822 { |
|
1823 octave_value retval; |
|
1824 |
|
1825 if (type.length () > 0) |
|
1826 { |
|
1827 switch (type[0]) |
|
1828 { |
|
1829 case '(': |
|
1830 { |
|
1831 if (type.length () > 1 && type[1] == '.') |
|
1832 retval = Octave_map (); |
|
1833 else |
|
1834 retval = octave_value (rhs.empty_clone ()); |
|
1835 } |
|
1836 break; |
|
1837 |
|
1838 case '{': |
|
1839 retval = Cell (); |
|
1840 break; |
|
1841 |
|
1842 case '.': |
|
1843 retval = Octave_map (); |
|
1844 break; |
|
1845 |
|
1846 default: |
|
1847 panic_impossible (); |
|
1848 } |
|
1849 } |
|
1850 else |
|
1851 retval = octave_value (rhs.empty_clone ()); |
|
1852 |
|
1853 return retval; |
|
1854 } |
|
1855 |
2376
|
1856 void |
|
1857 install_types (void) |
|
1858 { |
|
1859 octave_base_value::register_type (); |
3928
|
1860 octave_cell::register_type (); |
2376
|
1861 octave_scalar::register_type (); |
|
1862 octave_complex::register_type (); |
|
1863 octave_matrix::register_type (); |
|
1864 octave_complex_matrix::register_type (); |
|
1865 octave_range::register_type (); |
2825
|
1866 octave_bool::register_type (); |
|
1867 octave_bool_matrix::register_type (); |
2376
|
1868 octave_char_matrix::register_type (); |
|
1869 octave_char_matrix_str::register_type (); |
|
1870 octave_struct::register_type (); |
2903
|
1871 octave_file::register_type (); |
2880
|
1872 octave_list::register_type (); |
3977
|
1873 octave_cs_list::register_type (); |
2376
|
1874 octave_all_va_args::register_type (); |
|
1875 octave_magic_colon::register_type (); |
2974
|
1876 octave_builtin::register_type (); |
|
1877 octave_mapper::register_type (); |
|
1878 octave_user_function::register_type (); |
2376
|
1879 } |
|
1880 |
|
1881 static int |
4455
|
1882 warn_fortran_indexing (void) |
2376
|
1883 { |
4455
|
1884 Vwarn_fortran_indexing = check_preference ("warn_fortran_indexing"); |
2376
|
1885 |
4455
|
1886 liboctave_wfi_flag = Vwarn_fortran_indexing; |
2376
|
1887 |
|
1888 return 0; |
|
1889 } |
|
1890 |
|
1891 static int |
4452
|
1892 warn_imag_to_real (void) |
4257
|
1893 { |
4452
|
1894 Vwarn_imag_to_real = check_preference ("warn_imag_to_real"); |
4257
|
1895 |
|
1896 return 0; |
|
1897 } |
|
1898 |
|
1899 static int |
4452
|
1900 warn_num_to_str (void) |
2376
|
1901 { |
4452
|
1902 Vwarn_num_to_str = check_preference ("warn_num_to_str"); |
2376
|
1903 |
|
1904 return 0; |
|
1905 } |
|
1906 |
|
1907 static int |
4452
|
1908 warn_str_to_num (void) |
2376
|
1909 { |
4452
|
1910 Vwarn_str_to_num = check_preference ("warn_str_to_num"); |
2376
|
1911 |
|
1912 return 0; |
|
1913 } |
|
1914 |
|
1915 static int |
|
1916 print_answer_id_name (void) |
|
1917 { |
|
1918 Vprint_answer_id_name = check_preference ("print_answer_id_name"); |
|
1919 |
|
1920 return 0; |
|
1921 } |
|
1922 |
|
1923 static int |
4461
|
1924 warn_resize_on_range_error (void) |
2376
|
1925 { |
4461
|
1926 Vwarn_resize_on_range_error |
|
1927 = check_preference ("warn_resize_on_range_error"); |
2376
|
1928 |
4461
|
1929 liboctave_wrore_flag = Vwarn_resize_on_range_error; |
2376
|
1930 |
|
1931 return 0; |
|
1932 } |
|
1933 |
|
1934 static int |
4005
|
1935 silent_functions (void) |
|
1936 { |
|
1937 Vsilent_functions = check_preference ("silent_functions"); |
|
1938 |
|
1939 return 0; |
|
1940 } |
|
1941 |
|
1942 static int |
2376
|
1943 struct_levels_to_print (void) |
|
1944 { |
|
1945 double val; |
|
1946 if (builtin_real_scalar_variable ("struct_levels_to_print", val) |
|
1947 && ! xisnan (val)) |
|
1948 { |
|
1949 int ival = NINT (val); |
3961
|
1950 if (ival == val) |
2376
|
1951 { |
|
1952 Vstruct_levels_to_print = ival; |
|
1953 return 0; |
|
1954 } |
|
1955 } |
|
1956 gripe_invalid_value_specified ("struct_levels_to_print"); |
|
1957 return -1; |
|
1958 } |
|
1959 |
|
1960 static int |
|
1961 warn_divide_by_zero (void) |
|
1962 { |
|
1963 Vwarn_divide_by_zero = check_preference ("warn_divide_by_zero"); |
|
1964 |
|
1965 return 0; |
|
1966 } |
|
1967 |
|
1968 void |
2909
|
1969 symbols_of_ov (void) |
2376
|
1970 { |
4233
|
1971 DEFVAR (print_answer_id_name, true, print_answer_id_name, |
3372
|
1972 "-*- texinfo -*-\n\ |
|
1973 @defvr {Built-in Variable} print_answer_id_name\n\ |
|
1974 If the value of @code{print_answer_id_name} is nonzero, variable\n\ |
|
1975 names are printed along with the result. Otherwise, only the result\n\ |
|
1976 values are printed. The default value is 1.\n\ |
|
1977 @end defvr"); |
2376
|
1978 |
4233
|
1979 DEFVAR (silent_functions, false, silent_functions, |
4005
|
1980 "-*- texinfo -*-\n\ |
|
1981 @defvr {Built-in Variable} silent_functions\n\ |
|
1982 If the value of @code{silent_functions} is nonzero, internal output\n\ |
|
1983 from a function is suppressed. Otherwise, the results of expressions\n\ |
|
1984 within a function body that are not terminated with a semicolon will\n\ |
|
1985 have their values printed. The default value is 0.\n\ |
|
1986 \n\ |
|
1987 For example, if the function\n\ |
|
1988 \n\ |
|
1989 @example\n\ |
|
1990 function f ()\n\ |
|
1991 2 + 2\n\ |
|
1992 endfunction\n\ |
|
1993 @end example\n\ |
|
1994 \n\ |
|
1995 @noindent\n\ |
|
1996 is executed, Octave will either print @samp{ans = 4} or nothing\n\ |
|
1997 depending on the value of @code{silent_functions}.\n\ |
|
1998 @end defvr"); |
|
1999 |
3258
|
2000 DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print, |
3361
|
2001 "-*- texinfo -*-\n\ |
|
2002 @defvr {Built-in Variable} struct_levels_to_print\n\ |
|
2003 You can tell Octave how many structure levels to display by setting the\n\ |
|
2004 built-in variable @code{struct_levels_to_print}. The default value is 2.\n\ |
3363
|
2005 @end defvr"); |
2376
|
2006 |
4233
|
2007 DEFVAR (warn_divide_by_zero, true, warn_divide_by_zero, |
3371
|
2008 "-*- texinfo -*-\n\ |
|
2009 @defvr {Built-in Variable} warn_divide_by_zero\n\ |
|
2010 If the value of @code{warn_divide_by_zero} is nonzero, a warning\n\ |
|
2011 is issued when Octave encounters a division by zero. If the value is\n\ |
|
2012 0, the warning is omitted. The default value is 1.\n\ |
|
2013 @end defvr"); |
4451
|
2014 |
4455
|
2015 DEFVAR (warn_fortran_indexing, false, warn_fortran_indexing, |
|
2016 "-*- texinfo -*-\n\ |
|
2017 @defvr {Built-in Variable} warn_fortran_indexing\n\ |
|
2018 If the value of @code{warn_fortran_indexing} is nonzero, a warning is\n\ |
|
2019 printed for expressions which select elements of a two-dimensional matrix\n\ |
|
2020 using a single index. The default value is 0.\n\ |
|
2021 @end defvr"); |
|
2022 |
4451
|
2023 DEFVAR (warn_imag_to_real, false, warn_imag_to_real, |
|
2024 "-*- texinfo -*-\n\ |
|
2025 @defvr {Built-in Variable} warn_imag_to_real\n\ |
|
2026 If the value of @code{warn_imag_to_real} is nonzero, a warning is\n\ |
|
2027 printed for implicit conversions of complex numbers to real numbers.\n\ |
|
2028 The default value is 0.\n\ |
|
2029 @end defvr"); |
4452
|
2030 |
|
2031 DEFVAR (warn_num_to_str, true, warn_num_to_str, |
|
2032 "-*- texinfo -*-\n\ |
|
2033 @defvr {Built-in Variable} warn_num_to_str\n\ |
|
2034 If the value of @code{warn_num_to_str} is nonzero, a warning is\n\ |
|
2035 printed for implicit conversions of numbers to their ASCII character\n\ |
|
2036 equivalents when strings are constructed using a mixture of strings and\n\ |
|
2037 numbers in matrix notation. For example,\n\ |
|
2038 \n\ |
|
2039 @example\n\ |
|
2040 @group\n\ |
|
2041 [ \"f\", 111, 111 ]\n\ |
|
2042 @result{} \"foo\"\n\ |
|
2043 @end group\n\ |
|
2044 @end example\n\ |
|
2045 elicits a warning if @code{warn_num_to_str} is nonzero. The default\n\ |
|
2046 value is 1.\n\ |
|
2047 @end defvr"); |
|
2048 |
4461
|
2049 DEFVAR (warn_resize_on_range_error, false, warn_resize_on_range_error, |
|
2050 "-*- texinfo -*-\n\ |
|
2051 @defvr {Built-in Variable} warn_resize_on_range_error\n\ |
|
2052 If the value of @code{warn_resize_on_range_error} is nonzero, print a\n\ |
|
2053 warning when a matrix is resized by an indexed assignment with\n\ |
|
2054 indices outside the current bounds. The default value is 0.\n\ |
|
2055 @end defvr"); |
|
2056 |
4452
|
2057 DEFVAR (warn_str_to_num, false, warn_str_to_num, |
|
2058 "-*- texinfo -*-\n\ |
|
2059 @defvr {Built-in Variable} warn_str_to_num\n\ |
|
2060 If the value of @code{warn_str_to_num} is nonzero, a warning is printed\n\ |
|
2061 for implicit conversions of strings to their numeric ASCII equivalents.\n\ |
|
2062 For example,\n\ |
|
2063 @example\n\ |
|
2064 @group\n\ |
|
2065 \"abc\" + 0\n\ |
|
2066 @result{} 97 98 99\n\ |
|
2067 @end group\n\ |
|
2068 @end example\n\ |
|
2069 elicits a warning if @code{warn_str_to_num} is nonzero. The default\n\ |
|
2070 value is 0.\n\ |
|
2071 @end defvr"); |
2376
|
2072 } |
|
2073 |
|
2074 /* |
|
2075 ;;; Local Variables: *** |
|
2076 ;;; mode: C++ *** |
|
2077 ;;; End: *** |
|
2078 */ |