[Insight-users] Getting PyObject* through to wrapped C++
code
Bill Hoffman
bill . hoffman at kitware . com
Tue, 22 Jul 2003 14:33:40 -0400
That sounds like a good idea. I guess it could be added
as another command line option to cswig.
cswig -cfg_file itk.cfg
Then we just have to change the CMakeLists.txt files to reference
a common itk.cfg file that has all the itk fixes in it.
The only issue is that you can not refer to itk objects in
the itk.cfg file since it is parsed first, but we could
put the exception stuff in there which would be better than
the current approach.
Please try a proof of concept.
-Bill
At 02:15 PM 7/22/2003, Charl P. Botha wrote:
>Hi Bill,
>
>Sorry for all the mails, but I've just discovered something very
>interesting. This also leads to a more elegant solution to all current
>difficulties (I hope).
>
>Please bear with me.
>
>On Tue, Jul 22, 2003 at 01:41:22PM -0400, Bill Hoffman wrote:
>> Node *top = Swig_cparse(cpps);
>> CableSwig cswig;
>> cswig.ParseFile(input_file, top, typemap_lang);
>
>Also in this code, we see the following:
>Printf(fs,"%%include \"swig.swg\"\n");
>if (lang_config) {
> Printf(fs,"\n%%include \"%s\"\n", lang_config);
>}
>
>lang_config is set by python.cxx (part of swig) to python.swg and by
>tcl8.cxx to tcl8.swg. This means that swig IS seeing the following typemap:
>
>%typemap(in) PyObject * "$1 = $input;";
>%typemap(out) PyObject * "$result = $1;";
>
>Which means it SHOULDN'T be touching PyObject* parameter or return types!
>However, Cable doesn't see these as "PyObject *"s, but as "p._object", due
>to the fact that PyObject is actually a typedef'ed _object in the system
>global python.h. So, the typemap is being set, but Cable is presenting
>PyObjects with another name, so Swig isn't recognising them and consequently
>PyObject*s are being mangled.
>
>Should python.swg be patched? Or should we create a global python-cable.swg
>and tcl8-cable.swg with corrections for CableSwig specific behaviour?
>
>My idea would be to create a global itk.swg that always gets parsed (after
>the language specific .swg) with corrections/global additions. It should be
>possible to move the exception handling there as well as the corrected type
>mappings.
>
>What say you? Would you like me to implement a proof-of-concept?
>
>Thanks,
>Charl
>
>--
>charl p. botha http://cpbotha . net/ http://visualisation . tudelft . nl/
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk . org
>http://www . itk . org/mailman/listinfo/insight-users