[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mapper functions for 3.1
From: |
John W. Eaton |
Subject: |
Re: mapper functions for 3.1 |
Date: |
Wed, 13 Feb 2008 18:50:46 -0500 |
On 13-Feb-2008, David Bateman wrote:
| David Bateman wrote:
| > I believe that lgamma and gamma are the only mapper functions that can
| > in fact set error_state and that these two functions are only valid for
| > real arguments, and so one solution and the one I'm working on is to
| > just not treat gamma and lgamma as mappers but like any other builtin
| > function
|
| OK, this isn't a solution as the asinh, etc functions and others also
| use the F77_XFCN macro. The only other solution I see at this point is
| to move the declaration of error_state.cc from error.cc and into
| liboctave.. Do you see any other solutions?
Short of rewriting everything to use C++ exceptions?
How about something like the following patch? With this, I think you
should be able to do
if (liboctave_check_error_state ())
{
// handle error ...
}
I'm not sure this is a great solution, but I think it should work.
Should we add "revamp error handling" to the list for 3.2?
jwe
diff -r 93826ba0d078 libcruft/ChangeLog
--- a/libcruft/ChangeLog Wed Feb 13 00:00:33 2008 -0500
+++ b/libcruft/ChangeLog Wed Feb 13 18:48:00 2008 -0500
@@ -1,3 +1,10 @@ 2008-02-12 John W. Eaton <address@hidden
+2008-02-13 John W. Eaton <address@hidden>
+
+ * misc/lo-error.c (liboctave_error_state_variable): New static variable.
+ (liboctave_set_error_state_variable, liboctave_check_error_state):
+ New functions.
+ * mist/lo-error.h: Provide decls.
+
2008-02-12 John W. Eaton <address@hidden>
* lapack-xtra/xilaenv.f: New wrapper for Fortran function ilaenv.
diff -r 93826ba0d078 libcruft/misc/lo-error.c
--- a/libcruft/misc/lo-error.c Wed Feb 13 00:00:33 2008 -0500
+++ b/libcruft/misc/lo-error.c Wed Feb 13 18:48:00 2008 -0500
@@ -45,6 +45,9 @@ liboctave_warning_with_id_handler curren
liboctave_warning_with_id_handler current_liboctave_warning_with_id_handler
= liboctave_warning_with_id;
+/* Pointer to error_state variable */
+static int *liboctave_error_state_variable = 0;
+
static void
verror (const char *name, const char *fmt, va_list args)
{
@@ -84,6 +87,18 @@ set_liboctave_warning_with_id_handler (l
}
void
+liboctave_set_error_state_variable (int *var)
+{
+ liboctave_error_state_variable = var;
+}
+
+int
+liboctave_check_error_state (void)
+{
+ return liboctave_error_state_variable && liboctave_error_state_variable;
+}
+
+void
liboctave_fatal (const char *fmt, ...)
{
va_list args;
diff -r 93826ba0d078 libcruft/misc/lo-error.h
--- a/libcruft/misc/lo-error.h Wed Feb 13 00:00:33 2008 -0500
+++ b/libcruft/misc/lo-error.h Wed Feb 13 18:48:00 2008 -0500
@@ -53,6 +53,10 @@ CRUFT_API extern void set_liboctave_warn
CRUFT_API extern void set_liboctave_warning_with_id_handler
(liboctave_warning_with_id_handler f);
+CRUFT_API extern void set_liboctave_error_state_variable (int *);
+
+CRUFT_API extern int liboctave_check_error_state (void);
+
#ifdef __cplusplus
}
#endif
diff -r 93826ba0d078 src/ChangeLog
--- a/src/ChangeLog Wed Feb 13 00:00:33 2008 -0500
+++ b/src/ChangeLog Wed Feb 13 18:48:00 2008 -0500
@@ -1,3 +1,8 @@ 2008-02-12 David Bateman <address@hidden
+2008-02-13 John W. Eaton <address@hidden>
+
+ * octave.cc (initialize_error_handlers):
+ Set liboctave_error_state_variable here.
+
2008-02-12 David Bateman <address@hidden>
* graphics.h.in: Implement the cdatamapping property in patch and
diff -r 93826ba0d078 src/octave.cc
--- a/src/octave.cc Wed Feb 13 00:00:33 2008 -0500
+++ b/src/octave.cc Wed Feb 13 18:48:00 2008 -0500
@@ -530,6 +530,7 @@ initialize_error_handlers ()
set_liboctave_error_handler (error);
set_liboctave_warning_handler (warning);
set_liboctave_warning_with_id_handler (warning_with_id);
+ set_liboctave_error_state_variable (&error_state);
}
// What happens on --traditional.
- mapper functions for 3.1, David Bateman, 2008/02/05
- mapper functions for 3.1, John W. Eaton, 2008/02/05
- Re: mapper functions for 3.1, David Bateman, 2008/02/09
- Re: mapper functions for 3.1, David Bateman, 2008/02/09
- Re: mapper functions for 3.1, David Bateman, 2008/02/11
- Re: mapper functions for 3.1, David Bateman, 2008/02/11
- Re: mapper functions for 3.1, John W. Eaton, 2008/02/11
- Re: mapper functions for 3.1, David Bateman, 2008/02/13
- Re: mapper functions for 3.1, David Bateman, 2008/02/13
- Re: mapper functions for 3.1,
John W. Eaton <=
- Re: mapper functions for 3.1, David Bateman, 2008/02/14
- Re: mapper functions for 3.1, John W. Eaton, 2008/02/14
- Using C++ exceptions in liboctave (was: Re: mapper functions for 3.1), John W. Eaton, 2008/02/14
- Using C++ exceptions in liboctave (was: Re: mapper functions for 3.1), John W. Eaton, 2008/02/14
- Re: mapper functions for 3.1, David Bateman, 2008/02/15
- Re: mapper functions for 3.1, John W. Eaton, 2008/02/16
- Re: mapper functions for 3.1, David Bateman, 2008/02/16
- Re: mapper functions for 3.1, John W. Eaton, 2008/02/16
- Re: mapper functions for 3.1, John W. Eaton, 2008/02/16
- Re: mapper functions for 3.1, David Bateman, 2008/02/17