Export to GitHub

swig-gsoc - ProjectIdeas.wiki


Note to potential students: SWIG hasn't applied to take part in GSoC 2010.

We felt we didn't have enough potentially interested mentors this year so have decided to take a break this year. Half-hearted participation is not good for students, for SWIG, or for GSoC itself.

We hope to be back in future years.

Google Summer of Code 2009 Ideas for SWIG

See http://code.google.com/soc/ for details of the Google Summer of Code. SWIG home page - http://www.swig.org.

Ideas

Background Information

SWIG is a software development tool to ease the use of C/C++ code from other programming languages. These so called 'target languages' vary enormously. The most popular being the scripting languages Python, Perl, Ruby, PHP & Tcl and the strongly typed languages, Java & C#. However, the full list of target languages includes various Scheme and Common Lisp languages as well as XML. For C++, SWIG generates the glue code so that a C++ class can be called from an automatically generated target language proxy class. SWIG is coded in C and C++.

Working with SWIG will expose the student to a wide variety programming languages and will give them the chance to gain some deep insight into C/C++ and one or more of the list of target languages. Exposure to Object Oriented programming in general will also be gained.

Idea 1: New C++ standard (C++0x) support

Mostly done in 2009

SWIG can parse and support most of standard C++ (1998, minor updates in 2003). However, there are numerous changes coming up in the next C++ standard, known as C++0x. There are two areas in which SWIG can be modified for the upcoming standard.

a) Language syntax

The goal is to modify SWIG to parse the new language features/syntax and provide the most sensible target language wrappers for the new features. Example areas are rvalue references, initializer lists, concepts, strongly typed enums, type inference (auto) etc.

b) Standard library

The standard library is being enhanced. New SWIG interface library files can be written to provide good wrappers for these new components in any chosen target language. Some good candidates are tuples, hash tables, fixed size arrays.

Students are advised to pick pieces of the standard that can then be made into sub-projects.

The interested student should have good C++ experience and ideally have been following developments in the new standard. For the language syntax modifications, some Bison/yacc parser knowledge is required or at least the desire to learn it. This project will be working on the cutting edge of C++ and is rated mixed as the new standard is so big and varied so the tasks can be broken into sub-projects.

Background reading:

Idea 2: Using source code documentation comments

C/C++ code is often documented using plain C/C++ comments within the code, or nowadays, Doxygen is pretty much the de-facto tool for documenting C++ code. Many of the target languages also have their standard way of generating documentation for the code, eg JavaDoc is used for Java, POD for Perl, PythonDoc for Python etc. An approach is required to parse these documentation comments within the C/C++ header files and use them to document the target language wrapper classes/functions in an easy and intuitive way.

In GSoC 2008, this idea was worked on, adding support to SWIG's parser to pick out Doxygen-format documentation comments and put them in to the parse tree, and to write out these comments in JavaDoc format, translating the more common Doxygen markup.

It would be cool to build on this by adding more output formats (e.g. PythonDoc, Perl POD, etc), and to add support for more Doxygen markup.

