Specifying Data Types, Precision and Enumerators

BridgePoint allows the user to define special data types. Marking is used to define the precision of these data types. This is particularly useful to reduce the storage (say from 16 or 32 bits to 8 bits) of class attributes when the ranges of the attributes are known to be limited. User defined types which are also enumerations are included in the category of types that can be controlled. The datatype.mark provides the means for specifying these data type specializations.

Note that core types can be marked with this function as well as user defined types (UDTs). For example, the core type real can be marked to generate "double" precision.

The return data type for bridges and operations can be user defined data types. Empty operations can be used as a sort of variable declaration in conjunction with UDT precision tagging.

Tagging Precision

Mark TagDataTypePrecision may only be used for application analysis data types which are derived from either BridgePoint core data types of integer or real. Also, user defined types that are enumerations can be marked. Such data will have core data type string, but will serve as integers. Attempting to use this mark with any other core data type will result in a fatal marking error (translation aborted). This restriction applies equally to both component specific and system wide use of this mark.

Precision tag tagged_name may be any standard C/C++ integer or real variable type. For example, unsigned char, long long, double, etc. POSIX types are also accepted, such as uchar_t, ulong_t, etc.

When an analysis class is instantiated, the default is to initialize attributes of core type integer to 0, and attributes of core type real to 0.0 (declared as code type float). Tag initial_value may be used to re-define the default initialization value.

Casting may be used in the tag, such as "(unsigned)EACCESS", but should be used only with careful system level discretion.

No translation time error checking is performed on initial_value. Bogus tags such as "@*#$" will only be caught during compilation.

Invoke TagDataTypePrecision to indicate to the model compiler the precision of a user defined data type.

TagDataTypePrecision(string "component",
 string "dt_name",
 string "tagged_name",
 string "initial_value");
 

Where the input parameters are:

component

component name (Use ``*'' to indicate a system wide data type to be applied to all components containing the user data type.)

dt_name

name of the data type as known in the application analysis

tagged_name

name of the data type as known in generated implementation code (e.g. the precision of the data type)

initial_value

optional specification of the default value for the data type (Use "" for the architectural default (e.g. 0 for integer, 0.0 for real.)

Example 4.3. Data Type Precision

.invoke TagDataTypePrecision( "MyDom", "Octet", "uchar_t", "" )
.invoke TagDataTypePrecision( "MyDom", "FunkyReal", "double", "666.999" )
.invoke TagDataTypePrecision( "*", "SysWideLong", "long int", "-1" )
        


Mapping Pointer Types

To allow for pointer reference to arbitrarily shaped masses of data, user-defined data types can be implemented as pointers. After marking a UDT as a pointer, the pointer typed data can be passed into and returned from operation and bridge operations. Marking is used to tag pointer types. The datatype.mark provides the means for specifying these pointer data type specializations.

Invoke MapDataTypeAsPointer to indicate to the model compiler that a user defined data type shall be implemented as a pointer.

MapDataTypeAsPointer(string "component",
 string "dt_name",
 string "pointer_type",
 string "include_file");
 

Where the input parameters are:

component

component name (Use ``*'' to indicate a system wide data type to be applied to all components containing the user data type.)

dt_name

name of the data type as known in the application analysis

pointer_type

name of the pointer data type as known in generated implementation code.

include_file

optional include file which declares the implementation type of `pointer_type'.

Example 4.4. Mapping Pointer Types

.invoke MapDataTypeAsPointer( "MyDom", "DataPacket", "char", "" )
.invoke MapDataTypeAsPointer( "DomA", "AcmeType", "SomeStruct_t", "legacy.h" )
        


Specifying Uninitialized Enumerators

In analysis models, enumerated types defined within BridgePoint Builder (using the Data Type editor available in BP5.0+) have no initial (uninitialized) value. With marking, it is possible to explicity define this value for uninitialized enumeration variables. The datatype.mark provides the means for specifying this starting value.

To indicate to the software architecture that the uninitialized enumerator of an enumeration shall have a value other than the default, use the following invocation:

TagUninitializedEnumerationValue(string "component",
 string "enumeration",
 string "value");
 

Where the input parameters are:

component

component name (Use ``*'' to indicate a system wide data type to be applied to all components containing the enumeration data type.)

enumeration

is the name of the enumration data type as known in the application analysis. Use ``*'' to indicate all enumerations in a component or system wide.

value

a string containing the value to be assigned to the unitialized enumerator

Example 4.5. Specifying a Value for the Default Uninitialized Enumerator

Domain specific:

.invoke TagUninitializedEnumerationValue( "MO", "wattage", "4" )
        

All Enumerations in Domain:

.invoke TagUninitializedEnumerationValue( "MO", "*", "0x40" )
        

System Wide:

.invoke TagUninitializedEnumerationValue( "*", "wattage", "0x20" )
        

All Enumerations in All Domains:

.invoke TagUninitializedEnumerationValue( "*", "*", "100" )
        


Specifying Values for Enumerators

In some target environments, it may be desirable to select the integer values of the individual enumerators in an enumeration. MC-3020 enables the assigning of discrete values to one or more of the enumerators in an enumeration.

Invoke TagEnumeratorDiscreteValue to indicate to the model compiler that a user defined enumeration data type enumerator shall have a value other than the default.

TagEnumeratorDiscreteValue(string "component",
 string "enumeration",
 string "enumerator",
 string "value");
 

Where the input parameters are:

component

component name (Use ``*'' to indicate a system wide data type to be applied to all components containing the enumeration data type.)

enumeration

is the name of the enumration data type as known in the application analysis. Use ``*'' to indicate all enumerations in a component or system wide.

value

a string containing the value to be assigned to the specified enumerator

Example 4.6. Specifying Enumerator Values

Domain specific:

.invoke TagEnumeratorDiscreteValue( "MO", "wattage", "low", "4" )
.invoke TagEnumeratorDiscreteValue( "MO", "wattage", "med", "0x20" )
        

System Wide:

.invoke TagEnumeratorDiscreteValue( "*", "wattage", "high", "0x40" )