Package mapping for generating SPARK 83 (Ada code)
For each Package, ACS generates a folder or an Ada package:
If a Package's Mapping property is set to Folder and that Package contains items that have been selected for generation, ACS generates a subfolder of the working folder for the Package.
If the Package's Mapping property is set to Namespace, ACS generates an Ada package (package specification file and a package body file). The package is a logically nested child package of a containing namespace package if one exists. Namespace packages are generated only if they contain at least one Attribute, Class, Data Type, Exception, Operation or Type Definition.
ACS typically generates a package specification file and a package body file for a namespace Package, even if the package body file is not required. To prevent ACS from generating a package body file that is not required for a namespace Package, apply the «Ada Source» to the Package, and then set the tagged value of the Ada Requires Body tag definition to FALSE.
If you want Package members to be generated in a specific order, apply the «Ada Source» stereotype to the Package 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 Package's members through the Ada Generation Order tag definition, see Specifying the generation order of model, package, class or data type members (Ada code).
The generation of a Package is derived from the properties of the Package and the tagged values set for Tag Definitions that are applied to it:
If the Package 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 Package is stereotyped by the «Ada Context» stereotype, ACS can generate with and 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 Model. 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 Package.
The tagged value of the Ada_Implementation_Dependencies tag definition is generated in the package body created for the Package.
For more information about modeling dependencies to packages in the Model, see Modeling with, use and use type clauses in Modeler (Ada code).
If the Package 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 Package 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 Package is stereotyped by the «Ada Renames» stereotype, the Package 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 item.
If the Package is stereotyped by the «Ada Representation» stereotype, the tagged value of the Ada Representation Text tag definition (applied by the «Ada Representation» stereotype) is used to generate the representation clauses.
If the Package 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 Package is stereotyped by the «Ada Source»stereotype, the tagged value of the Ada Library Unit tag 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 Package, 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 or Data Type.
The «Ada Generic» and «Ada Generic Instance» stereotypes are ignored.
Examples
Examples are provided for folder and namespace Packages.
Folder Packages
Package1 is a folder Package.
If you generate Class1, ACS creates a subfolder in the working folder for Package1.
Namespace Packages
Package2 and Package3 are both namespace Packages. Package3 owns an Attribute named Attribute1.
If you generate Package3, ACS creates a package specification file named Package2_Package3.ads. The package specification file contains the following text.
package Package2_Package3 is
-- public attributes
Attribute1 : Integer;
end Package2_Package3;
Was this helpful?