Package mapping for generating Ada 95 (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.
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.
• If the Package is stereotyped by the «Ada Generic Instance» stereotype, ACS generates an instantiated generic package. The «Ada Generic Instance» stereotype applies three Tag Definitions:
◦ The tagged value of the Ada Generic Parameters tag definition is generated as the parameters of the instantiated generic package.
◦ If the associated generic package is modeled in the Model, the tagged value of the Ada Generic Parent tag definition identifies the Package, Class or Data Type that is generated as the associated generic package.
◦ If the associated generic package is not modeled in the Model, the tagged value of the Ada Generic Parent Text tag definition specifies the name of the associated generic package.
• 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 retrieve the location of generated or reverse engineered files from the registry. In Modeler, this information is used to populate the files listed on the Open Ada File context submenu for a Package.
|
Examples
The following examples are provided:
• Folder Packages
• 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;