[Insight-users] Getting PyObject* through to wrapped C++ code
Charl P. Botha
c . p . botha at ewi . tudelft . nl
Tue, 22 Jul 2003 19:45:10 +0200
Hi Bill,
On Tue, Jul 22, 2003 at 01:33:09PM -0400, Bill Hoffman wrote:
> We have integrated the PATCH-SET 1 with some minor modifications
> that allow it to work with the std::exception and not be an ITK specific
> solution, and also we added the code for tcl wrapping as well. So,
> we catch all std::exceptions which ITK exceptions are a sub-class of.
Great, thank you very much! Unfortunately, we're losing file and line
number information however. In the light of this and of other potential
advantages, is it not better to modify itkExceptionObject::what() to return
a compination of GetFile(), GetLine() and GetDescription() instead of just
GetDescription()? This has no drawbacks as far as I can see.
If you think this is a good idea, I could whip up a patch for
itkExceptionObject.
> Could you take a look at re-working PATCH2 with SwigExtras.i in mind?
> I would like to avoid putting ITK specific code into CableSwig.
As I said in a previous mail, typemap specifications in SwigExtras.i are
local to SwigExtras, unless you meant that I should use SwigExtras to create
helper functions to unwrap a wrapped PyObject.
In addition, passing PyObject * through unaltered is definitely not ITK
specific. Swig, in its default configuration, also does this. See this
extract from python.swg:
/* ------------------------------------------------------------
* PyObject * - Just pass straight through unmodified
* ------------------------------------------------------------ */
%typemap(in) PyObject * "$1 = $input;";
%typemap(out) PyObject * "$result = $1;";
Comments?
Thanks,
Charl
--
charl p. botha http://cpbotha . net/ http://visualisation . tudelft . nl/