Qore Programming Language 1.14.0
|
To develop a Qore module, several functions and several global variables must be declared in the module with public visibility so the module can be initialized and used by the Qore library.
The global variables are as follows:
qore_module_name
[] - must give the name of the feature provided by the module.qore_module_version
[] - must give the version of the moduleqore_module_description
[] - a description of the moduleqore_module_author
[] - the author of the moduleqore_module_url
[] - a URL for the moduleqore_module_api_major
- must be assigned to QORE_MODULE_API_MAJORqore_module_api_minor
- must be assigned to QORE_MODULE_API_MINORqore_module_license
- must be assigned to either QL_GPL or QL_LGPL according to the license the module requires; if the module links with GPL code, then QL_GPL must be used; otherwise if it is compatible with the LGPL then QL_LGPL must be usedThe functions are as follows:
qore_module_init
- the module initialization functionqore_module_ns_init
- the module namespace delta functionsqore_module_delete
- the module deletion functionHere is an example:
Note that the module name (or the module's feature name) as given by qore_module_name
is used to uniquely identify the feature provided by the module. Therefore if a module is loaded that provides feature "widget" and another module also claims to provided feature "widget", the second module cannot be loaded in the Qore library after the first has been loaded due to the duplicate feature name.
The qore_module_api_major
and qore_module_api_minor
variables are used to determine if the module corresponds to the API (and ABI) of the Qore library trying to load it.
The module initialization function qore_module_init()
will be run when the module is loaded by the Qore library. If any errors occur when initializing the module, a description should be returned as a QoreString pointer (the library will own the pointer and delete it later). If a non-zero pointer is returned by the qore_module_init()
function, the feature will not be added to the Qore library and the module load will fail.
If the module provides any namespaces, classes or constants, they will be added on demand to QoreProgram objects by calling the module's qore_module_ns_init()
function. In this case, the namespace additions should be initialized in the qore_module_init()
function and copies should be provisioned in the qore_module_ns_init()
function. In particular classes must not be created more than once, because a Qore class gets a unique ID assigned when it is created, and this ID must be unique in the entire Qore library.
Here are example functions from the ncurses module: