TOC PREV NEXT INDEX


Compiler Configuration File



In addition to command line options, a configuration file can be used to specify compiler options. These options can be applied not only globally but also to specific modules and productions.

A simple form of the Extended Markup Language (XML) is used to format items in the file. This language was chosen because it is fairly well known and provides a natural interface for representing hierarchical data such as the structure of ASN.1 modules and productions. The use of an external configuration file was chosen over embedding directives within the ASN.1 source itself due to the fact that ASN.1 source versions tend to change frequently. An external configuration file can be reused with a new version of an ASN.1 module, but internal directives would have to be reapplied to the new version of the ASN.1 code.

At the outer level of the markup is the <asn1config> </asn1config> tag pair. Within this tag pair, the specification of global items and modules can be made. Global items are applied to all items in all modules. An example would be the <storage> qualifier. A storage class such as dynamic can be specified and applied to all productions in all modules. This will cause dynamic storage (pointers) to be used for any embedded structures within all of the generated code to reduce memory consumption demands.

The specification of a module is done using the <module></module> tag pair. This tag pair can only be nested within the top-level <asn1config> section. The module is identified by using the required <name></name> tag pair or by specifying the name as an attribute (for example, <module name="MyModule">). Other attributes specified within the <module> section apply only to that module and not to other modules specified within the specification. A complete list of all module attributes is provided in the table at the end of this section.

The specification of an individual production is done using the <production></production> tag pair. This tag pair can only be nested within a <module> section. The production is identified by using the required <name></name> tag pair or by specifying the name as an attribute (for example, <production name="MyProd">). Other attributes within the production section apply only to the referenced production and nothing else. A complete list of attributes that can be applied to individual productions is provided in the table at the end of this section.

When an attribute is specified in more than one section, the most specific application is always used. For example, assume a <typePrefix> qualifier is used within a module specification to specify a prefix for all generated types in the module and another one is used to a specify a prefix for a single production. The production with the type prefix will be generated with the type prefix assigned to it and all other generated types will contain the type prefix assigned at the module level.

Values in the different sections can be specified in one of the following ways:


<name>H323-MESSAGES</name>


<isPDU/>


<include types="TypeName1,TypeName2,TypeName3"/>

The following are some examples of configuration specifications:

<asn1config><storage>dynamic</storage></asn1config>
 

This specification indicates dynamic storage should be used in all places where its use would result in significant memory usage savings within all modules in the specified source file.

<asn1config>
 
  <module>
 
    <name>H323-MESSAGES</name>
 
    <sourceFile>h225.asn</sourceFile>
 
    <typePrefix>H225</typePrefix>
 
  </module>
 
  ...
 
</asn1config>
 

This specification applies to module `H323-MESSAGES' in the source file being processed. For IMPORT statements involving this module, it indicates that the source file `h225.asn' should be searched for specifications. It also indicates that when C or C++ types are generated, they should be prefixed with `H225'. This can help prevent name clashes if one or more modules are involved and they contain productions with common names.

The following tables specify the list of attributes that can be applied at all of the different levels: global, module, and individual production:

Global Level

These attributes can be applied at the global level by including them within the <asn1config> section:
Name
Values
Description
<storage></storage>
 
dynamic, static, list, array, or dynamicArray keyword.
 
If dynamic, it indicates that dynamic storage (i.e., pointers) should be used everywhere within the generated types where use could result in lower memory consumption. These places include the array element for sized SEQUENCE OF/SET OF types and all alternative elements within CHOICE constructs.
 
If static, it indicates static type should be used in these places. In general, static types are easier to work with.

If list, a linked-list type will be used for SEQUENCE OF/SET OF constructs instead of an array type.
 
If array, an array type will be used for SEQUENCE OF/SET OF constructs. The maxSize attribute can be used in this case of specify the size of the array variable (for example, <storage maxSize="12"> array </storage>).
 
If dynamicArray, a dynamic array will be used for SEQUENCE OF/SET OF constructs. A dynamic array is an array that uses dynamic storage for the array elements.
 


Module Level

These attributes can be applied at the module level by including them within a <module> section:

Name
Values
Description
<name>
</name>
 
module name
This attribute identifies the module to which this section applies. It is required.
<include types="names"
values="names"/>
 
ASN.1 type or values names are specified as an attribute list
This item allows a list of ASN.1 types and/or values to be included in the generated code. By default, the compiler generates code for all types and values within a specification. This allows the user to reduce the size of the generated code base by selecting only a subset of the types/values in a specification for compilation.
 
Note that if a type or value is included that has dependent types or values (for example, the element types in a SEQUENCE, SET, or CHOICE), all of the dependent types will be automatically included as well.
 
<include importsFrom=
"name"
/>
 
ASN.1 module name(s) specified as an attribute list.
This form of the include directive tells the compiler to only include types and/or values in the generated code that are imported by the given module(s).
<exclude types="names"
values="names"/>
 
