Swig and C# operators (Python is fine)

View: New views
1 Messages — Rating Filter:   Alert me  

Swig and C# operators (Python is fine)

by Giorgio S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm porting a big C++ library to either Python and C#.
In Python the wrapping of C++ operators is just some lines of %rename.

But in C#, SWIG does not accept:

    %rename(operator =) *::operator =

(which is basically what I need).

What I do now is:

   %rename(some_dummy_name) *::operator =

and

   %typemap(cscode) ClassName %{ .... }%

for each class (and they are a lot!) and for each operator (=, ==, +, +=, [], () etc etc).

I could have used SWIGTYPE (instead of ClassName) in %typemap, but not all classes supports all operators (take for example std::vector).

Is there a better way to make this process automatic?

I'm looking for something which can replace all occurences of one operator, possibily parameterized by class_name.

Thanks.