Mercurial > octave
changeset 20833:9c4c87679985
restructure calls to error
* op-bm-bm.cc, op-cell.cc, op-class.cc, op-cm-cm.cc, op-fcm-fcm.cc,
op-fm-fm.cc, op-m-m.cc, op-str-str.cc, op-struct.cc:
Restructure calls to error to avoid excess indentation.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 09 Dec 2015 14:32:04 -0500 |
parents | 3951d420556c |
children | 27b333c88c8e |
files | libinterp/operators/op-bm-bm.cc libinterp/operators/op-cell.cc libinterp/operators/op-class.cc libinterp/operators/op-cm-cm.cc libinterp/operators/op-fcm-fcm.cc libinterp/operators/op-fm-fm.cc libinterp/operators/op-m-m.cc libinterp/operators/op-str-str.cc libinterp/operators/op-struct.cc |
diffstat | 9 files changed, 60 insertions(+), 94 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/operators/op-bm-bm.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-bm-bm.cc Wed Dec 09 14:32:04 2015 -0500 @@ -61,12 +61,9 @@ CAST_UNOP_ARG (const octave_bool_matrix&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.bool_matrix_value ().transpose ()); + error ("transpose not defined for N-d objects"); + + return octave_value (v.bool_matrix_value ().transpose ()); } // bool matrix by bool matrix ops.
--- a/libinterp/operators/op-cell.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-cell.cc Wed Dec 09 14:32:04 2015 -0500 @@ -41,12 +41,9 @@ CAST_UNOP_ARG (const octave_cell&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (Cell (v.cell_value ().transpose ())); + error ("transpose not defined for N-d objects"); + + return octave_value (Cell (v.cell_value ().transpose ())); } DEFCATOP_FN (c_c, cell, cell, concat)
--- a/libinterp/operators/op-class.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-class.cc Wed Dec 09 14:32:04 2015 -0500 @@ -48,20 +48,18 @@ \ octave_value meth = symbol_table::find_method (#name, class_name); \ \ - if (meth.is_defined ()) \ - { \ - octave_value_list args; \ + if (meth.is_undefined ()) \ + error ("%s method not defined for %s class", #name, \ + class_name.c_str ()); \ \ - args(0) = a; \ + octave_value_list args; \ \ - octave_value_list tmp = feval (meth.function_value (), args, 1); \ + args(0) = a; \ \ - if (tmp.length () > 0) \ - retval = tmp(0); \ - } \ - else \ - error ("%s method not defined for %s class", \ - #name, class_name.c_str ()); \ + octave_value_list tmp = feval (meth.function_value (), args, 1); \ + \ + if (tmp.length () > 0) \ + retval = tmp(0); \ \ return retval; \ } @@ -85,21 +83,19 @@ \ octave_value meth = symbol_table::find_method (#name, dispatch_type); \ \ - if (meth.is_defined ()) \ - { \ - octave_value_list args; \ + if (meth.is_undefined ()) \ + error ("%s method not defined for %s class", #name, \ + dispatch_type.c_str ()); \ \ - args(1) = a2; \ - args(0) = a1; \ + octave_value_list args; \ \ - octave_value_list tmp = feval (meth.function_value (), args, 1); \ + args(1) = a2; \ + args(0) = a1; \ \ - if (tmp.length () > 0) \ - retval = tmp(0); \ - } \ - else \ - error ("%s method not defined for %s class", \ - #name, dispatch_type.c_str ()); \ + octave_value_list tmp = feval (meth.function_value (), args, 1); \ + \ + if (tmp.length () > 0) \ + retval = tmp(0); \ \ return retval; \ }
--- a/libinterp/operators/op-cm-cm.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-cm-cm.cc Wed Dec 09 14:32:04 2015 -0500 @@ -46,12 +46,9 @@ CAST_UNOP_ARG (const octave_complex_matrix&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.complex_matrix_value ().transpose ()); + error ("transpose not defined for N-d objects"); + + return octave_value (v.complex_matrix_value ().transpose ()); } DEFUNOP (hermitian, complex_matrix) @@ -59,12 +56,9 @@ CAST_UNOP_ARG (const octave_complex_matrix&); if (v.ndims () > 2) - { - error ("complex-conjugate transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.complex_matrix_value ().hermitian ()); + error ("complex-conjugate transpose not defined for N-d objects"); + + return octave_value (v.complex_matrix_value ().hermitian ()); } DEFNCUNOP_METHOD (incr, complex_matrix, increment)
--- a/libinterp/operators/op-fcm-fcm.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-fcm-fcm.cc Wed Dec 09 14:32:04 2015 -0500 @@ -46,12 +46,9 @@ CAST_UNOP_ARG (const octave_float_complex_matrix&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.float_complex_matrix_value ().transpose ()); + error ("transpose not defined for N-d objects"); + + return octave_value (v.float_complex_matrix_value ().transpose ()); } DEFUNOP (hermitian, float_complex_matrix) @@ -59,12 +56,9 @@ CAST_UNOP_ARG (const octave_float_complex_matrix&); if (v.ndims () > 2) - { - error ("complex-conjugate transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.float_complex_matrix_value ().hermitian ()); + error ("complex-conjugate transpose not defined for N-d objects"); + + return octave_value (v.float_complex_matrix_value ().hermitian ()); } DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
--- a/libinterp/operators/op-fm-fm.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-fm-fm.cc Wed Dec 09 14:32:04 2015 -0500 @@ -46,12 +46,9 @@ CAST_UNOP_ARG (const octave_float_matrix&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.float_matrix_value ().transpose ()); + error ("transpose not defined for N-d objects"); + + return octave_value (v.float_matrix_value ().transpose ()); } DEFNCUNOP_METHOD (incr, float_matrix, increment)
--- a/libinterp/operators/op-m-m.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-m-m.cc Wed Dec 09 14:32:04 2015 -0500 @@ -46,12 +46,9 @@ CAST_UNOP_ARG (const octave_matrix&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.matrix_value ().transpose ()); + error ("transpose not defined for N-d objects"); + + return octave_value (v.matrix_value ().transpose ()); } DEFNCUNOP_METHOD (incr, matrix, increment)
--- a/libinterp/operators/op-str-str.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-str-str.cc Wed Dec 09 14:32:04 2015 -0500 @@ -39,13 +39,10 @@ CAST_UNOP_ARG (const octave_char_matrix_str&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.char_matrix_value ().transpose (), - a.is_sq_string () ? '\'' : '"'); + error ("transpose not defined for N-d objects"); + + return octave_value (v.char_matrix_value ().transpose (), + a.is_sq_string () ? '\'' : '"'); } // string by string ops.
--- a/libinterp/operators/op-struct.cc Wed Dec 09 14:18:52 2015 -0500 +++ b/libinterp/operators/op-struct.cc Wed Dec 09 14:32:04 2015 -0500 @@ -39,12 +39,9 @@ CAST_UNOP_ARG (const octave_struct&); if (v.ndims () > 2) - { - error ("transpose not defined for N-d objects"); - return octave_value (); - } - else - return octave_value (v.map_value ().transpose ()); + error ("transpose not defined for N-d objects"); + + return octave_value (v.map_value ().transpose ()); } DEFUNOP (scalar_transpose, scalar_struct) @@ -63,30 +60,30 @@ oct_catop_struct_matrix (octave_base_value& a1, const octave_base_value& a2, const Array<octave_idx_type>&) { - octave_value retval; CAST_BINOP_ARGS (const octave_struct&, const octave_matrix&); + NDArray tmp = v2.array_value (); dim_vector dv = tmp.dims (); - if (dv.all_zero ()) - retval = octave_value (v1.map_value ()); - else + + if (! dv.all_zero ()) error ("invalid concatenation of structure with matrix"); - return retval; + + return octave_value (v1.map_value ()); } static octave_value oct_catop_matrix_struct (octave_base_value& a1, const octave_base_value& a2, const Array<octave_idx_type>&) { - octave_value retval; CAST_BINOP_ARGS (const octave_matrix&, const octave_struct&); + NDArray tmp = v1.array_value (); dim_vector dv = tmp.dims (); - if (dv.all_zero ()) - retval = octave_value (v2.map_value ()); - else + + if (! dv.all_zero ()) error ("invalid concatenation of structure with matrix"); - return retval; + + return octave_value (v2.map_value ()); } void