Parameter mapping for C (C code)
ACS generates a Parameter as part of both the declaration and implementation of an Operation. In each case the code is derived from the properties of the Parameter (Mechanism and Data Type) and the tagged values set for Tag Definitions that are applied by the «C Parameter» stereotype.
Properties:
If the Data Type property is set, ACS generates the value as the parameter's data type, unless there is a value set for the C Function Pointer Return tag definition, in which case that value is used for the parameter's data type.
Example code:
// File foo.h
void SomeOp(int a = 10, char* name = "foo");
If no data type is specified, ACS generates int by default. If you want ACS to generate a different default in the absence of a data type for an Attribute, Parameter or Type Definition, change the default value that is specified in the C_Sync.ini file. Tell me more...
Reverser Notes: When reverse engineering a parameter's data type:
If the data type is modeled in the Model or is going to be reverse engineered to the Model, the Parameter's Data Type references the appropriate item.
If the data type is not modeled in the Model and is not going to be reverse engineered to the Model, the Parameter's Data Type is set to the name of the data type (as text).
If the data type is a function pointer, the Parameter's Data Type is not set and instead the C Function Pointer Return and C Function Pointer Parameter tag definitions are used to record the data type.
The Default Value property is ignored.
The Description property is ignored.
If the Mechanism property is set to 'Out' or 'In and Out', the parameter is generated as a pointer. If the Mechanism property is set to 'In', the parameter is not generated as a pointer. If a value is set for the C Indirection tag definition, the Mechanism property is ignored.
Example code:
void func(int inParam, int* inOutParam, int* OutParam);
Reverser Notes: When reverse engineering parameters, if a parameter has any indirection the Reverser sets the Mechanism property to 'In and Out', else the Mechanism property is set to 'In'.
The Name property is generated as the name of the parameter in the code.
Example code:
void func(const int foo);
* 
ACS may modify the parameter name that is added to the code to make it valid for C. You can specify the exact parameter name to add to the code through the CODE_GENERATION_NAME property of a Parameter. Tell me more...
Tag Definitions:
The following tag definitions are applied to a Parameter by the «C Parameter» stereotype:
If the tagged value of the C Anonymous Itemtag definition is set to TRUE, it means that the parameter is used as an anonymous type and is generated with no name.
Example code:
// Sometimes developers (for whatever reason) don't name a parameter.
// In these cases the parameter is called something like unnamed0 but
// when we generate it we give it no name
void myFunc(char* name, int age, bool); // Last parameter is anonymous
Reverser Notes: When reverse engineering a parameter that is used as an anonymous type, the Reverser creates a Parameter in Modeler and sets its C Anonymous Item tag definition to TRUE. The name of the Parameter is as follows: unnamed<integer to make unique>
If the tagged value of the C Array Spec tag definition has been set, the value is used as the parameter array, that is, it is generated after the parameter name.
Example code:
void foo(char name[255]);
#define AgeCount 20
int SetAges(int Ages[AgeCount]);
If the tagged value of the C CV Qualifier tag definition is set to const, volatile or const volatile, the selected keyword is generated before the data type.
Example code:
void func(const int foo);
void func2(volatile float pi);
void func3(const volatile char cvParam)
{
}
If the tagged values of the C Function Pointer Parameters and C Function Pointer Return tag definitions have been set, the Parameter declaration is generated as follows:
<C Function Pointer Return>(<C Indirection><derived C Name>)(<C Function Pointer Parameters>);
Reverser Notes: When reverse engineering parameters that are of type function pointer, the Reverser uses the tagged values of the C Function Pointer Parameters and C Function Pointer Return tag definitions to capture the return type and parameters of the function pointer.
If the tagged value of the C Indirection tag definition has been set, the value is used as the indirection, that is, the value is generated after the data type and before the parameter name. If the tagged value of the C Storage Class tag definition is set to auto, register or extern, the selected storage class keyword is generated. Note that for a Parameter you should use only the auto or register values.
Example code:
void func(const int* foo);
void func2(float* const pi);
void func3(char* const * cvParam);
Was this helpful?