# HG changeset patch # User John W. Eaton # Date 1443892828 14400 # Node ID c547458dc10e48169594b6dcdb1b99aa5490388c # Parent 0fc9b572e566694ad6902c6b03c033e72289b061 eliminate error_state from most header files * defun-int.h, event-queue.h, graphics.in.h, oct-handle.h, ov-classdef.h, misc/f77-fcn.h, unwind-prot.h: Eliminate use of global error_state variable. diff -r 0fc9b572e566 -r c547458dc10e libinterp/corefcn/defun-int.h --- a/libinterp/corefcn/defun-int.h Fri Oct 02 16:07:41 2015 -0400 +++ b/libinterp/corefcn/defun-int.h Sat Oct 03 13:20:28 2015 -0400 @@ -103,21 +103,14 @@ octave_function * \ gname (const octave_shlib& shl, bool relative) \ { \ - octave_function *retval = 0; \ - \ check_version (OCTAVE_API_VERSION, name); \ \ - if (! error_state) \ - { \ - octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \ + octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \ \ - if (relative) \ - fcn->mark_relative (); \ + if (relative) \ + fcn->mark_relative (); \ \ - retval = fcn; \ - } \ - \ - return retval; \ + return fcn; \ } // MAKE_BUILTINS is defined to extract function names and related diff -r 0fc9b572e566 -r c547458dc10e libinterp/corefcn/event-queue.h --- a/libinterp/corefcn/event-queue.h Fri Oct 02 16:07:41 2015 -0400 +++ b/libinterp/corefcn/event-queue.h Sat Oct 03 13:20:28 2015 -0400 @@ -36,8 +36,8 @@ event_queue (void) : fifo () { } // Destructor should not raise an exception, so all actions - // registered should be exception-safe (but setting error_state is - // allowed). If you're not sure, see event_queue_safe. + // registered should be exception-safe. If you're not sure, see + // event_queue_safe. ~event_queue (void) { run (); } diff -r 0fc9b572e566 -r c547458dc10e libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Fri Oct 02 16:07:41 2015 -0400 +++ b/libinterp/corefcn/graphics.in.h Sat Oct 03 13:20:28 2015 -0400 @@ -718,14 +718,9 @@ { double d = c(i).double_value (); - if (! error_state) - { - std::ostringstream buf; - buf << d; - value[i] = buf.str (); - } - else - break; + std::ostringstream buf; + buf << d; + value[i] = buf.str (); } } } @@ -795,14 +790,9 @@ { double d = c(i).double_value (); - if (! error_state) - { - std::ostringstream buf; - buf << d; - value[i] = buf.str (); - } - else - return false; + std::ostringstream buf; + buf << d; + value[i] = buf.str (); } } @@ -810,30 +800,30 @@ } else { - NDArray nda = val.array_value (); - - if (! error_state) + NDArray nda; + + try { - octave_idx_type nel = nda.numel (); - - value.resize (nel); - - for (octave_idx_type i = 0; i < nel; i++) - { - std::ostringstream buf; - buf << nda(i); - value[i] = buf.str (); - } - - stored_type = char_t; + nda = val.array_value (); } - else + catch (const octave_execution_exception&) { error ("set: invalid string property value for \"%s\"", get_name ().c_str ()); - - return false; } + + octave_idx_type nel = nda.numel (); + + value.resize (nel); + + for (octave_idx_type i = 0; i < nel; i++) + { + std::ostringstream buf; + buf << nda(i); + value[i] = buf.str (); + } + + stored_type = char_t; } return true; @@ -1488,23 +1478,18 @@ { bool retval = array_property::do_set (v); - if (! error_state) + dim_vector dv = data.dims (); + + if (dv(0) > 1 && dv(1) == 1) { - dim_vector dv = data.dims (); - - if (dv(0) > 1 && dv(1) == 1) - { - int tmp = dv(0); - dv(0) = dv(1); - dv(1) = tmp; - - data = data.reshape (dv); - } - - return retval; + int tmp = dv(0); + dv(0) = dv(1); + dv(1) = tmp; + + data = data.reshape (dv); } - return false; + return retval; } private: @@ -1712,7 +1697,16 @@ protected: bool do_set (const octave_value& val) { - const Matrix new_kids = val.matrix_value (); + Matrix new_kids; + + try + { + new_kids = val.matrix_value (); + } + catch (const octave_execution_exception&) + { + error ("set: expecting children to be array of graphics handles"); + } octave_idx_type nel = new_kids.numel (); @@ -1721,33 +1715,25 @@ bool is_ok = true; bool add_hidden = true; - if (! error_state) + const Matrix visible_kids = do_get_children (false); + + if (visible_kids.numel () == new_kids.numel ()) { - const Matrix visible_kids = do_get_children (false); - - if (visible_kids.numel () == new_kids.numel ()) - { - Matrix t1 = visible_kids.sort (); - Matrix t2 = new_kids_column.sort (); - Matrix t3 = get_hidden ().sort (); - - if (t1 != t2) - is_ok = false; - - if (t1 == t3) - add_hidden = false; - } - else + Matrix t1 = visible_kids.sort (); + Matrix t2 = new_kids_column.sort (); + Matrix t3 = get_hidden ().sort (); + + if (t1 != t2) is_ok = false; - if (! is_ok) - error ("set: new children must be a permutation of existing children"); + if (t1 == t3) + add_hidden = false; } else - { - is_ok = false; - error ("set: expecting children to be array of graphics handles"); - } + is_ok = false; + + if (! is_ok) + error ("set: new children must be a permutation of existing children"); if (is_ok) { @@ -3395,28 +3381,21 @@ void set___graphics_toolkit__ (const octave_value& val) { - if (! error_state) + if (val.is_string ()) { - if (val.is_string ()) + std::string nm = val.string_value (); + graphics_toolkit b = gtk_manager::find_toolkit (nm); + + if (b.get_name () != nm) + error ("set___graphics_toolkit__: invalid graphics toolkit"); + else if (nm != get___graphics_toolkit__ ()) { - std::string nm = val.string_value (); - graphics_toolkit b = gtk_manager::find_toolkit (nm); - if (b.get_name () != nm) - { - error ("set___graphics_toolkit__: invalid graphics toolkit"); - } - else - { - if (nm != get___graphics_toolkit__ ()) - { - set_toolkit (b); - mark_modified (); - } - } + set_toolkit (b); + mark_modified (); } - else - error ("set___graphics_toolkit__ must be a string"); } + else + error ("set___graphics_toolkit__ must be a string"); } void adopt (const graphics_handle& h); @@ -4515,27 +4494,24 @@ void set_position (const octave_value& val) { - if (! error_state) + octave_value new_val (val); + + if (new_val.numel () == 2) { - octave_value new_val (val); - - if (new_val.numel () == 2) - { - dim_vector dv (1, 3); - - new_val = new_val.resize (dv, true); - } - - if (position.set (new_val, false)) - { - set_positionmode ("manual"); - update_position (); - position.run_listeners (POSTSET); - mark_modified (); - } - else - set_positionmode ("manual"); + dim_vector dv (1, 3); + + new_val = new_val.resize (dv, true); } + + if (position.set (new_val, false)) + { + set_positionmode ("manual"); + update_position (); + position.run_listeners (POSTSET); + mark_modified (); + } + else + set_positionmode ("manual"); } // See the genprops.awk script for an explanation of the @@ -6096,8 +6072,7 @@ cb = go.get (name); } - if (! error_state) - execute_callback (h, cb, data); + execute_callback (h, cb, data); } static void execute_callback (const graphics_handle& h, diff -r 0fc9b572e566 -r c547458dc10e libinterp/corefcn/oct-handle.h --- a/libinterp/corefcn/oct-handle.h Fri Oct 02 16:07:41 2015 -0400 +++ b/libinterp/corefcn/oct-handle.h Sat Oct 03 13:20:28 2015 -0400 @@ -42,12 +42,14 @@ /* do nothing */; else { - double tval = a.double_value (); - - if (! error_state) - val = tval; - else - error ("invalid handle"); + try + { + val = a.double_value (); + } + catch (const octave_execution_exception&) + { + error ("invalid handle"); + } } } diff -r 0fc9b572e566 -r c547458dc10e libinterp/octave-value/ov-classdef.h --- a/libinterp/octave-value/ov-classdef.h Fri Oct 02 16:07:41 2015 -0400 +++ b/libinterp/octave-value/ov-classdef.h Sat Oct 03 13:20:28 2015 -0400 @@ -1208,7 +1208,7 @@ { cdef_class cls (get_class ()); - if (! error_state && cls.ok ()) + if (cls.ok ()) cls.register_object (); } } @@ -1220,7 +1220,7 @@ { cdef_class cls (get_class ()); - if (! error_state && cls.ok ()) + if (cls.ok ()) cls.unregister_object (); } } diff -r 0fc9b572e566 -r c547458dc10e liboctave/cruft/misc/f77-fcn.h --- a/liboctave/cruft/misc/f77-fcn.h Fri Oct 02 16:07:41 2015 -0400 +++ b/liboctave/cruft/misc/f77-fcn.h Sat Oct 03 13:20:28 2015 -0400 @@ -45,8 +45,7 @@ here, we'll restore the previous context and return. We may also end up here if an interrupt is processed when the Fortran subroutine is called. In that case, we resotre the context and go - to the top level. The error_state should be checked immediately - after this macro is used. */ + to the top level. */ #define F77_XFCN(f, F, args) \ do \ diff -r 0fc9b572e566 -r c547458dc10e liboctave/util/unwind-prot.h --- a/liboctave/util/unwind-prot.h Fri Oct 02 16:07:41 2015 -0400 +++ b/liboctave/util/unwind-prot.h Sat Oct 03 13:20:28 2015 -0400 @@ -40,8 +40,8 @@ unwind_protect (void) : lifo () { } // Destructor should not raise an exception, so all actions - // registered should be exception-safe (but setting error_state is - // allowed). If you're not sure, see unwind_protect_safe. + // registered should be exception-safe. If you're not sure, see + // unwind_protect_safe. ~unwind_protect (void) { run (); }