Reputation: 2154
Let's say I have this in C/C++:
struct MyType {
int foo;
long other;
};
I want to change "int" ONLY of field "foo" to bool in SWIG! How can I do this?
I don't want to change the original source. Normally if it were my sources, I would just change to bool!
Upvotes: 0
Views: 255
Reputation: 88721
You can use %apply
to use the bool
typemaps on int foo
to achieve what you want:
%module test
%apply bool { int foo };
%inline %{
struct MyType {
int foo;
};
%}
In other more convoluted scenarios you'd have to write your own typemaps to support this, but since bool and int are implicitly convertible in C++ this will compile and work just fine out of the box.
Upvotes: 1