Hi. I just committed new feature - exception translation.
In general the only code that a user have to write is "translate"
code. Py++ will
do the rest. It will create translate and register functions.
Usage example:
struct my_exception
{
std::string& what() throw();
...
};
mb = module_builder_t( ... )
exc_class = mb.class_( "my_exception" )
exc_class.exception_translation_code \
= "PyErr_SetString(PyExc_RuntimeError, exc.what().c_str() );"
Py++ also provides a convenience method, that converts exception to string:
exc_class.translate_exception_to_string(
'PyExc_RuntimeError', 'exc.what().c_str()' )
Here you can find the full working example ( unit tests ):
http://svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/cppexceptions_tester.py?view=markup
Enjoy
P.S. Matthias can you update pypp_api?
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|