From: Fred R. <ric...@co...> - 2005-12-16 01:00:50
|
When I try to convert the following C++ to Python (with SWIG 1.3.24 on MacOS...or 1.3.26 on WinXP Pro, for that matter): -------- %module test %{ #include <vector> %} %inline %{ struct Foo { }; struct Bar { }; %} %include "std_vector.i" /* Put these after the definition of Test class and there is no shadowing. */ %template(vector_Foo) std::vector<Foo>; %template(vector_Bar) std::vector<Bar>; %inline %{ struct Test { void method(const std::vector<Foo>& f) { (void )f; } void method(const std::vector<Bar>& b) { (void )b; } }; %} -------- I get the following error: test.i:19: Warning(509): Overloaded method(std::vector<Bar > const &) is shadowed by method(std::vector<Foo > const &) at test.i:18. However, if I move the two %template lines after the definition of Test then SWIG has no problem wrapping both Test::method() overrides. I can also leave the %template lines where they are and remove the const qualifier from the vector arguments and then SWIG will successfully wrap both methods, too. Am I not using the %template directive correctly, or am I simply pushing to hard with my function/method overloading? The fact that taking the const qualifiers out helps SWIG to work makes me suspect that this is a parsing error. But removing the const qualifiers from my C++ code isn't really an option for me; I'm happy to change the placement of %template directives, but I'd like to understand where the proper place is. Guidelines? -Fred |