I have a complex C ++ library that I need to open in a java application for Android. This C ++ library consists of standard C ++ classes and C ++ class templates.
One of the templates in the library has a template constructor.
Because an example is worth a thousand words:
namespace NS1 {
template < class T >
class Bar {
protected:
T mVal;
public:
template< class OtherType >
Bar (const Bar<OtherType>& pOther) {
mVal = pOther.mVal;
}
};
class A {
};
class B : public A {};
}
I wrap them using the following snippet of the swig interface file:
%extend NS1::Bar< A > {
%template(Abar) NS1::Bar::Bar<NS1::A>;
%template(ABar) NS1::Bar::Bar<NS1::B>;
};
%template(ABar) NS1::Bar< NS1::A >;
%extend NS1::Bar<B> {
%template(BBar) NS1::Bar::Bar<NS1::B>;
};
%template(BBar) NS1::Bar<NS1::B>;
I would like the shell to include a wrapper for the template constructor:
public class ABar {
public ABar (ABar other) {...}
public ABar (BBar other) {...}
}
That's good, the problem is that the extend directive seems to ignore the template parameter and extends each instance of the Bar template with these. That is, the BBarjava class looks like this:
public class BBar {
public BBar (ABar other) {...}
public BBar (BBar other) {...}
}
What is wrong in this case.
How can I bind an extension to a specific instance of a template?
Note:
% ext (%extend NS1::Bar<NS1::A>{...}) Swig.
swig 2.0.12 3.0.8
- -?