The following sections present a detailed specification of the Generator UML to Embedded C. It specifies the functional & non-functional requirements that are implemented in the generator and the UML profile 'Embedded_C'.
UML is so generic and sometimes so abstract that it is really hard to map the C language in UML. In order to overcome this problem, the entities of the C language are described with the help of UML stereotypes. Indeed, the UML standard often needs extensions to specify entities that only exist in C.
Therefore, UML stereotypes constitute a nice way to extend the UML standard. A stereotype is defined either as an extension of a UML base meta-class or as a specialization of an existing stereotype. The extension relationship of UML is not an association but a kind of association directed from the stereotype to the extended meta-class. Consequently, the metadata conveyed by the associated the attributes of the stereotype are associated to the extended meta-class in a transparent manner for the meta-class itself. This allows profiles owning the stereotypes to be applied and removed dynamically without modifying the underlying models.
For the sake of simplicity, a minimum number of stereotypes have been defined.
REQ-PROF-001: The profile Embedded_C shall be identified under the ID 'org.eclipse.umlgen.gen.embedded.c.profile'.
REQ-PROF-002: The profile Embedded_C shall provide the following stereotypes:
REQ-PROF-003: The stereotype 'Array' shall be applicable for any uml::Property. It shall have the following attribute:
REQ-PROF-004: The stereotype 'Asm' shall be applicable for any uml::Operation.
REQ-PROF-005: The stereotype 'Attribute' shall be applicable for any uml::Property or uml::Datatype. It shall have the following attribute:
REQ-PROF-006: The stereotype 'Constant' shall be applicable for any uml::EnumerationLiteral of a given uml::Enumeration. It shall have the following attributes:
REQ-PROF-007: The stereotype 'Inline' shall be applicable for any uml::Operation.
REQ-PROF-008: The stereotype 'Pointer' shall be applicable for any uml::TypedElement. It shall have the following attribute:
REQ-PROF-009: The stereotype 'Requirement' shall be applicable for any uml::Constraint. It shall have the following attributes:
REQ-PROF-010: The stereotype 'Singleton' shall be applicable for any uml::Class.
REQ-PROF-011: The stereotype 'Object' shall be applicable for any uml::Class.
REQ-PROF-012: The stereotype 'Struct' shall be applicable for any uml::TypedElement.
REQ-PROF-013: The stereotype 'Typedef' shall be applicable for any uml::DataType or uml::Enumeration. It shall have the following attribute:
In case of Enumeration, if the attribute ‘MappedType’ is specified, the default type of the Enumeration is redefined by an specified mapped type. Otherwise, the Enumeration itself is seen as a type.
REQ-PROF-014: The stereotype 'Union' shall be applicable for any uml::DataType.
REQ-PROF-015: The stereotype 'UsesStaticMethods' shall be applicable for any uml::Property.
REQ-PROF-016: The stereotype 'Value' shall be applicable for any uml::EnumerationLiteral. It shall have the following attribute:
REQ-PROF-017: The stereotype 'Volatile' shall be applicable for uml::Property.
In addition to the stereotypes, the profile should also own the basic types of the C language.
REQ-PROF-018: The profile Embedded_C shall provide the primitive types of the C language:
The Generator UML to Embedded C shall be an Acceleo based generator which shall be compliant to the UML2 meta-model ( http://www.eclipse.org/uml2/5.0.0/UML). The following lines present the general specification of the feature and a detailed specification of the model to text transformations.
REQ-GEN-001: The Generator UML to Embedded C shall be identified under the ID 'org.eclipse.umlgen.gen.embedded.c'.
REQ-GEN-002: The feature Generator UML to Embedded C shall include at least the following plugins:
REQ-GEN-003: The Generator UML to Embedded C shall be a specialization of the 'org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator'.
REQ-GEN-004: The generator shall generate ANSI C files from an UML model.
The model shall contain at least one uml::Package. Otherwise, nothing is generated.
REQ-GEN-005: The maximum size of a comment line shall be 120 semi-colomns.
REQ-GEN-006: The size of a tabulation shall be 4 spaces.
The following requirements specify the model to text transformations for uml::Package.
REQ-PACK-001: A uml::Package shall take the representation of a directory in the file system. The name of the directory shall be the name of the uml::Package.
REQ-PACK-002: Besides the directory, a header and a source file shall be generated for each uml::Package. The name of the files shall be the name of the uml::Package.
REQ-PACK-003: The header file of a uml::Package shall contain the followings:
REQ-PACK-004: The source file of a uml::Package shall contain the followings:
The following requirements specify the model to text transformations for uml::Class.
REQ-CLASS-001: The generator shall generate a source file plus a header file for any uml::Class. The name of both files shall be equal to the name of the uml::Class.
REQ-CLASS-002: The header file of an uml::Class shall contain at least the followings:
REQ-CLASS-003: The source file of an uml::Class shall contain at least the followings:
REQ-CLASS-004: A uml::Class may have several representations. The generator shall manage the following extensions:
REQ-CLASS-005: In case of uml::Class stereotyped as 'Object', the properties of the given uml::Class shall be generated as variables.
The variables may be public (generated in the source file and external in the header file) or private (generated statically in the source file).
REQ-CLASS-006: In presence of uml::Class stereotyped as 'Singleton' or nothing, a structural definition of the uml::Class shall be generated where the fields of the structure are the properties of the given uml::Class.
The name of the C structure is the name of the uml::Class plus the string '_t'.
REQ-CLASS-007: In presence of a uml::Class stereotyped as 'Singleton', its structural definition shall be instantiated once as a static variable in the source file if the singleton is private.
The name of the variable shall be equal to the name of the 'Singleton'.
The following requirements specify the model to text transformations for uml::Property.
REQ-PROP-001: A uml::Property which has no type shall be generated as #define.
The default value of the uml::Property is the value of the #define.
REQ-PROP-002: A typped uml::Property marked as read-only shall be generated as constant ('const').
REQ-PROP-003: A uml::Property of an 'Object' class shall be generated as variables.
REQ-PROP-004: Private uml::Property of an 'Object' shall be generated as static variable in the source file.
REQ-PROP-005: Public uml::Property of an 'Object' shall be generated as extern variable in the header file.
REQ-PROP-006: The default value of the property of an 'Object' shall be generated as the initialisation of the variable.
REQ-PROP-007: In case a uml::Comment is applied to the uml::Property, Doxygen comments shall be generated.
REQ-PROP-008: In case the stereotype 'Array' is applied to a uml::Property, the uml::Property shall be generated as an Array with the specified multiplicity.
In case the uml::Multiplicity (upper bound) of the uml::Property is higher than 1 and no stereotype Array is applied on, the uml::Property shall also be generated as an Array with the specified upper value.
REQ-PROP-009: In case the stereotype 'Pointer' is applied on a uml::Property, simple or double pointer shall be generated for the given variable.
REQ-PROP-010: In case the stereotype 'Volatile' is applied on a uml::Property, the keyword 'volatile' shall be generated for the given variable.
REQ-PROP-011: In case the stereotype 'Attribute' is applied on a uml::Property, the keyword '_attribute_' shall be generated for the given variable with its value.
REQ-PROP-012: In case the stereotype 'UsesStaticMethods' is applied on a uml::Property, the variable shall be generated after the declaration of static prototype(s).
This is typically the case of static callback table where callbacks are static functions.
REQ-PROP-013: In case requirement(s) constrain(s) a uml::Property, a requirement list shall be generated.
The following requirements specify the model to text transformations for uml::Enumeration.
REQ-ENUM-001: A uml::Enumeration shall be generated as 'typedef enum'. The name of the enumeration shall be equal to the name of the uml::Enumeration.
REQ-ENUM-002: In case the stereotype 'Typedef' is applied to a uml::Enumeration, the enumeration shall be generated as a simple 'enum'. Below the the 'enum' declaration, a 'typdef' shall specify the corresponding mapped type.
REQ-ENUM-003: Inside a uml::Enumeration, a uml::EnumerationLiteral stereotyped as 'Constant' shall be generated as #define.
The property 'Declaration' of the stereotype 'Constant' is the value of the #define. The stereotype 'Constant' specifies also #define conditions (#ifdef, #ifndef, #endif).
REQ-ENUM-004: In case a comment is applied to the the uml::Enumeration or literals, Doxygen comments shall be generated.
REQ-ENUM-006: In case the stereotype 'Value' is applied to a uml::EnumerationLiteral, the value of the literal shall be forced to the value of the stereotype.
REQ-ENUM-006: In case requirement(s) constrain(s) a uml::Enumeration, a requirement list shall be generated.
The following requirements specify the model to text transformations for uml::Datatype.
REQ-DTYPE-001: A uml::Datatype shall be generated as 'typedef struct'. The id of the structure shall be the name of the uml::Datatype.
REQ-DTYPE-002: All the porperties of the uml::Datatype shall be generated as fields of the structure.
The properties are generated with their types, the multiplicity and the comment (properties may also be stereotyped as 'struct', 'Array', ...).
REQ-DTYPE-003: A uml::Datatype stereotyped as 'union' shall be generated as 'typedef union'.
REQ-DTYPE-004: A uml::Datatype stereotyped as 'typedef' shall be generated as 'typedef'.
REQ-DTYPE-005: In case the 'mapped type' property of the stereotype 'typedef' contains the string '%s', the latter shall be replaced by the name of the uml::Datatype.
REQ-DTYPE-006: For each type (structure, typedef or union), corresponding Doxygen comment shall be generated.
REQ-DTYPE-007: In case the stereotype 'struct' is applied on a property of a uml::Datatype, the keyword 'struct' shall specify the field.
REQ-DTYPE-008: In case the stereotype 'pointer' is applied on a property of a uml::Datatype, simple or double pointer shall be generated for the given field.
REQ-DTYPE-009: In case the stereotype 'Attribute' is applied on a uml::Datatype, the keyword '_attribute_' shall be generated for the given structure with its value.
REQ-DTYPE-010: In case requirement(s) constrain(s) a uml::Datatype, a requirement list shall be generated.
The following requirements specify the model to text transformations for uml::Usage.
REQ-USE-001: Private uml::Usage shall be generated as #include in the source file.
REQ-USE-002: Public uml::Usage shall be generated as #include in the header file.
REQ-USE-003: A comment shall be generated to describe the object of the uml::Usage.
The following requirements specify the model to text transformations for uml::Operation.
REQ-OPER-001: Private operation shall be generated as static function.
REQ-OPER-002: In case no parameter with the direction 'return' is specified, the signature of the function shall be 'void'.
REQ-OPER-003: In case a parameter with the direction 'return' is specified, the signature shall be the type of this parameter.
REQ-OPER-004: The name of the function shall be the name of the operation.
REQ-OPER-005: In case no parameter is found, the argument of the function shall be 'void'.
REQ-OPER-006: Each parameter owned by the operation shall be generated as argument of the function.
The type, the pointer value, the const data or const pointer. In the prototype, each argument must be separated by a comma.
REQ-OPER-007: An operation stereotyped as 'inline' shall be generated as #define.
Inline operation may have conditional declaration. The stereotype 'Inline' has several Boolean property to specify #ifdef or #ifndef conditions.
REQ-OPER-008: The parameter defined in an operation stereotyped as 'inline' shall be generated as argument of the #define.
Only the name of the parameter is generated (no type). In the prototype, each argument must be separated by a comma.
REQ-OPER-009: A protected field shall be generated for the user implementation.
This includes 'ASM' and 'Inline' operation.
REQ-OPER-010: In case the stereotype 'Pointer' is applied on a uml::Parameter, simple or double pointer shall be generated for the given argument.
This includes 'const' data or 'const' pointer.
REQ-OPER-011: In case requirement(s) constrain(s) a uml::Operation, a requirement list shall be generated.
REQ-OPER-012: Detailed comments for the function (description of the function) and for each parameters (direction, comments and type) shall be generated.