Mercurial > hg > octave-lojdl
changeset 7977:065c28e1c368
Modify Fcellfun to directly access the error message/id rather than use a call to Flasterr
author | David Bateman <dbateman@free.fr> |
---|---|
date | Mon, 28 Jul 2008 10:50:46 +0200 |
parents | 736124a4fa3d |
children | f8514786c490 |
files | src/ChangeLog src/DLD-FUNCTIONS/cellfun.cc src/error.cc src/error.h |
diffstat | 4 files changed, 46 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2008-07-28 David Bateman <dbateman@free.fr> + + * error.cc (last_error_id, last_error_message, last_warning_id, + last_warning_message): New functions to return the error/warning + message and id without exposing the internal values. + * error.h (last_error_id, last_error_message, last_warning_id, + last_warning_message): Declare them. + * DLD-FUNCTIONS/cellfun.cc (Fcellfun): Use them to pass the error + to the ErrorHandler function. + 2008-07-28 John W. Eaton <jwe@octave.org> * error.cc (Flasterror, Flasterr): Unwind-protect error_state.
--- a/src/DLD-FUNCTIONS/cellfun.cc +++ b/src/DLD-FUNCTIONS/cellfun.cc @@ -38,9 +38,6 @@ #include "ov-colon.h" #include "unwind-prot.h" -extern octave_value_list -Flasterr (const octave_value_list& args_name, int nargout_name); - DEFUN_DLD (cellfun, args, nargout, " -*- texinfo -*-\n\ @deftypefn {Loadable Function} {} cellfun (@var{name}, @var{c})\n\ @@ -364,13 +361,10 @@ if (error_state && have_error_handler) { - octave_value_list errtmp = - Flasterr (octave_value_list (), 2); - Octave_map msg; - msg.assign ("identifier", errtmp(1)); - msg.assign ("message", errtmp(0)); - msg.assign ("index", octave_value(double (count))); + msg.assign ("identifier", last_error_id ()); + msg.assign ("message", last_error_message ()); + msg.assign ("index", octave_value(double (count + static_cast<octave_idx_type>(1)))); octave_value_list errlist = inputlist; errlist.prepend (msg); buffer_error_messages--; @@ -443,13 +437,10 @@ if (error_state && have_error_handler) { - octave_value_list errtmp = - Flasterr (octave_value_list (), 2); - Octave_map msg; - msg.assign ("identifier", errtmp(1)); - msg.assign ("message", errtmp(0)); - msg.assign ("index", octave_value(double (count))); + msg.assign ("identifier", last_error_id ()); + msg.assign ("message", last_error_message ()); + msg.assign ("index", octave_value(double (count + static_cast<octave_idx_type>(1)))); octave_value_list errlist = inputlist; errlist.prepend (msg); buffer_error_messages--;
--- a/src/error.cc +++ b/src/error.cc @@ -1740,6 +1740,30 @@ return SET_INTERNAL_VARIABLE (debug_on_warning); } +std::string +last_error_message (void) +{ + return Vlast_error_message; +} + +std::string +last_error_id (void) +{ + return Vlast_error_id; +} + +std::string +last_warning_message (void) +{ + return Vlast_warning_message; +} + +std::string +last_warning_id (void) +{ + return Vlast_warning_id; +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/src/error.h +++ b/src/error.h @@ -114,6 +114,12 @@ // TRUE means warning messages are turned off. extern OCTINTERP_API bool discard_warning_messages; +// Helper functions to pass last error and warning messages and ids +extern OCTINTERP_API std::string last_error_message (void); +extern OCTINTERP_API std::string last_error_id (void); +extern OCTINTERP_API std::string last_warning_message (void); +extern OCTINTERP_API std::string last_warning_id (void); + #endif /*