lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> What is SWIG? (Maybe you could mention something on your web page about it)

As somebody else already mentioned, SWIG is a wrapper generator for C/C++
libraries. It parses C/C++ header files and tries to build wrappers for
any declared functions. It also has some limited functionality to produce
object oriented code for Tcl out of C++ classes.

I use SWIG to wrap an XML processor for usage in various scripting
languages. This XML processor is part of my Ph.D. work, so I wanted to
demonstrate its use in as many contexts as possible. At our department,
Tcl is widely used, but I like Lua much better, and other languages are
also quite interesting. SWIG is very handy to use existing libraries (with
not too complex interfaces) in different languages. Currently, I generate
the C header files which are fed into SWIG by processing an interface
declaration written in XML (of course using a Lua script). This also helps
to generate documentation in HTML or other formats.

The drawbacks are that more complex interfaces or C++ code is wrapped only
in a very basic way, i.e. not taking advantage of inheritance relations,
overloading etc. SWIG works best with libraries that use opaque datatypes
along with a set of operations on these datatypes. It is however possible
to use alot of hacking and produce more sophisticated wrappers. The
problem is that some of these enhancements might not be usable in some
scripting languages, so SWIG sticks mostly to the least common denominator
across languages.

I'll put some info about SWIG on SWIGLua's web page, thanks for your
suggestion.

Regards,

Eckhart

-- 
Universität GH Essen - Wirtschaftsinformatik und Softwaretechnik
Universitätsstr. 9, D-45141 Essen, Raum R09 R02 H18
Tel.: +49 (0201) 183 4075 Fax: +49 (0201) 183 4073
Eckhart.Koeppen@uni-essen.de http://nestroy.wi-inf.uni-essen.de/Koeppen/