| SWIG Features |
| |
| <h2>SWIG Features</h2> |
| |
| <p> |
| This information is based on the SWIG-1.3.22 release. |
| |
| <h3>Code Generation</h3> |
| |
| SWIG current generates wrapper code for thirteen different target languages: |
| |
| <ul> |
| <li>Allegro CL |
| <li>C# |
| <li>Chicken |
| <li>Guile |
| <li>Java |
| <li>Modula-3 |
| <li>Mzscheme |
| <li>OCAML |
| <li>Perl |
| <li>PHP |
| <li>Python |
| <li>Ruby |
| <li>Tcl |
| </ul> |
| |
| In addition to this, an XML output module is also available and work |
| is in progress on a Pike module. |
| |
| <h3>ANSI C</h3> |
| |
| SWIG is capable of wrapping all of ANSI C. Features include: |
| |
| <ul> |
| <li>Handling of <em>all</em> ANSI C datatypes. |
| <li>Global functions, global variables, and constants. |
| <Li>Structures and unions. |
| <li>Pointers. |
| <li>Arrays and multidimensional arrays. |
| <li>Pointers to functions. |
| <li>Variable length arguments. |
| <li>Typedef. |
| <li>Enums. |
| </ul> |
| |
| <h3>ANSI C++</h3> |
| |
| SWIG provides wrapping support for almost all of ANSI C++. |
| |
| <ul> |
| <Li>All C++ datatypes. |
| <Li>References. |
| <li>Pointers to members. |
| <li>Classes. |
| <li>Inheritance and multiple inheritance. |
| <li>Overloaded functions and methods (using dynamic dispatch). |
| <li>Overloaded operators. |
| <li>Static members. |
| <li>Namespaces (including using declarations, aliases, nesting, etc.) |
| <li>Templates |
| <li>Member templates |
| <li>Template specialization and partial specialization. |
| <li>Smart pointers |
| <li>Library support for strings, STL vectors, and more. |
| </ul> |
| |
| The only major C++ feature not currently supported by SWIG is the |
| wrapping of nested classes--a problem we're working on. SWIG also |
| does not allow C++ virtual methods to be implemented in certain |
| target languages (a subtle feature that might be useful in projects that |
| rely heavily on the use of callback functions). |
| |
| <p> |
| C++ users who rely on advanced template programming techniques |
| (e.g., template meta-programming) should also be aware that SWIG |
| currently requires manual instantiation of all template classes. |
| Therefore, if your application somehow involves the instantiation of 50000 |
| template classes, your mileage might vary. |
| |
| <h3>Preprocessing</h3> |
| |
| SWIG provides a full C preprocessor with the following features: |
| |
| <ul> |
| <li>Macro expansion. |
| <li>Automatic wrapping of #define statements as constants (when applicable). |
| <li>Support for C99 (variadic macro expansion). |
| |
| </ul> |
| |
| <h3>Customization features</h3> |
| |
| SWIG provides control over most aspects of wrapper generation. Most |
| of these customization options are fully integrated into the C++ type |
| system--making it easy to apply customizations across inheritance |
| hierarchies, template instantiations, and more. Features include: |
| |
| <ul> |
| <li>Customizated type conversion/marshaling. |
| <Li>Exception handling. |
| <li>Class/structure extension. |
| <li>Memory management. |
| <li>Ambiguity resolution. |
| <li>Template instantiation. |
| <li>File import and cross-module linking. |
| <li>Code inclusion, helper function support. |
| <li>Extensive diagnostics (error/warning messages). |
| <li>Extended SWIG macro handling. |
| </ul> |
| |