Class mapping for generating SPARK 83 (Ada code)
For each Class, ACS generates an Ada package, record type or variant record type:
• If the Class is not stereotyped by either an «Ada Record» or «Ada Variant Record» stereotype, ACS generates an Ada package (package specification file and a package body file).
• If the Class is stereotyped by the «Ada Record» or «Ada Variant Record» stereotype, ACS generates an Ada record type or variant record type.
|
If the Class is stereotyped by the «Ada Task» stereotype, ACS ignores the Class.
|
In each case, the Class' Visibility property determines where the Ada package or record type is declared:
• If the Class' Visibility property is set to Public or Package, the Ada package or record type is declared in the public part of the parent Ada package specification.
• If the Class' Visibility property is set to Protected, the Ada package or record type is declared in the private region of the Ada package specification.
• If the Class' Visibility property is set to Private, the Ada package or record type is declared in the parent Ada package body.
The following properties of a Class are ignored:
• Abstract
• Persistent
• Template
• Template Specialization
• Union
ACS typically generates a package specification file and a package body file for a Class, even if the package body file is not required. To prevent ACS from generating a package body file that is not required for a Class, apply the «Ada Source» to the Class, and then set the tagged value of the Ada Requires Body tag definition to FALSE.
Ada package generation
The package is a logically nested child package of the containing namespace Package, Class or Data Type if one exists. For more information about setting up Packages in Modeler, see
Setting up a package as a namespace
The package specification and body files are derived from the properties of the Class, and the Stereotypes and Tag Definitions that are applied to the Class:
• If the Class contains on-instance attributes, inherited data members or composite aggregations, the package specification declares a record type, called Object.
If you want Class members to be generated in a specific order, apply the
«Ada Source» stereotype to the Class and then use the
Ada Generation Order tag definition to order the members in the required order. Within the appropriate part of a generated file, members referenced through the Ada Generation Order tag definition are ordered accordingly and are generated before members that are not referenced by the Ada Generation Order tag definition. For more information about ordering a Class' members through the Ada Generation Order tag definition, see
Specifying the generation order of model, package, class or data type members (Ada code).
• If the Class owns an Operation that is stereotyped by the «Ada Create» stereotype, ACS generates the body of the Operation as the body code of the Ada Package.
• If the Class is linked to a Package, Class or Data Type through a Dependency, ACS generates a with or use clause for the package created for the associated Package, Class or Data Type, unless the Dependency is stereotyped by the «Ada Ignore» stereotype.
• If the Class is stereotyped by the «Ada Context» stereotype, ACS can generate with or use clauses to packages that are not modeled in the Model, or use type clauses to packages that are or are not modeled in the Modeler. The «Ada Context» stereotype applies the Ada_Declaration_Dependencies and Ada_Implementation_Dependencies tag definitions:
◦ The tagged value of the Ada_Declaration_Dependencies tag definition is generated in the package specification created for the Class.
◦ The tagged value of the Ada_Implementation_Dependencies tag definition is generated in the package body created for the Class.
• If the Class is stereotyped by the «Ada Renames» stereotype, the Class is generated as a renames declaration.
◦ If the Ada Rename Target Text tag definition (applied by the «Ada Renames» stereotype) specifies the name of a target Ada package, the renames declaration renames the specified Ada package.
◦ If the Ada Rename Target Text tag definition is blank and the Ada Rename Target tag definition (applied by the «Ada Renames» stereotype) references a Class or Data Type in the Model, the renames declaration renames the Ada package that is generated from the referenced Package, Class or Data Type.
• If the Class is stereotyped by the «Ada Pragma» stereotype, the tagged value of the Ada Pragma Text tag definition (applied by the «Ada Pragma» stereotype) is used to generate the pragmas.
• If the Class is stereotyped by the «Ada Configuration Pragma» stereotype, the tagged value of the Ada Configuration Pragma Text tag definition (applied by the «Ada Configuration Pragma» stereotype) is used to generate file scoped pragmas.
• If the Class is stereotyped by the «Ada Separate»stereotype, ACS generates the body of the package in a separate file. A body stub is generated in the parent package body.
The tagged value of the Ada Parent Subprogram tag definition (applied by the «Ada Separate» stereotype) specifies which subprogram owns the separate.
• If the Class is stereotyped by the «Ada Source»stereotype, the tagged value of the Ada Library Unittag definition determines whether the package is generated in its own file (set to TRUE) or nested inside its parent (set to FALSE). If the «Ada Separate» stereotype is applied to the Class, the Ada Library Unit tag definition is ignored.
|
ACS uses the tagged values of the Ada_Spec and Ada_Body tag definitions (applied by the «Ada Source» stereotype) to record the location of the associated package specification and body files. In Modeler, this information is used to populate the files listed on the Open Ada File context submenu for a Class.
|
Ada record type and variant record type generation
For information setting up record types and variant record types in Modeler, click here
The record type is derived from the properties of the Class, and the Stereotypes and Tag Definitions that are applied to the Class:
• If the Class is stereotyped by the «Ada Pragma» stereotype, the tagged value of the Ada Pragma Text tag definition (applied by the «Ada Pragma» stereotype) is used to generate the pragmas.
• If the Class is stereotyped by the «Ada Private» stereotype, ACS generates the record type with the 'private' keyword. If the tagged value of the Ada Limited tag definition (applied by the «Ada Private» stereotype) is set to TRUE, ACS generates the type with the 'limited private' keywords.
• If the Class is stereotyped by the «Ada Representation» stereotype, the generated type includes a representation clause. The tagged value of the Ada Representation Text tag definition is used to generate the representation clauses.
• If the Class is stereotyped by the «Ada Separate»stereotype, ACS generates the body of the record type in a separate file. A body stub is generated in the parent package body.
The tagged value of the Ada Parent Subprogram tag definition (applied by the «Ada Separate» stereotype) specifies which subprogram owns the separate.
• If the Class owns an Attribute that is stereotyped by the «Ada Variant» stereotype, ACS generates the component of the record as a variant for the variant record type. The value of the Ada Case tag definition (applied by the «Ada Variant» stereotype) is generated as the variant text.
If you want Class members to be generated in a specific order, apply the
«Ada Source» stereotype to the Class and then use the
Ada Generation Order tag definition to order the members in the required order. Within the appropriate part of a generated file, members referenced through the Ada Generation Order tag definition are ordered accordingly and are generated before members that are not referenced by the Ada Generation Order tag definition. For more information about ordering a Class' members through the Ada Generation Order tag definition, see
Specifying the generation order of model, package, class or data type members (Ada code).