Hi folks!
Just recently I have begun using SWIG to create an Python interface to my C++ kernel. Now, I feel a little overwhelmed by the possibilities and cannot find the right place to find a solution for the following problem of mine:
I have two different enums and a class with different constructors making use of them, e.g.
enum A { a1, a2, a3 };
enum B { b1, b2, b3 };
class C
{
C(string s, A a);
C(string s, B b);
C(string s, A a, B b);
}
Now when using SWIG on this setup, it gives me a message on the shadowing of c'tor C(string s, B b) by C(string s, A a) as apparently Python doesn't know about enumerations and replaces them with integer values. As it is (obviously) impossible to distinguish between C(string s, int a) and C(string s, int b), the second c'tor cannot be called from Python.
I've seen several entries in the SWIG manuals about typemaps, but I am really not sure how to use them or if they can be applicable and helpful in this case (it's clearly stated, typemaps are of the more advanced topics in SWIG interface generation).
Can anybody help me to resolve this issue?
The use of enumerations in C++ is made this way to enable the use of default parameters without paying respect to the ordering of parameters.
Thank you very much in advance and
best regards!
Oliver
thanks for the very fast response!!!
I was just thinking about quite the same thing as I found some indication of this here: http://www.swig.org/Doc1.3/SWIGPlus.html#SWIGPlus_nn16 I'll give it a try and reward you the points if it works (which I have no doubt about :)
Thank you!
Oliver