On Thu, 22 Mar 2007 19:06:22 -0600
"mark gossage " <mark@...> wrote:
>
>> Lets say i have a header file that contains:
>>
>> class csLibraryReference :
>> public scfImplementationExt2<csLibraryReference,
>> csObject,
>> iLibraryReference,
>> iSelfDestruct>
>> {
>> csString file;
>> csString path;
>> bool checkDupes;
>>
>> public:
>> /// The constructor.
>> csLibraryReference (const char* file, const char*
>>path
>> = 0, bool checkDupes = false);
>> /// The destructor
>> virtual ~csLibraryReference ();
>> virtual const char* GetFile () const;
>> virtual const char* GetPath () const;
>> virtual bool GetCheckDupes () const;
>> virtual iObject *QueryObject () { return
>> (csObject*)this; }
>> void SelfDestruct () {}
>> };
>>
>>
>> I will get a warning such as
>>
>>
>> /development/cs/include/cstool/saverref.h(0):
>> Warning(401): Nothing known about base class
>> 'scfImplementationExt2<csLibraryReference, csObject,
>> iLibraryReference,iSelfDestruct>'. Ignored.
>> /development/cs/include/cstool/saverref.h(0):
>> Warning(401): Maybe you forgot to instantiate
>> 'scfImplementationExt2<csLibraryReference, csObject,
>> iLibraryReference,iSelfDestruct>' using %template.
>>
>>
>> So say the next thing I'll do is insert above the class
>> declaration so the waring goes away.
>>
>> #ifdef SWIG
>>
>> %template() scfImplementationExt2<csLibraryReference,
>> csObject, iLibraryReference,iSelfDestruct>;
>>
>> #endif
>>
>> so this means its ready and all the required info for
>> construction as well for %template().
>>
>> I have serveral hundred of these todo.. can I make SWIG
>>do
>> this for me automatically?
>>
>>
>>
>> Thank you,
>> Douglas
>>
>
> Hello Douglas,
> A neater solution is to add this stuff into the .i file.
>That way you don't mess up the original headers (which is
>always a good idea).
>
> ===cspace.i====
> %template()
> scfImplementationExt2<csLibraryReference,csObject,
>iLibraryReference,iSelfDestruct>;
>
> %include "saverref.h"
> ....
>
> ================
> The other thing you can do is to carefully include the
>various files in certain order. Like in C/C++, the order
>that you include makes a difference.
> If you don't want to include a certain file, you can
>just add a few declarations and stuff into the .i file to
>help in the parsing.
The question where i used saverref.h isn't the best
example sinbce currently I am doing it from a .i file in
the exact manner you described :) I wouldnt dare have
added this to the .h ! ok, well maybe for a few minutes to
confirm the %templates() where sufficiently defined by
prevoius %include (for iSelfDestruct first). But then back
to where belong in a .i file.
>
> It looks like you are trying to wrapper crystal space
>3d. There were a previous set of SWIG wrappers written
>for it. Do they no longer work? I seem to remeber that
>those wrappers made heavy use of macro's, you might be
>able to do the same.
The CS java wrappers work, and if you stay w/in the java
context they are sufficient to even write a game!
If you're wrapping a C++ project that uses crystalspace (I
am wrapping Planeshift into java wrappers) there are
return values that leverage CS classes that arnt currently
wrapped like WeakRef<> are RefArray<>.
>
> Regards,
> Mark
>
>
Mainly was hoping there was something simular to
-autotemplate-like option that is used from another
language binding that I can move to SWIGJAVA module or
perhaps one already exists somehow.
But here is something else "getting me":
Every once in a while something uses a member variable
that perhaps needed a %template() before it is seen..
csRef<csVector3> myMemberVar;
Even though a typemap(out)/typemap(in) csRef<csVector> {
... } existed it maybe have needed a
%template()csRef<csVector3 >; ?
csRef<csVector> getMyMemberVar(); will happen .. Would
i have needed to ...
%template() csRef<csVector3 >; first ...
in order to prevent a SWIGTYPE_p_csRefTcsVector3_t.java
from getting produced?
Maybe I am too early with the typemap(in/out) or too
late?.. or maybe missing %template()?
Thank you Douglas.
|