Mercurial > octave-antonio
diff libinterp/octave-value/ov-usr-fcn.cc @ 15427:6823ad7a25b1
implement local option for warnings
* error.cc (warning_query): New function.
(Fwarning): Handle "local" option when setting warning states.
Use warning_query to handle query option.
* ov-usr-fcn.cc (octave_usr_function::restore_warning_states):
New private function.
(octave_usr_function::bind_automatic_vars): Create hidden auto
variable .saved_warning_states.
(octave_usr_function::do_multi_index_op): Insert pointer to
restore_warning_states function in unwind_protect frame.
* ov-usr-fcn.h (octave_usr_function::restore_warning_states):
Provide decl.
* NEWS: Note user visible change.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Sep 2012 12:20:39 -0400 |
parents | 3f43e9d6d86e |
children | 52df2e7baabe |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-usr-fcn.cc Thu Sep 20 10:14:03 2012 -0400 +++ b/libinterp/octave-value/ov-usr-fcn.cc Thu Sep 20 12:20:39 2012 -0400 @@ -30,6 +30,7 @@ #include <defaults.h> #include "Cell.h" +#include "builtins.h" #include "defun.h" #include "error.h" #include "gripes.h" @@ -455,6 +456,8 @@ bind_automatic_vars (arg_names, nargin, nargout, all_va_args (args), lvalue_list); + frame.add_method (this, &octave_user_function::restore_warning_states); + bool echo_commands = (Vecho_executing_commands & ECHO_FUNCTIONS); if (echo_commands) @@ -614,6 +617,11 @@ symbol_table::mark_automatic (".nargin."); symbol_table::mark_automatic (".nargout."); + symbol_table::varref (".saved_warning_states.") = octave_value (); + + symbol_table::mark_automatic (".saved_warning_states."); + symbol_table::mark_automatic (".saved_warning_states."); + if (takes_varargs ()) symbol_table::varref ("varargin") = va_args.cell_value (); @@ -648,6 +656,26 @@ symbol_table::mark_automatic (".ignored."); } +void +octave_user_function::restore_warning_states (void) +{ + octave_value val = symbol_table::varval (".saved_warning_states."); + + if (val.is_defined ()) + { + octave_map m = val.map_value (); + + if (error_state) + panic_impossible (); + + Cell ids = m.contents ("identifier"); + Cell states = m.contents ("state"); + + for (octave_idx_type i = 0; i < m.numel (); i++) + Fwarning (ovl (states(i), ids(i))); + } +} + DEFUN (nargin, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} nargin ()\n\