Simplified wrapper and interface generator, or SWIG, translates C/C++ files to various high-level programming languages. Its use is to create user interfaces and environments and test program prototypes.
However, it doesn’t cover all languages, especially those for object-oriented programming. You’ll have to use Valabind to convert .vapi and .vala abstractions into C++.
SWIG is free to use and creates a source code that serves as a connection between the target language and C. The code is always a shared library, but it comes in two forms, depending on the language in question.
The difference is that one library can get linked to an external module, while the other links directly to other programs in the target language.
This program gives you control over most aspects of the wrapper generation process. Some of the most prominent features for you to customise in the program include exception handling, ambiguity resolution, and memory management. You also get access to extensive diagnostic options.
Using SWIG facilitates app customisation and testing of various scripts that you’ll include in the finished program. You can create code for commercial and non-commercial projects under the Gnu license.
Input and output
After you launch the program, it will expect files with ANSI C/C++ declarations and SWIG directives as input. You’ll recognise these files by their .i or .swg suffixes.
SWIG outputs a C/C++ file containing all wrapper code necessary to build an extension module for your target language. Depending on the one you choose, it could generate additional data.
You won’t need to edit the output file, but only compile it and add it to your C/C++ shared library.
Useful for professionals
SWIG facilitates customisation of programs, automating much of the process. Even if the final product doesn't contain a scripting engine, it's handy for writing test scripts. It will require some knowledge of the field, but for programmers, this tool is invaluable.