# HG changeset patch # User Mike Miller # Date 1491251460 25200 # Node ID 09a1acb81d8bdd3413cd797096c90dbc5fc1de4b # Parent 70071a5512de3f4b361f23ef814f05ba3475f36b Delete legacy code no longer used in project * configure.ac: Drop checks for headers and functions no longer needed. * exceptions.cc, exceptions.h: Delete pytave::init_exceptions and related methods and properties for registering exceptions with Boost.Python runtime. * octave_to_python.cc, octave_to_python.h (pytave::octlist_to_pytuple): Delete. * python_to_octave.cc, python_to_octave.h (pytave::pytuple_to_octlist): Delete. diff -r 70071a5512de -r 09a1acb81d8b configure.ac --- a/configure.ac Mon Apr 03 12:25:03 2017 -0700 +++ b/configure.ac Mon Apr 03 13:31:00 2017 -0700 @@ -40,7 +40,6 @@ [AC_MSG_FAILURE([unable to find Octave development files])]) pytave_save_CPPFLAGS=$CPPFLAGS CPPFLAGS=$OCTAVE_CPPFLAGS -AC_CHECK_HEADERS([octave/call-stack.h]) CPPFLAGS=$pytave_save_CPPFLAGS # Pick a Python library to use @@ -58,9 +57,6 @@ AM_INIT_AUTOMAKE([foreign -Wno-portability]) LT_INIT -# Checks for header files. -AC_CHECK_HEADERS([locale.h]) - # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST @@ -75,10 +71,6 @@ AC_TYPE_UINT32_T AC_TYPE_UINT64_T -# Checks for library functions. -AC_CHECK_FUNCS([uselocale], [pytave_have_uselocale=yes], - [pytave_have_uselocale=no]) - AC_OUTPUT AC_MSG_NOTICE([ @@ -92,15 +84,4 @@ executable ....... $PYTHON Boost::Python ...... $BOOST_PYTHON_LIB -Features - uselocale .......... $pytave_have_uselocale - ========================================================================]) - -AS_IF([test "x$pytave_have_uselocale" = "xno"], - [AC_MSG_WARN([This system doesn't have uselocale support. - The Octave interpreter will NOT work correctly in any - locale but the C (POSIX) locale. Pytave would use the - uselocale function to work around this limitation. Pytave - can be compiled without it but will only work correcly in C - (POSIX) locale.])]) diff -r 70071a5512de -r 09a1acb81d8b exceptions.cc --- a/exceptions.cc Mon Apr 03 12:25:03 2017 -0700 +++ b/exceptions.cc Mon Apr 03 13:31:00 2017 -0700 @@ -31,22 +31,6 @@ namespace pytave { - - PyObject *octave_error_exception::excclass = 0; - PyObject *value_convert_exception::excclass = 0; - PyObject *object_convert_exception::excclass = 0; - 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 ()); - } - std::string fetch_exception_message (void) { PyObject *ptype, *pvalue, *ptraceback; diff -r 70071a5512de -r 09a1acb81d8b exceptions.h --- a/exceptions.h Mon Apr 03 12:25:03 2017 -0700 +++ b/exceptions.h Mon Apr 03 13:31:00 2017 -0700 @@ -32,11 +32,6 @@ class pytave_exception { public: - static void translate_exception (const pytave_exception& py_ex) - { - PyErr_SetString (PyExc_Exception, py_ex.error.c_str ()); - } - pytave_exception (const std::string& err) { error = err; }; private: @@ -46,20 +41,6 @@ class octave_error_exception { public: - static bool init () - { - excclass = PyErr_NewException (const_cast ("pytave.OctaveError"), - PyExc_RuntimeError, 0); - return (excclass != 0); - }; - - static void translate_exception (const octave_error_exception& py_ex) - { - PyErr_SetString (excclass, py_ex.error.c_str ()); - } - - static PyObject *excclass; - octave_error_exception (const std::string& err) { error = err; }; private: @@ -69,20 +50,6 @@ class octave_parse_exception { public: - static bool init () - { - excclass = PyErr_NewException (const_cast ("pytave.ParseError"), - PyExc_RuntimeError, 0); - return (excclass != 0); - }; - - static void translate_exception (const octave_parse_exception& py_ex) - { - PyErr_SetString (excclass, py_ex.error.c_str ()); - } - - static PyObject *excclass; - octave_parse_exception (const std::string& err) { error = err; }; private: @@ -92,20 +59,6 @@ class value_convert_exception { public: - static bool init () - { - excclass = PyErr_NewException (const_cast ("pytave.ValueConvertError"), - PyExc_TypeError, 0); - return (excclass != 0); - }; - - static void translate_exception (const value_convert_exception& py_ex) - { - PyErr_SetString (excclass, py_ex.error.c_str ()); - } - - static PyObject *excclass; - value_convert_exception (const std::string& err) { error = err; }; private: @@ -115,20 +68,6 @@ class object_convert_exception { public: - static bool init () - { - excclass = PyErr_NewException (const_cast ("pytave.ObjectConvertError"), - PyExc_TypeError, 0); - return (excclass != 0); - }; - - static void translate_exception (const object_convert_exception& py_ex) - { - PyErr_SetString (excclass, py_ex.error.c_str ()); - } - - static PyObject *excclass; - object_convert_exception (const std::string& err) { error = err; }; private: @@ -138,27 +77,12 @@ class variable_name_exception { public: - static bool init () - { - excclass = PyErr_NewException (const_cast ("pytave.VarNameError"), - PyExc_RuntimeError, 0); - return (excclass != 0); - }; - - static void translate_exception (const variable_name_exception& py_ex) - { - PyErr_SetString (excclass, py_ex.error.c_str ()); - } - - static PyObject *excclass; - variable_name_exception (const std::string& err) { error = err; }; private: std::string error; }; - bool init_exceptions (void); std::string fetch_exception_message (void); } diff -r 70071a5512de -r 09a1acb81d8b octave_to_python.cc --- a/octave_to_python.cc Mon Apr 03 12:25:03 2017 -0700 +++ b/octave_to_python.cc Mon Apr 03 13:31:00 2017 -0700 @@ -202,20 +202,4 @@ throw value_convert_exception ( "Conversion from Octave value not implemented"); } - - void octlist_to_pytuple (boost::python::tuple& python_tuple, - const octave_value_list& octave_list) - { - boost::python::list seq; - int length = octave_list.length (); - - for (int i = 0; i < length; i++) - { - boost::python::object py_object; - octvalue_to_pyobj (py_object, octave_list(i)); - seq.append (py_object); - } - - python_tuple = tuple (seq); - } } diff -r 70071a5512de -r 09a1acb81d8b octave_to_python.h --- a/octave_to_python.h Mon Apr 03 12:25:03 2017 -0700 +++ b/octave_to_python.h Mon Apr 03 13:31:00 2017 -0700 @@ -55,17 +55,6 @@ */ void octvalue_to_pyobj (boost::python::object& py_object, const octave_value& oct_value); - - //! Octave value list objects are converted to Python tuples. - /*! - \param py_tuple a reference to boost::python::tuple to store - the result of the conversion. - \param oct_list a constant reference to a octave_value_list - that contains the tuple to be converted. - \see pytuple_to_octlist - */ - void octlist_to_pytuple (boost::python::tuple& py_tuple, - const octave_value_list& oct_list); } #endif diff -r 70071a5512de -r 09a1acb81d8b python_to_octave.cc --- a/python_to_octave.cc Mon Apr 03 12:25:03 2017 -0700 +++ b/python_to_octave.cc Mon Apr 03 13:31:00 2017 -0700 @@ -330,15 +330,4 @@ else oct_value = pyobject_wrap_object (py_object.ptr ()); } - - void pytuple_to_octlist (octave_value_list& octave_list, - const boost::python::tuple& python_tuple) - { - int length = extract (python_tuple.attr ("__len__") ()); - - for (int i = 0; i < length; i++) - { - pyobj_to_octvalue (octave_list(i), python_tuple[i]); - } - } } diff -r 70071a5512de -r 09a1acb81d8b python_to_octave.h --- a/python_to_octave.h Mon Apr 03 12:25:03 2017 -0700 +++ b/python_to_octave.h Mon Apr 03 13:31:00 2017 -0700 @@ -57,15 +57,6 @@ */ void pyobj_to_octvalue (octave_value& oct_value, const boost::python::object& py_object); - - //! Python tuples are converted to Octave value list objects. - /*! - \param oct_list a reference to octave_value_list to store the result of the conversion. - \param py_tuple a constant reference to a boost::python::tuple that contains the tuple to be converted. - \see octlist_to_pytuple - */ - void pytuple_to_octlist (octave_value_list& oct_list, - const boost::python::tuple& py_tuple); } #endif