From: William S F. <ws...@fu...> - 2008-07-23 07:54:18
|
ami...@us... wrote: > > Hi > I'm trying to swig some C++ into java. The C++ code boost::shared_ptr > extensively. I included "boost_shared_ptr.i" in my interface file and > defined the template directives to generate the java code: > > %include "boost_shared_ptr.i" > %template (MyCppClassPtr) boost::shared_ptr<MyCppClass>; > > This seems to work, as it generates java MyCppClass and MyCppClassPtr > classes. > > But when I look at the generated code in MyCppClassPtr there is no way > for me to publicly assign an instance of MyCppClass to it. The > generated java looks like this: > > public class MyCppClassPtr { > private long swigCPtr; > protected boolean swigCMemOwn; > > protected MyCppClassPtr(long cPtr, boolean cMemoryOwn) {...} > > protected static long getCPtr(MyCppClassPtr obj) { ... } > > protected void finalize() { ... } > > public synchronized void delete() { ... } > > public MyCppClassPtr() { ... } > > } > You need to use the SWIG_SHARED_PTR or SWIG_SHARED_PTR_DERIVED macro instead of %template. See the notes dated 02/09/2008 in the CHANGES file. Although this is for Python, it applies for Java and C# too. William |