Welcome to SWIG
[ Chinese ]
SWIG is a software development tool that connects programs written in
C and C++ with a variety of high-level programming
languages. SWIG is used with different types of target languages including common scripting languages such as
Perl, PHP, Python, Tcl and Ruby. The list of
supported languages also includes
non-scripting languages such as C#, Common Lisp (CLISP, Allegro CL, CFFI, UFFI), D, Go language, Java, Lua, Modula-3, OCAML, Octave and R.
Also several interpreted and compiled Scheme implementations (Guile, MzScheme/Racket, Chicken)
are supported. SWIG is most
commonly used to create high-level interpreted or compiled programming
environments, user interfaces, and as a tool for testing and prototyping C/C++ software.
SWIG is typically used to parse C/C++ interfaces and generate the 'glue code' required for the above target languages to call into the C/C++ code.
SWIG can also export its parse tree in the form of XML and Lisp s-expressions.
SWIG is free software and the code that SWIG generates is compatible with both commercial and non-commercial projects.
Recent News
- 2011/05/21 - SWIG-2.0.4 released
- SWIG-2.0.4 release summary:
- This is mainly a Python oriented release including support for Python built-in types for superior performance with the new -builtin option. The -builtin option is especially suitable for performance-critical libraries and applications that call wrapped methods repeatedly. See the python-specific chapter of the SWIG manual for more info. - Python 3.2 support has also been added and various Python bugs have been fixed. - Octave 3.4 support has also been added. - There are also the usual minor generic improvements, as well as bug fixes and enhancements for D, Guile, Lua, Octave, Perl and Tcl. - 2011/03/29 - SWIG-2.0.3 released
- SWIG-2.0.3 has been released. This is a bug fix release including a couple of fixes for regressions in the 2.0 series.
- 2011/02/20 - SWIG-2.0.2 released
- SWIG-2.0.2 has been released and includes the following changes:
- Support for the D language has been added. - Various bug fixes and minor enhancements. - Bug fixes particular to the Clisp, C#, Go, MzScheme, Ocaml, PHP, R, Ruby target languages. - 2010/10/04 - SWIG-2.0.1 released
- SWIG-2.0.1 has been released and includes the following changes:
- Support for the Go language has been added. - New regular expression (regex) encoder for renaming symbols based on the Perl Compatible Regular Expressions (PCRE) library - http://pcre.org . - Numerous fixes in reporting file and line numbers in error and warning messages. - Various bug fixes and improvements in the C#, Lua, Perl, PHP, Ruby and Python language modules. - 2010/06/03 - SWIG-2.0.0 released
- SWIG-2.0.0 has been released. The following are the main changes:
- License changes, see LICENSE file and http://www.swig.org/legal.html . - Much better nested class/struct support. - Much improved template partial specialization and explicit specialization handling. - Namespace support improved with the 'nspace' feature where namespaces can be automatically translated into Java packages or C# namespaces. - Improved typemap and symbol table debugging. - Numerous subtle typemap matching rule changes when using the default (SWIGTYPE) type. These now work much like C++ class template partial specialization matching. - Other small enhancements for typemaps. Typemap fragments are also now official and documented. - Warning and error display refinements. - Wrapping of shared_ptr is improved and documented now. - Numerous C++ unary scope operator (::) fixes. - Better support for boolean expressions. - Various bug fixes and improvements in the Allegrocl, C#, Java, Lua, Octave, PHP, Python, R, Ruby and XML modules. - 2010/04/20 - SWIG joins the Software Freedom Conservancy
- The Software Freedom Conservancy has just announced that SWIG has been accepted as a member of the Conservancy - http://sfconservancy.org/news/2010/apr/20/swig-joins/ . Being part of the Conservancy and all the good work it does for free and open source software is great news for SWIG. The Conservancy provides many benefits such as a formal legal structure and will help ensure the vitality of SWIG as the Conservancy is able to handle donations to the SWIG project. Please visit our new http://www.swig.org/donate.html donations page.
- 2009/09/23 - SWIG's Second Summer of code
- SWIG is a programmer's tool designed to make it easier to use C and C++ code from other popular programming languages such as Python, Perl, Ruby, PHP, Java, and C#. 2009 was SWIG's second Summer of Code, and this year we mentored five projects related to SWIG. All five students were very active over the summer period and produced some great new features. In no particular order:
Matevz Jekovec has been busy working at the coal face of SWIG to add support for C++0x, the forthcoming C++ standard. Matevz has managed to achieve close to full support for C++0x. The C++0x Wikipaedia article http://en.wikipedia.org/wiki/C%2B%2B0x details the numerous planned new C++0x features and Matevž has put together a SWIG C++0x page (http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-matevz/Doc/Manual/Cpp0x.html) documenting the new SWIG support for each of these. In summary the enhanced C++ language can now be parsed by SWIG, which in itself is a great step. There is much more than just this though, as most of the information parsed is used to create useful wrappers of C++0x code. The work can be tried out on the C++0x branch http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-matevz which should be merged fairly soon into a forthcoming release.
Miklos Vajna has been working on SWIG's PHP support to implement an advanced SWIG feature already supported for most other target languages, but not PHP. The feature is called "directors" and allows cross-language polymorphism - wrapped C++ classes can be subclassed in PHP and virtual method calls work in the natural way, whether they're made from PHP or C++ code. You can read more in the new PHP Director documentation http://www.swig.org/Doc1.3/Php.html#Php_nn3 . Miklos made such great progress that we were able to merge this support into SWIG 1.3.40, which was released even before the Summer of Code finished. Miklos also spent some time working on improving SWIG's testsuite for PHP, and fixing bugs in the PHP support.
Ashish Sharma spent the summer adding support for Objective-C as a new target language. Objective-C is a major language on the Mac OS X platform. This means that now SWIG can be used to generate Objective-C wrappers over C++ code. In particular the wrappers include proxy classes, which preserve the class hierarchy from the C++ code. Ultimately this means that from the user's perspective, proxy objects look no different to objects originally written in Objective-C. Adding a new target language is quite a considerable task and Ashish is keen to add plenty more improvements over the coming months. Ashish's work is in Subversion and can be accessed in the ashishs99 branch http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-ashishs99 .
Baozeng Ding has also added a new target language, in this case for the Scilab language, a free numerical computing package. He has coded up support for all the C features: variables, functions, constants, enums, structs, unions, pointers and arrays and also intends to develop it further in the near future. Documentation for SWIG and Scilab can be viewed online direct from Baozeng's Subversion branch http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-sploving/Doc/Manual/Scilab.html .
Kosei Moriyama has been working on Perl bindings for the Xapian library using SWIG, to replace some existing bindings implemented by hand. He's achieved almost complete compatibility with the API of the existing bindings (the only real omission is callbacks which are waiting for completion of director support for Perl in SWIG). He has also wrapped features which weren't previously accessible from Perl. You can view Kosei's work online in his Subversion branch http://trac.xapian.org/browser/branches/gsoc2009-kosei .
Finally, many thanks to Google for sponsoring the summer of code and a special thanks for all the hard work done by the students, mentors and Olly Betts, the co-administrator. - 2009/08/18 - SWIG-1.3.40 released
- SWIG-1.3.40 has been release. A summary of changes is as follows:
- SWIG now supports directors for PHP. - PHP support improved in general. - Octave 3.2 support added. - Various bug fixes/enhancements for Allegrocl, C#, Java, Octave, Perl, Python, Ruby and Tcl. - Other generic fixes and minor new features. - 2009/04/21 - Summer of code 2009 accepted projects
- The students accepted into the Google Summer of Code have now been announced. SWIG has been allocated five student slots by Google and we have chosen the following five projects/students which will be developed over the next four months:
"Add support for Scilab language" - Baozeng Ding "C++0x support for Swig" - Matevz Jekovec "Implement Perl binding for Xapian using SWIG" - Kosei MORIYAMA "Objective C Wrapper Generator over C++ using SWIG" - Ashish Sharma "Director support for PHP" - Miklos Vajna An abstract for each project is available at http://socghop.appspot.com/org/home/google/gsoc2009/swig Congratulations to Baozeng, Matevz, Kosei, Ashish and Miklos, we set some fairly high standards for acceptance this year and you have all done well to meet these standards. We hope that your quality proposals will result in useful enhancements by the end of the summer. For anyone interested in any of these projects, you are welcome to follow the development of them on the swig-devel mailing list - http://www.swig.org/mail.html . Also feel free to drop by our IRC channel to discuss or just say hello - #swig-gsoc on irc.freenode.net. William and Olly SWIG Summer of Code administrators 2009 - 2009/03/21 - SWIG-1.3.39 released
- SWIG-1.3.39 has been release. A summary of changes is shown below.
- Some new small feature enhancements. - Improved C# std::vector wrappers. - Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl and Ruby
More news
Feedback and questions concerning this site should be posted to the swig-devel mailing list.
Last modified : Sat Feb 19 23:56:35 2011
|