Menu

Modules

Will Pittenger

Overview

Those of you that remember Turbo Pascal may remember that it had a module system that let you expose functionality to other modules. These days, .NET executables and Java JARs have something similar. Essentially, a module was a fully compiled library with an internal semi-compiled list of publicly declared types. That's what an ASIL module is.

Like with ASIL namespaces, a module is declared with either a module XML file or an XML element inside your makefile. If you pick a separate file, use the same name as your executable or library, only with the extension ".asil-module". Also like namespaces in ASIL, modules can derive from one another.

Valid elements

The table below lists the valid elements inside a module file.

Element Parent Valid children Valid attributes Details
<module> N/A <base>, <namespace> name, final (optional), version, main-script (DASIL only), main-type (see notes on use) Root element! The name attribute should be the full name of the module, but without the filename extension. The final attribute, if present, prevents other modules from deriving from this module. The version attribute lists the version number of this module. It will be compared with the min-version and max-version attributes of any modules that declare a dependency on this module with the <depends-on> element. The main-script attribute is required if you expect to run this module as a DASIL script. If you don't use main-script, you must use main-type to make the module executable. main-type must be a fully qualified type name with declares a valid main function as described in SASIL.
<base> <module> none name Specifies the module that this module is based on. The name attribute should be the name given in its module declaration file. List each module you need to derive from with its own <base> entry.
<namespace> <module> none name, no-child-namespaces (optional) Specifies a namespace that will be part of this module. Use the name attribute to specify the fully qualified name of the namespace you want to include. Including a namespace includes everything inside it. If you need to break a namespace up into several modules, list the namespaces inside it, not the parent namespace! If there are no child namespaces, you may need to break the namespace up. Use of the optional no-child-namespaces attribute causes the compiler to include the types declared directly inside the specified namespace and nothing from that namespace's child namespaces.
<depends-on> <module> none name, min-version, max-version Lists the name of a module that his module depends on. The name attribute should match the name given for the module you're declaring a dependency on. The min-version and max-version attributes will be compared with the version given in the copy of the module that was found.

Note: All version attributes, if not the entire declaration file, should be present inside the module's executable or binary file.

Deriving from modules in other projects

Like with namespaces, it's considered poor form to derive from a module in another project.

The module registration system

We need to avoid the situation where either a user or code is forced to find a module (or its source code) with Google, Yahoo, Bing, etc. Rather, it's hoped that a portion of this site will be dedicated to listing known trusted modules and a way to download them and/or their source code. The actual module won't be stored on the site; just the URL where it can be downloaded from.

Modules and DASIL

If you're module will contain only DASIL scripts, the tool that creates the module could be able to make the module as only a compressed package of obfuscated scripts files. When you make a module containing DASIL scripts and you want to make the module executable such that it runs one of the scripts, you need to specify the main-script attribute on the <module> element. It must be in the format "namespace@identifier". The "namespace" part must be a namespace included in this module (not a base namespace or module). The "identifier" part must be the ASIL identifier you listed in the namespace for the script you want to run when the module is executed. The script must be declared as public by the namespace.

Note: If you specify main-script, you're module won't run directly any SASIL code—even if it contains a main procedure somewhere. Furthermore, the main-script and main-type attributes are mutually exclusive. Use one other the other—not both.


Related

Wiki: Derivatives-DASIL
Wiki: Derivatives-SASIL
Wiki: Home
Wiki: Namespaces