Skip to content

Declarations

Since C and C++ language standards, features and keywords are ever evolving we obted for a generic solution to implement new keywords/features.

Declaration

To enable you to use any keyword/feature we extended the Embedded Engineers UML Profile to contain the Declaration Stereotype.

This Stereotype/Tagged Values can be set for:

To use this new feature simply apply the Stereotype Declaration to one of the specified elements and set Incorporation, Prefix and/or Suffix Tagged Values

Declaration

Declaration

Incorporation

Specifies where the Pre-/Suffix should be generated.

Possilbe values:

Value Description
Implementation Will generate Pre-/Suffix in the implementation file (.c File)
Declaration Will generate Pre-/Suffix in the declaration file (.h File)
Both Will generate Pre-/Suffix in both files (c. and .h File)

Prefix

A simple string/opaque code that will be inserted right before the code of the flagged element

Suffix

A simple string/opaque code that will be inserted right after the code of the flagged element

Example

Use the model: CodeGenerationComponentsTest.eapx

Element: Model.EmbeddedEngineer Components.AnsiC.Structural Elements.Classes.DeclarationClass

Use the model: MDCodeGenerationComponentsTest.xml

Element: Model.EmbeddedEngineer Components.AnsiC.Structural Elements.Classes.DeclarationClass

We flagged the example Class, Struct, Enum, Activity, Attribute and Operation with a prefix_[type] and suffix_[type] string in the corresponding model.

Generated Code

Pre-/Suffix Code Example
prefix_enum typedef enum suffix_enum {
} DeclarationEnum;

prefix_struct typedef struct DeclarationStructStruct suffix_struct
{
} DeclarationStruct;

prefix_Class typedef struct DeclarationClassStruct suffix_Class
{
    prefix_attr int DeclarationAttr suffix_attr;
} DeclarationClass;

prefix_Activity void DeclarationClass_DeclarationActivity(DeclarationClass* const me) suffix_Activity;

prefix_fnc void DeclarationClass_DeclarationFnc(DeclarationClass* const me) suffix_fnc;