SWIG's First Summer of Code

SWIG is a programmers tool for semi-automating the calls to C or C++ code from almost any other programming language. The idea is to feed C/C++ header files into SWIG and SWIG then generates the 'glue' code so that your C/C++ library can be used from another language such as Python, Java, C#, Ruby, Perl etc. In fact there are implementations for supporting over 20 different of these target languages. The summer of code students have had a productive summer and have extended the number of languages and features supported in SWIG's first Google Summer of Code.

Haoyu Bai has added support for the upcoming Python 3 release. Python is the most popular target language amongst SWIG users and no doubt this addition will be much appreciated by those who are thinking of upgrading to Python 3. Also Haoyu has provided new Python 3 features which make coding faster and simpler when using Python extension code. The main features added are function annotations, buffer interfaces and abstract base classes and are outlined in more detail here: http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-bhy/Doc/Manual/Python.html#Python_python3support

Jan Jezabek has added a new 'language' module providing Windows Component Object Model (COM) support. This new module makes it possible for any COM enabled language to easily call into C or C++ libraries. The COM module in SWIG is more powerful than most as it ultimately provides support for more than one language as there are numerous languages that can call into COM libraries. Compiled languages such as Visual Basic and scripting languages, such as JScript, VBA and VBScript that can run on the Windows Scripting Host are probably the most popular to benefit. A great use will be the ease of making C/C++ libraries available in applications supporting the various Basic dialects, such as OpenOffice.org and Microsoft Office. SWIG makes it easy to utilise more advanced C++ code, such as templates, and the COM module is no different here as Jan has added in very comprehensive coverage of the C and C++ languages, full details here: http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-jezabek/Doc/Manual/COM.html

Maciej Drwal has added a module for calling C++ code from C code. It is now possible to automatically create a flattened API of C++ classes so that the C++ functionality is available in the form of easy to use C structs and global functions. For example, features such as C++ template classes / functions are easily callable from C. One cool part of this project is the graceful handling of C++ exceptions in the calling C code. Some introductory documentation is available here: http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-maciekd/Doc/Manual/C.html

Cheryl Foil has added an interesting feature to improve code documentation in the target language. This works when C/C++ code is documented using the industry standard Doxygen tool for annotating methods, classes, variables etc. The new feature extracts the Doxygen comments from the code for use by one of the many target languages. Cheryl has added initial support for Java so that the Doxygen comments are turned into JavaDoc comments embedded into the generated Java wrappers, see http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-cherylfoil/Doc/Manual/Doxygen.html

Lastly, many thanks to the mentors involved in making this happen, Ian Appru, Olly Betts, Richard Boulton and William Fulton and finally to Google for funding a great programme.

Posted by William Fulton 2008-10-08