From: Build M. <akb...@gm...> - 2012-05-18 22:42:39
|
Forgot to reply to the list instead of the user that answered my question. ---------- Forwarded message ---------- From: Build Master <akb...@gm...> Date: Fri, May 18, 2012 at 5:31 PM Subject: Re: [Swig-user] Updates on Template with nested structure To: David Piepgrass <dpi...@me...> I attached an example. Say on Windows, put the two files under same folder, e.g., "C:\MyTest" and assume SWIG folder is at "C:\MyTest\SWIG" Run this command: SWIG\swig.exe -oMyWrapper_wrap.cxx -c++ -csharp hello_template.swig You will see the errors that I posted. If you comment out all the namespaces in both the .swig file and .h file, the example works perfectly. K On Fri, May 18, 2012 at 4:56 PM, David Piepgrass <dpi...@me...>wrote: > What namespace is MyArray in? Try qualifying with that namespace (or > ::MyArray if no namespace). Also, I noticed the args were “aCustomType > const &” in one place and “const aCustomType &” in another... better make > it the same in both places, just in case.**** > > **** > > If you need further help, I suggest you reduce the problem to a simple, > complete, compilable example that exhibits the problem.**** > > ** ** > > *From:* Build Master [mailto:akb...@gm...] > *Sent:* Friday, May 18, 2012 2:44 PM > *To:* swi...@li... > *Subject:* [Swig-user] Updates on Template with nested structure**** > > ** ** > > Hello, > > Here is an update about my earlier post today (see below the original) > I've narrowed down the problem. > My original problem was that the generated C# subclass > CustomList turned out to be inherited from IDisposal (default) instead of > its true parent MyArray. > > I found that this has nothing to do with the nested Iterator struct, but > with the fact that > the C++ class CustomList was defined in nested namespaces like this > > namespace Name1 > { > namespace Name2 > { > class CustomList : public MyArray<aCustomType, const > aCustomType&, anotherCustomType, 4> > { > .... > } > } > > } > > With the namespace, I got these errors > > 1>HeaderBlob.h(3397) : Warning 401: Nothing known about base class > > 'MyArray< aCustomType, aCustomType const &, anotherCustomType, 4 >'. > > Ignored. > > 1>HeaderBlob.h(3397) : Warning 401: Maybe you forgot to instantiate > > 'MyArray< aCustomType, aCustomType const &, anotherCustomType,4 >' > > using %template. > > > > Even after defined this class with namespaces in my SWIG interface like > this: > namespace AK > { > namespace SoundEngine > { > namespace DynamicDialogue > { > %template(AkPlaylist) Playlist<PlaylistItem, PlaylistItem > const &, ArrayPoolDefault, 4>; > } > } > } > > I still got the same errors. > > Any help would be appreciated. > > K > > > ====================== > Original question > ====================== > Hello, > > I'm generating C# bindings for C++ that need to expose templates. > Now I'm having errors related to nested structures in template class. > > I read from SWIG doc that SWIG has only limited support to nested > structures. > I now have to expose a template class that contains a nest struct, > something looking like this > > // MyArray.h > template <class T, class T1, class T2, unsigned long P> class MyArray { > public: > > MyArray() ....{} > > struct Iterator > { > T* pItem; > Iterator& operator++() { ... } > Iterator& operator--() { ... } > ..... > } > > Iterator Begin() const { ... } > Iterator End() const { ... } > > ... > } > > > Then in my interface I have this statement based on this class: > > > %include <MyArray.h> > > %template(CustomArray) MyArray<aCustomType, aCustomType const &, > > anotherCustomType, 4>; > > > > %include <HeaderBlob.h> > > > > In HeaderBlob.h, I have classes that looks like: > > > class CustomList : public MyArray<aCustomType, const aCustomType&, > > anotherCustomType, 4> > > > > > When using SWIG to generate bindings, I'm getting these errors: > > 1>MyArray.h(84) : Warning 325: Nested struct not currently supported > > (Iterator ignored) > > 1>HeaderBlob.h(3397) : Warning 401: Nothing known about base class > > 'MyArray< aCustomType, aCustomType const &, anotherCustomType, 4 >'. > > Ignored. > > 1>HeaderBlob.h(3397) : Warning 401: Maybe you forgot to instantiate > > 'MyArray< aCustomType, aCustomType const &, anotherCustomType,4 >' > > using %template. > > > > SWIG generates CustomList, aCustomType C# class and CustomArray C# class > that have no connections. > > Also two orphan types are generated > > > > > SWIGTYPE_p_MyArrayT_aCustomType_aCustomType_const_R_anotherCustomeType > > _4_t__Iteratorcs > > SWIGTYPE_p_aCustomType.cs > > > > I wonder if this is due to the nested Iterator struct, or the fact that > I'm missing some required typemaps or other SWIG constructs?? > > Regards, > K**** > |