CCTData Class

If the filter supports both C and C++, there will usually be a base class and two classes that inherit from that class, one for each language. The classes are passed to the system via the filter_init function.

For more information on using CCT filters, see Working with Auto CCT Scripts.

For example, a minimal declaration would look like this:

class TICCTData(CCTData):
    def __init__(self):
        super(TICCTData, self).__init__()

class TICCTDataC(TICCTData):
    def __init__(self):
        super(TICCTDataC, self).__init__()

class TICCTDataCPP(TICCTData):
    def __init__(self):
        super(TICCTDataCPP, self).__init__()

The information in these classes tends to be static information that is specific to the compiler and does not usually change depending on options.

Overridable Functions

The following functions or properties can be overridden for a given filter. The first three (parser_extensions, compiler_behavior and extra_defines) return values which are added to the CCT in a certain section. For the operation of the CCT, the section of the CCT that the text appears in does not matter. They are only separated in this way to improve the readability of the CCT.

parser_extensions

Returns a list of CCT settings for the compiler. For example:

@property
def parser_extensions(self):
    extensions = super(TICCTDataCPP, self).parser_extensions + [
        ["-dpft+"],
        ["-duc99dilt+"],
        ["* special handling for __complex__."],
        [
            r'-coderegex'
            r' "s/__complex__\s+(float|(long\s+)*double(\s+long)*)/__complex__(\1)/"'
        ],

compiler_behavior

Various CCT settings relating to the compiler can appear here. For example:

@property
def compiler_behavior(self):
    return [
        ["-ifn-"],
        ["-sdep-"],
        ["-sig-"],
    ]

extra_defines

Additional macro definitions can be added here. For example:

def extra_defines(self, defines):
    extra = super(TICCTDataC, self).extra_defines(defines)
    extra += [
        ['__interrupt', ''],
        ['_XKEYCHECK', '1'],
        ['__assume(a)', None],
        ['_NATIVE_NULLPTR_SUPPORTED', True],
    ]
    return extra

Note that the value of None indicates that the macro has a blank value and a value of True adds the macro to the CCT without an equals sign. The settings above would produce a CCT with the following lines:

-sd __interrupt=""
-sd _XKEYCHECK="1"
-sd __assume(a)=
-sd _NATIVE_NULLPTR_SUPPORTED

type_mappings

The GNU version of this function is as follows:

@property
def type_mappings(self):
    return (
        ("__WCHAR_TYPE__", "wchar_t"),
        ("__PTRDIFF_TYPE__", "ptrdiff_t"),
        ("__SIZE_TYPE__", "size_t"),
    )

This is telling the system what predefined compiler macro to use for those types.

additional_includes

The return value of this function is the value for ADDITIONAL_INCLUDES in the CCT. It specifies a folder of include files used for analysis. Usually a Stub folder.

masterscript_include

The return value of this function is the value for INCLUDE_VALUE for the MasterScript in the CCT. This is known as the CIP generation script. For example, this CCT had a return value of "DATA/autocct/Script/master_script.py":

* "INCLUDE_LIST" : [
*    {"INCLUDE_STRUCTURE": {
*       "INCLUDE_TYPE": "MasterScript",
*       "INCLUDE_VALUE": "DATA/autocct/Script/master_script.py"
*      }
*    }],

helperscript_include and helperscript_include2

Similar to the masterscript_include function, these two functions specify values for the HelperScript INCLUDE_TYPE. Most CCTs will have just one helper script but if a second is required, it can be specified in the helperscript_include2 function.

get_settings_file_options

This returns values used in the SETTINGS_FILE_OPTIONS part of the CCT which relates to synchronization. Although Auto CCT does it's synchronization without the need for these settings, the generated CCT could be used with other synchronization methods if these settings are provided. For example:

@property
def get_settings_file_options(self):
    return {'EXTENSION': ',', 'FLAG': '-@,--cmd_file=', 'LITERAL_QUOTES': ','}

This is telling other synchronization methods that --cmd_file can specify options in a file. Auto CCT itself would use the value passed to the init_filter function. Refer to The filter_init Function and Filter Setup for more information.

include_flags

Similar to get_settings_file_options, this setting relates to other synchronization methods. It sets the INCLUDE_FLAGS value in the CCT.

signed_char_defines and unsigned_char_defines

The -u setting (unsigned chars) in the CCT is usually determined by a predefined macro value. The define returned by this property is used to see if the char type is signed or not. For example:

@property
def unsigned_char_defines(self):
    return ['__unsigned_chars__']

For unsigned_char_defines, if the define returned is present and has a value of 1, then the -u flag will be set to true in the CCT (-u+). If the compiler doesn't have a define that works in this way, processing must be added to the Visitor class to process the option. Refer to Visitor Class (Option Processing) for more information.

signed_bits_defines and unsigned_bits_defines

The -bits setting (signed bitfields) is usually implemented by checking a command line option—by adding code to the Visitor class, see Visitor Class (Option Processing)—but it is also possible to check defines. For example:

@property
def unsigned_bits_defines(self):
    return ['__UBIT']

@property
def signed_bits_defines(self):
    return ['__SBIT']

In that example, -bits will be enabled if the define __SBIT has a value of 1. It will be disabled if __UBIT has a value of 1.

size_type_map

This is very similar to the custom_size_map function in the Configurator but it has less access to the compilation environment. The values in CCTData are usually fixed and do not depend on compiler options.

In this example, the compiler defines the types in compiler header files so only two types need to be added to the CCT:

@property
def size_type_map(self):
    return {
        "codeptr": "__SIZEOF_POINTER__",
        "dataptr": "__SIZEOF_POINTER__",
    }