Mercurial > octave-nkf
comparison libinterp/octave-value/ov-base-sparse.cc @ 18196:0d5721873d6b
avoid some tests that rely on ordering of enum values
* ov-base-sparse.cc (octave_base_sparse<T>::map): Use explicit list of
umap_X cases instead of relying on specific ordering of enum values.
* ov-float.cc (octave_float_scalar::map): Likewise.
* ov-flt-re-mat.cc (octave_float_matrix::map): Likewise.
* ov-re-mat.cc (octave_matrix::map): Likewise.
* ov-scalar.cc (octave_scalar::map): Likewise.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 02 Jan 2014 23:18:45 -0500 |
parents | 1b6db9303933 |
children | b7d3e1f762e1 |
comparison
equal
deleted
inserted
replaced
18195:1b6db9303933 | 18196:0d5721873d6b |
---|---|
448 // cases that are expected to return sparse matrices. | 448 // cases that are expected to return sparse matrices. |
449 octave_value retval = this->full_value ().map (umap); | 449 octave_value retval = this->full_value ().map (umap); |
450 | 450 |
451 // Sparsify the result if possible. | 451 // Sparsify the result if possible. |
452 | 452 |
453 // FIXME: intentionally skip this step for string mappers. Is this wanted? | 453 switch (umap) |
454 // FIXME: this will break if some well-meaning person rearranges the | 454 { |
455 // enum list in ov-base.h. | 455 case umap_xisalnum: |
456 if (umap >= umap_xisalnum && umap <= umap_xtoupper) | 456 case umap_xisalpha: |
457 return retval; | 457 case umap_xisascii: |
458 | 458 case umap_xiscntrl: |
459 switch (retval.builtin_type ()) | 459 case umap_xisdigit: |
460 { | 460 case umap_xisgraph: |
461 case btyp_double: | 461 case umap_xislower: |
462 retval = retval.sparse_matrix_value (); | 462 case umap_xisprint: |
463 break; | 463 case umap_xispunct: |
464 case btyp_complex: | 464 case umap_xisspace: |
465 retval = retval.sparse_complex_matrix_value (); | 465 case umap_xisupper: |
466 break; | 466 case umap_xisxdigit: |
467 case btyp_bool: | 467 case umap_xsignbit: |
468 retval = retval.sparse_bool_matrix_value (); | 468 case umap_xtoascii: |
469 break; | 469 // FIXME: intentionally skip this step for string mappers. |
470 default: | 470 // Is this wanted? |
471 break; | 471 break; |
472 | |
473 default: | |
474 { | |
475 switch (retval.builtin_type ()) | |
476 { | |
477 case btyp_double: | |
478 retval = retval.sparse_matrix_value (); | |
479 break; | |
480 | |
481 case btyp_complex: | |
482 retval = retval.sparse_complex_matrix_value (); | |
483 break; | |
484 | |
485 case btyp_bool: | |
486 retval = retval.sparse_bool_matrix_value (); | |
487 break; | |
488 | |
489 default: | |
490 break; | |
491 } | |
492 } | |
472 } | 493 } |
473 | 494 |
474 return retval; | 495 return retval; |
475 } | 496 } |