next up previous contents
Next: XML Repositories Up: SIDL Files Previous: Comments and Doc-Comments   Contents

Packages, Versions, and Import

!!!FIXME!!! This section needs to be brought up-to-date now that we have revised versioning (which includes import and require statements) and introduced re-entrant package support.

WARNING:This section explains issues that are commonly misunderstood and misused. Please read this whole section carefully.


SIDL has both a packaging and versioning mechanism built in. Packages are essentially named scopes, serving a similar function as Java packages or C++ namespaces. Versions are decimal separated integer values where it is assumed larger numbers imply more recent versions.

The outtermost SIDL package has a version number assigned to it. By default that version is 0. All classes and interfaces in that package get that same version number. If subpackages are specified, they can have their own version number assigned.

users_guide/basics/code/package1.sidl This SIDL file represents the minimum needed for each and every SIDL file. The package statement defines a scope where all classes within the package must reside. Since no version clause is included, the version number defaults to 0.

Packages can be nested. This is shown in the example below. The version numbers assigned to all the types is determined by the package, or subpackage, in which it resides. In the design of the SIDL file, remember that some languages get very long function names from excessively nested packages or excessively long package names. users_guide/basics/code/package2.sidl

Advanced:There is a bug/feature in Babel which allows sub-packages to be broken into separate files, but you'd still have to run Babel on all the files at the same time. Here's how it works.

First define the outtermost package in a file. users_guide/basics/code/package3a.sidl

Then define a sub-package in a second file. users_guide/basics/code/package3b.sidl

Note that both files begin with the identical version statement. Now as long as you run Babel on both SIDL files at the same time (with the outtermost one first on the commandline), all is fine.

This works because the package statement takes a scoped identifier as an argument. As long as Babel knows that a package mypkg exists, it can handle a new package called subpkg. Version statements require an identifier for the outtermost package. Since packages cannot have dots ``.'' in their names, the only dots in version statements should appear at the numbers, not the package names.

Running the second file without the first will (and should) generate an error since the enclosing package was not declared. Use of this bug/feature should be used judiciously.

External types can be expressed in one of two ways. The fully scoped external type can be used anywhere in the class description. Alternatively, an import statement can be used to put the type in the local package-space. Below is a sample SIDL file, that should help bring all of these concepts together.

users_guide/basics/code/package5.sidl


next up previous contents
Next: XML Repositories Up: SIDL Files Previous: Comments and Doc-Comments   Contents


babel-0.8.0
users_guide Last Modified 2003-01-14

http://www.llnl.gov/CASC/components
components@llnl.gov