Index: impEM/pyext/SConscript =================================================================== --- impEM/pyext/SConscript (revision 674) +++ impEM/pyext/SConscript (working copy) @@ -9,6 +9,7 @@ # _USE_MATH_DEFINES is needed to get math.h to define M_LN2 under w32 e.Append(CPPDEFINES='_USE_MATH_DEFINES') +e.Append(CPPFLAGS='-DSWIG_TYPE_TABLE=IMP') # Build the Python extension from SWIG interface file: pyext = e.LoadableModule('_IMPEM', 'IMPEM.i', Index: impEM/pyext/IMPEM.i =================================================================== --- impEM/pyext/IMPEM.i (revision 674) +++ impEM/pyext/IMPEM.i (working copy) @@ -17,6 +17,8 @@ %include "std_string.i" %include "std_except.i" +%include "../../pyext/IMP_exceptions.i" + %feature("director"); namespace IMP { @@ -28,8 +30,7 @@ } /* Get definitions of IMP base classes (but do not wrap; that is done by IMP) */ -%import "IMP/Object.h" -%import "IMP/Restraint.h" +%import "../../pyext/IMP.i" /* Get definitions of EMLIB base classes (but do not wrap) */ %import "ParticlesAccessPoint.h" Index: bin/imppy.sh.in =================================================================== --- bin/imppy.sh.in (revision 674) +++ bin/imppy.sh.in (working copy) @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/zsh TOPDIR=@TOPDIR@ MODPY=@MODPY@ Index: pyext/IMP_macros.i =================================================================== --- pyext/IMP_macros.i (revision 674) +++ pyext/IMP_macros.i (working copy) @@ -33,5 +33,10 @@ Ucname *get_##lcname(IndexType i) const ; \ unsigned int number_of_##lcname##s() const {return lcname##_vector_.size();} \ const std::vector &get_##lcname##s() const {\ - return lcname##_vector_;}\ + return lcname##_vector_;} +#define IMP_STATE(version_string, lmb_string)\ + virtual void update(); \ + virtual void show(std::ostream &out=std::cout) const; \ + virtual std::string version() const {return std::string(version_string);} \ + virtual std::string last_modified_by() const {return std::string(lmb_string);} Index: pyext/SConscript =================================================================== --- pyext/SConscript (revision 674) +++ pyext/SConscript (working copy) @@ -6,6 +6,8 @@ e = get_pyext_environment(env, cplusplus=True) e.Append(CPPPATH='#/include') e.Append(LIBPATH='../src', LIBS='imp') +e.Append(CPPFLAGS='-DSWIG_TYPE_TABLE=IMP') +e.Append(CPPFLAGS='-DSWIG_DIRECTOR_STATIC') # Build the Python extension from SWIG interface file: pyext = e.LoadableModule('_IMP', 'IMP.i', Index: pyext/IMP.i =================================================================== --- pyext/IMP.i (revision 674) +++ pyext/IMP.i (working copy) @@ -10,6 +10,27 @@ %include "IMP_macros.i" %include "IMP_exceptions.i" +%{ + /* Code to convert C++ exceptions into scripting language errors. Saves + having lots of catch statements in every single wrapper. */ + void IMP_swig_handle_exception(void) + { + try { + throw; + } catch (std::out_of_range &e) { + SWIG_exception(SWIG_IndexError, e.what()); + } catch (IMP::IndexException &e) { + SWIG_exception(SWIG_IndexError, e.what()); + } catch (IMP::InvalidStateException &e) { + SWIG_exception(SWIG_ValueError, e.what()); + } catch (IMP::ErrorException &e) { + SWIG_exception(SWIG_RuntimeError, e.what()); + } + /* SWIG_exception contains "goto fail" so make sure the label is defined */ + fail: + return; + } +%} namespace IMP { %pythonprepend Model::add_particle %{ Index: pyext/IMP_exceptions.i =================================================================== --- pyext/IMP_exceptions.i (revision 674) +++ pyext/IMP_exceptions.i (working copy) @@ -1,33 +1,13 @@ /* IMP exception handling */ - - %{ - /* Code to convert C++ exceptions into scripting language errors. Saves - having lots of catch statements in every single wrapper. */ - static void handle_imp_exception(void) - { - try { - throw; - } catch (std::out_of_range &e) { - SWIG_exception(SWIG_IndexError, e.what()); - } catch (IMP::IndexException &e) { - SWIG_exception(SWIG_IndexError, e.what()); - } catch (IMP::InvalidStateException &e) { - SWIG_exception(SWIG_ValueError, e.what()); - } catch (IMP::ErrorException &e) { - SWIG_exception(SWIG_RuntimeError, e.what()); - } - /* SWIG_exception contains "goto fail" so make sure the label is defined */ - fail: - return; - } + void IMP_swig_handle_exception(void); %} %exception { try { $action } catch (...) { - handle_imp_exception(); + IMP_swig_handle_exception(); /* This should be unnecessary, since handle_imp_exception cannot return; here just to quell lots of warnings about the 'result' variable not being initialized. */