ASN.1 type or values names are specified as an attribute list
This item allows a list of ASN.1 types and/or values to be excluded in the generated code. By default, the compiler generates code for all types and values within a specification. This is generally not as useful as in include directive because most types in a specification are referenced by other types. If an attempt is made to exclude a type or value referenced by another item, the directive will be ignored.
 
<storage>
</storage>
 
dynamic, static, list, array, or dynamicArray keyword.
 
The definition is the same as for the global case except that the specified storage type will only be applied to generated C and C++ types from the given module.
 
<sourceFile>
</sourceFile>
 
source file name
Indicates the given module is contained within the given ASN.1 source file. This is used on IMPORTs to instruct the compiler where to look for imported definitions. This replaces the module.txt file used in previous versions of the compiler to accomplish this function.
 
<typePrefix>
</typePrefix>
 
prefix text
This is used to specify a prefix that will be applied to all generated C and C++ typedef names (note: for C++, the prefix is applied after the standard `ASN1T_' prefix). This can be used to prevent name clashes if multiple modules are involved in a compilation and they all contain common names.
 
<enumPrefix>
</enumPrefix>
 
prefix text
This is used to specify a prefix that will be applied to all generated enumerated identifiers within a module. This can be used to prevent name clashes if multiple modules are involved in a compilation. (note: this attribute is normally not needed for C++ enumerated identifiers because they are already wrapped in a structure to allows the type name to be used as an additional identifier).
 
<valuePrefix>
</valuePrefix>
 
prefix text
This is used to specify a prefix that will be applied to all generated value constants within a module. This can be used to prevent name clashes if multiple modules are involved that use a common name for two or more different value declarations.
 
<noPDU/>
 
n/a
Indicates that this module contains no PDU definitions. This is normally true in modules that are imported to get common type definitions (for example, InformationFramework). This will prevent the C++ version of the compiler from generating any control class definitions for the types in the module.
 
<intCType>
byte, int16, uint16, int32, uint32, int64, string
This is used to specify a specific C integer type be used for all unconstrained integer type. By default, ASN1C will use the int32 (32-bit integer) type for all unconstrained integers.
<arcCType>
int32, int64
The is used to specify a specific C integer type be used for the arc types in Object Identifier definitions. By default, int32 (32-bit integer arc values) are generated.
 
<namespace>
</namespace>
 
namespace name
This is used to specify the namespace name for the given module. By default, Asn1c compiler will use the "http://www.obj-sys.com" as the module namespace. This option should be used with XML encoding rule (XML) only. Asn1c compiler will ignore this option usage with other encoding rules.
 




Production Level

These attributes can be applied at the production level by including them within a <production> section:
Name
Values
Description
<name>
</name>
 
module name
This attribute identifies the module to which this section applies. It is required.
<ctype>
byte, int16, uint16, int32, uint32, int64, string
This is used to specify a specific C integer type be used in place of the default integer definition generated by ASN1C. In general, ASN1C will try and use the smallest integer type available based on the value or value range constraint on the integer type. If the integer is not constrained, the int32 (32-bit integer) type will be used.
 
<storage>
</storage>
 
dynamic, static, list, array, or dynamicArray keyword.
 
The definition is the same as for the global case except that the specified storage type will only be applied to the generated C or C++ type for the given production.
 
<typePrefix>
</typePrefix>
 
prefix text
This is used to specify a prefix that will be applied to all generated C and C++ typedef names (note: for C++, the prefix is applied after the standard `ASN1T_' prefix). This can be used to prevent name clashes if multiple modules are involved in a compilation and they all contain common names.
 
<enumPrefix>
</enumPrefix>
 
prefix text
This is used to specify a prefix that will be applied to all generated enumerated identifiers within a module. This can be used to prevent name clashes if multiple modules are involved in a compilation. (note: this attribute is normally not needed for C++ enumerated identifiers because they are already wrapped in a structure to allows the type name to be used as an additional identifier).
 
<isBigInteger/>
 
n/a
This is a flag variable (an `empty element' in XML terminology) that specifies that this production will be used to store an integer larger than the C or C++ int type on the given system (normally 32 bits). A C string type (char*) will be used to hold a textual representation of the value.
 
This qualifier can be applied to either an integer or constructed type. If constructed, all integer elements within the constructed type are flagged as big integers.
 
<isPDU/>
 
n/a
This is a flag variable that specifies that this production represents a Protocol Data Unit (PDU). This is defined as a production that will be encoded or decoded from within the application code. This attribute only makes a difference in the generation of C++ classes. Control classes that are only used in the application code are only generated for types with this attribute set.
 


Element Level

These attributes can be applied at the element level by including them within an <element> section:
Name
Values
Description
<name>
</name>
 
element name
This attribute identifies the element within a SEQUENCE, SET, or CHOICE construct to which this section applies. It is required.
<isOpenType/>
n/a
This is a flag variable (an `empty element' in XML terminology) that specifies that this element will be decoded as an open type (i.e. skipped). Refer to the section on deferred decoding for further information.
 





Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX