CableSwig is used to create interfaces (i.e. "wrappers") to interpreted languages such as Tcl and Python. It was created to produce wrappers for ITK because the toolkit uses C++ structures that SWIG cannot parse (deeply nested template instantiations). CableSwig is a combination tool that uses  GCC_XML as the c++ parser. The input files are  Cable style input files. The XML produced from the Cable/GCC_XML input files are then parsed and feed into a modified version of  SWIG. SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. It is used to generate the language bindings to the target language. Currently, Tcl and Python are supported.

CableSwig consists of four executables:

  • cswig - the main cable swig executable, that takes an xml file from gccxml as input. The xml file should be created from a cable config input file. This program is a modified version of the standard SWIG main. It uses CABLE libraries to parse the input XML from gccxml to create SWIG data structures describing the C++ code to be wrapped.

  • cableidx - a program to generate index files from gccxml xml files. The index files tell cswig what classes are wrapped in which libraries. This is important because swig needs to know if a class is not wrapped or wrapped in another module, and if it is wrapped which module it is wrapped in.

  • gccxml_cc1plus - A patched version of gcc that has the -fxml option to convert c++ into xml.

  • gccxml - ( the front end program to gccxml_cc1plus.
Installing and Downloading
CableSwig is currently only available by Git.

Use the following command:

git clone git://

You will need to install  CMake to build CableSwig. Once you have CableSwig sources and CMake on your system, there are two ways to build CableSwig for ITK:

  • Building inside ITK - If you are using CableSwig to wrap ITK, the easiest way to build it, is to checkout CableSwig in the Insight/Utilities directory, then CableSwig will be built as part of ITK. If not, then build it as you would any other CMake project.

  • Building outside ITK - CableSwig can also be built outside ITK. Just run CMake with the CableSwig as the source directory of the build, and choose a directory for the binary. Then generate the native build files and compile.

  • Enable CSwig for ITK - When running CMake on ITK, show the advanced cache values with the cmake GUI (CMakeSetup or ccmake. Turn on the ITK_CSWIG_TCL and/or the ITK_CSWIG_PYTHON variables. If CableSwig is in the Utilities directory that is all you should need to do. If not, you will have to tell CMake were CableSwig has been built. CSWIG, CABLE_INDEX, and GCCXML will all need to be located for the wrapping process.
For more information about ITK and CableSwig see the README file in Insight/Wrapping/CSwig/README.

CableSwig was developed to support ITK, and has not been widely used elsewhere. Not all features of SWIG are currently accessible through CableSwig. Features known to be missing are:
  • Wrapping of public data members in structs and classes. No accessor routines are created. The original source must provide access methods.