The interested student must have at least a basic level of C/C++ and an interest in working with as many of the SWIG target languages as possible (lots of coding experience in these languages isn't required though). The student will gain an appreciation of compilers/parsers and gain an insight into a wide variety of documentation tools. This project is rated medium.

Background reading:

Idea 3: Director support for PHP

Completed in 2009

Idea 4: Enhance COM support

SWIG contains experimental support for generating COM wrappers (added as part of GSoC 2008), which can be used to make C/C++ objects available to COM-aware applications (e.g. most Windows office suites) and languages (Delphi, ASP languages). The COM module is mostly functional, but has some rough edges and unimplemented features. Among those are:

  • Currently only type-unsafe enumerations are supported, where enumerated objects are treated as integers. Type-safe enumerations can be implemented in a similar fashion as they are in SWIG's Java module
  • There is no support for the versioning of classes, interfaces, type libraries, etc. Ideally one should be able to specify versions using the %feature directive
  • The names of COM functions are case insensitive as opposed to C++. This can lead to name clashes, which are not detected by SWIG. This may result in code which does not compile
  • Argument names are not preserved in the IDL file generated by SWIG. While not a critical issue it can make life unnecessarily hard for users of IDEs
  • The generated code should be made 64-bit safe
  • Some registry entries are not created on component registration, which makes it hard to run the component out of process
  • There are only a few runtime tests. So the test coverage could be much improved

The task is to bring the COM module to the state where it can be merged into SWIG's main branch.

The interested student should have an understanding of the basic concepts of COM. An understanding of how OOP constructs are mapped to low-level objects is also quite important. Lastly the student should have some experience writing low-level C/C++ code.

Background reading:

Idea 5: Java annotations support

JDK 1.5 introduced annotations which is a syntax for adding meta data to Java elements such as methods, classes, parameters etc. SWIG needs a way for a user to add annotations to the SWIG generated proxy code. The implementation would be very similar to the C# attributes support currently in the C# module.

The interested student should have some knowledge of C, C++ and Java as well as a desire to learn more about these languages. This project is rated easy, and is probably too small by itself to make a suitable GSoC project, so you should either look to expand upon it, or combine it with another idea (for example, idea 6 below).

Idea 6: Better Multiple Inheritance Support

The requirement is to improve SWIG in the area of multiple inheritance support. For target languages, such as Python, which support multiple inheritance, there is a natural mapping between C++ and Python in this area and SWIG currently provides the natural wrappers in that the Python proxy class can derive from more than one base class. However, some target languages, like Java, only support deriving from a single base class. For these target languages the proxy class is only able to inherit from just one base class and so multiple inheritance is not supported. Many of these languages do actually provide a kind of multiple inheritance in that a class can derive from a single base class and multiple interfaces. The natural equivalent of an interface in C++ is an abstract base class (a class with only pure virtual methods).

The task is first to modify SWIG to recognise and classify abstract base classes. Secondly, choose one or more target language and modify to make use of this classification such that the proxy class implements the interface in the target language. The suggested target languages to improve are C# and/or Java. There is a patch which already provides some of this functionality.

The interested student must preferably have a basic level of C++ experience or alternatively some experience in Java or C#. This project is rated average difficulty.

Background reading:

Idea 7: Add support for Scilab language

Mostly done in 2009

Scilab is a numerical computing high level language. It is pretty similar to Octave/Matlab in its syntax. This idea would be to add the support for the Scilab language into SWIG.

This would be done in collaboration with the Scilab project (also part of the GSOC 2009).

An average level of C is required. There is no need to know the internals of Scilab. Scilab provides an API to extend it (this API could be extended if needed... in the context of this project or not).

Difficulty: medium

Background reading: * http://www.scilab.org/ - The Scilab website * http://wiki.scilab.org/ - The Scilab wiki

Idea 8: Implement bindings for Xapian using SWIG

Perl bindings mostly done in 2009

The Xapian Search Engine Library has a native C++ API, with bindings built using SWIG for Python, PHP5, Ruby, Tcl, and C#. There are also hand-written bindings using JNI for Java, and using XS for Perl.

This project is to use SWIG to implement bindings for another language, or reimplement the Perl or Java bindings (updating JNI and XS code for API changes is a lot more work than it is for SWIG, particularly for JNI). Some work has been done on SWIG-based Java bindings already.

You won't need to get into the "guts" of SWIG for this project, though you may find bugs and/or limitations and want to address them.

Skills: You'll need a good understanding of the language being wrapped. Knowledge of SWIG and C++ would be useful too. Some familiarity with Xapian would be a bonus.

Difficulty: easy-medium

Background reading:

Idea 9: Extend namespace support to more languages

SWIG now supports mapping C++ namespaces into namespaces or equivalent concepts in the target languages, but currently this is only implemented for C# and Java.

This project would be to expand this to support as many target languages as possible.

Idea 10: Improve expression parsing

SWIG needs to be able to parse C/C++ expressions for constants, default parameter values, and template parameters. Currently there are some limitations to what is supported.

This project would be to eliminate these limitations.

Idea 11: Template template support

"Template template parameter support is flaky and could be sorted out."

Further Ideas

We encourage students to suggest their own ideas. The flexibility and power of SWIG is immense as it will parse C/C++ and has the machinery to easily generate any code. Additionally, there are a number of feature requests which could be implemented. Interested students should email the community on the swig-user mailing list where we can give more information.

If you have an idea of suitable scope for GSoC which you'd like to see an idea listed on this page, please chat to us on IRC, see below. Bonus points if you're willing and able to mentor it.

Contact

Students are strongly encouraged to discuss their ideas on the SWIG mailing lists in order to be considered for acceptance. Alternatively, you should find some of the developers on IRC at #swig-gsoc on irc.freenode.net.