« Return to Thread: Most trivial example - failure

Re: Most trivial example - failure

by David Piepgrass :: Rate this Message:

Reply to Author | View in Thread

> >From the very beginning I am confused.
>
> What is a module ?  Why is the %module declaration needed ?  What is it
> telling swig to do ?

I have only used SWIG-C#. In SWIG-C# the module name is the name of the static class that contains wrappers of all global functions and variables. Also, if you use more than one module, each one needs a different name.

> Why am I hash-including and percent-including the same file ?
> If I hash-include, surely swig now knows about the class, why would I
> need to tell it again ?

I agree, this is poorly explained. SWIG follows %include directives but it ignores #include directives. %{ ... %} blocks are inserted verbatim into the .cxx wrapper file, but they are otherwise ignored by SWIG.

> Where is the definitive list of swig reserved words and their meanings ?
> This does not seem to appear anywhere in any documentation I can find on
> swig.

All SWIG-specific reserved words start with %... the ones that I can think of are

%module  : first line of your .i file
%include : include a file
%feature : modifies some aspect of SWIG's behavior
%typemap : see chapter 10
%apply   : copy typemaps from one type to another,
           unless the target type already has typemaps defined
%rename  : change name of something in target language
%ignore  : do not create a wrapper for a specific type
%template: instantiate a C++ template and wrap it
%insert  : insert code in .cxx wrapper file
%fragment: define a piece of shared code in .cxx wrapper file that
           is inserted only if it is requested by a typemap
%define...%enddef: multi-line #define

I think most other terms such as %newobject are not keywords, but aliases for features, e.g. in Lib/swig.swg you'll see

#define %newobject        %feature("new")

C/C++ reserved words are also reserved and have the same meaning as they do in C/C++.


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: Most trivial example - failure