From: Thomas M. <to...@al...> - 2014-01-08 23:02:05
|
I forgot to mention that I am building a python wrap... From: Thomas Maslach [mailto:to...@al...] Sent: Wednesday, January 08, 2014 5:53 PM To: swi...@li... Subject: [Swig-user] Bug in swig with %template/typemap of vector/namespace use? I have the following list test code that I'm trying to get working (I've shortened it greatly from my real example). I am using swig 2.0.11. START INTERFACE FILE: %module(directors="1", allprotected="1") test %include "std_vector.i" %{ #include <vector> class myObject { public : enum EntityType { ET_ONE, ET_TWO }; }; typedef myObject::EntityType myObjectType; %} #include <vector> class myObject { public : enum EntityType { ET_ONE, ET_TWO }; }; typedef myObject::EntityType myObjectType; // First one doesn't work, second one does %template (objectStlVector) std::vector<myObjectType>; //%template (objectStlVector) std::vector<myObject::EntityType>; :END INTERFACE FILE When I run this code, I get the following type of errors (I've only included the first few): D:\software\blue\devtools\bin\win64d\lib\swig2.0\std\std_vector.i(87) : Error: Can't copy typemap (directorout) std::vector< myObject::EntityType,std::allocator< myObject::EntityType > > = std::vector< myObject::EntityType,std::allocator< myObject::EntityType > > &DIRECTOROUT D:\software\blue\devtools\bin\win64d\lib\swig2.0\std\std_vector.i(87) : Error: Can't copy typemap (in) std::vector< myObject::EntityType,std::allocator< myObject::EntityType > > *INPUT = std::vector< myObject::EntityType,std::allocator< myObject::EntityType > > *INOUT D:\software\blue\devtools\bin\win64d\lib\swig2.0\std\std_vector.i(87) : Error: Can't copy typemap (in) std::vector< myObject::EntityType,std::allocator< myObject::EntityType > > &INPUT = std::vector< myObject::EntityType,std::allocator< myObject::EntityType > > &INOUT After playing with this small test case for a while, I did find a workaround - if I avoid using the typedef alias to instantiate my vector, all works well. That means uncommenting the commented line in the code above, while commenting the other %template. The looks to be somewhat familiar with the "using std" issue that was run into a while back (found the thread on swig-user). I do plan on reporting a bug soon as well. However, does anyone have a clever workaround that I could put at the top of the file so that I don't have to change the %template line? The reason I ask is because we auto-generate our interface files from header files. I'd really like to not go into that code to put in a fix, just because there is quite a bit more effort involved than appending something at the top of the interface file (like a %rename perhaps?). The auto-generating tool has the capability of adding stuff at the top of the interface file pretty easily.. If I have to, however, I will; I'd just like to avoid it if possible.. Thanks! Tom |