Typemaps are the very heart of what SWIG does. When you want to pass data between languages the behaviours for doing so depend upon the type that SWIG sees. The power of typemaps is that the chunks of code are applied many times.
SWIG itself includes many useful typemaps in the core library it is supplied with, e.g. for primitive types, C++ standard library containers, boost etc. so often you won't even need to write any typemaps to expose your code, however that list is by no means complete.
|NAME||The name of the typemap defines its role in generating a module. |
|TYPENAME||Each typemap gets applied to one or more matching types. These need to be listed here. Type qualifiers (e.g. const) matters.|
|CODE||Every typemap needs to convert between the C or C++ type and the corresponding type in the wrapped language. You will need to write code to do that in your custom typemaps, typically making use of special variables that get substituted in. E.g. |
|VARIABLENAME||Typemaps are matched from most specific to least specific in general. You can define a typemap that will only match function arguments with specific names by using this optional form. (See typemap matching for more details)|
|(LOCALVARTYPE LOCALVARNAME)||Sometimes, particuarly for |
|OPTION=VALUE||The behaviour of some typemaps can be influenced by setting extra options using this syntax. For example a |