In general, CommaSuite generators map language constructs to other language constructs belonging to a target language. For example, in case of monitoring, CommaSuite types are mapped to Java types since the monitors are implemented in Java. Users can define their own primitive types for which a generator may have no knowledge how to handle them. The type mappings configurations can be used to provide an additional information to code generators.

A type mapping is a named collection of pairs whose first element is a CommaSuite primitive type, either built-in or user defined, and a string as a second element. Type mappings are given in project files and can be referred to from generator tasks with their names.

It should be noted that the currently supported CommaSuite generator tasks do not use type mappings but extentions of the framework can do so.

As an example of using type mappings, consider a generator that generates C code. Assume that users have defined their own primitive types that correspond to C double and float types (CommaSuite does not have them as built-in types). In principle, the generator cannot anticipate in advance all possible user defined types. The way they are mapped to C may be given in a type mapping.

The syntax is as follows.

TypeMappings {
    mappingsForC {
        double -> "double"
        float -> "float"
        int -> "long"

        interface foo {
            wstring -> "std::wstring"
        }

        interface bar {
            int -> "ulong"
        }
    }
}

In this example, the mappings specify the text that will be used by the generator to represent the primitive types. Note that built-in types (int in this case) can also be used. Furthermore, mappings for types defined in a particular interface can also be given (wstring in the example) and can override the general mappings (e.g. int in the context of interface bar).

The defined mappings can be referred to within generator tasks. Here is an example of a hypothetical task generating C code.

Generate CCode {
    task1 {
        ...
        mappings = mappingsForC
    }
}