The $declare ${<model-item>} directive requests generating a declaration of the <model-item> specified between the parentheses. QM can generate declarations for the following item types:
In C, the directive $declare ${<Class>} generates the C "class" declaration, which consists of a C struct with all the attributes of the class and associated C functions for all the operations (see also Key Concept: Object-Oriented Programming in C↑).
If the $declare ${<Class>} directive is used in a file scope (inside a .c file), the declaration generates function prototypes with the static keyword, as shown in the code generated by the directive $declare ${AOs::Ship} for the class Ship shown in the screen shot above:
In C++, the directive $declare ${<class>} generates the C++ class declaration. For example, the code snippet below shows the code generated by the directive $declare ${AOs::Ship} for the class AOs::Ship shown in the screen shot above:
Free attribute is an attribute (variable) declared in a package outside of any class. The $declare ${<free-attribute>} directive requests generating a declaration of the <free-attribute> specified between the parentheses.
The following code snippet shows the C code generated by the $declare ${AOs::AO_Ship} code-generation directive:
The following code snippet shows the C++ code generated by the $declare ${AOs::AO_Ship} code-generation directive. Please note the C++ namespace generated around the variable. This is because the enclosing package AOs provide the namespace GAME:
Free operation is an operation (function) declared in a package outside of any class. The $declare ${<free-opeation>}> directive requests generating a declaration of the <free-operation> specified between the parentheses.
The following code snippet shows the C code generated by the $declare ${AOs::do_bitmaps_overlap} code-generation directive:
The following code snippet shows the C++ code generated by the $declare ${AOs::do_bitmaps_overlap} code-generation directive. Please note the C++ namespace generated around the function. This is because the enclosing package AOs provides the namespace GAME:
The $declare ${<package>} directive requests generating a recursive declaration of all classes, free attributes, and free operations in the <package>, as described in the sections above. If a package contains other packages, these packages are recursively declared, as described in the first sentence.