changeset 171:b8560f97e9bf

Wrap custom exception initialization in a function * exceptions.{cc,h} (pytave::init_exceptions): New function. * pytave.cc (pytave::init): Use it.
author Mike Miller <mtmiller@octave.org>
date Thu, 07 Apr 2016 14:12:09 -0700
parents 809f2c7f76c7
children 29d9da90afcf
files exceptions.cc exceptions.h pytave.cc
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/exceptions.cc	Thu Apr 07 10:42:13 2016 -0700
+++ b/exceptions.cc	Thu Apr 07 14:12:09 2016 -0700
@@ -37,4 +37,12 @@
   PyObject *octave_parse_exception::excclass = 0;
   PyObject *variable_name_exception::excclass = 0;
 
+  bool init_exceptions (void)
+  {
+    return (octave_error_exception::init ()
+            && value_convert_exception::init ()
+            && object_convert_exception::init ()
+            && octave_parse_exception::init ()
+            && variable_name_exception::init ());
+  }
 }
--- a/exceptions.h	Thu Apr 07 10:42:13 2016 -0700
+++ b/exceptions.h	Thu Apr 07 14:12:09 2016 -0700
@@ -157,6 +157,8 @@
   private:
     std::string error;
   };
+
+  bool init_exceptions (void);
 }
 
 #endif
--- a/pytave.cc	Thu Apr 07 10:42:13 2016 -0700
+++ b/pytave.cc	Thu Apr 07 14:12:09 2016 -0700
@@ -71,11 +71,7 @@
     c_locale = newlocale (LC_ALL, "C", 0);
 #endif
 
-    if (! octave_error_exception::init ()
-        || ! value_convert_exception::init ()
-        || ! object_convert_exception::init ()
-        || ! octave_parse_exception::init ()
-        || ! variable_name_exception::init ())
+    if (! init_exceptions ())
       {
         PyErr_SetString (PyExc_ImportError, "_pytave: init failed");
 #if defined (PYTHON_ABI_VERSION)