The cmdx command is used to manage
Tcl
command extensions.
Cactvs
Tcl
command extensions are an upward-compatible extension to standard
Tcl
packages. It is possible to load them by means of the standard
Tcl
commands
load
or
package require
, but if loaded in that fashion, the additional metadata and attributes are not accessible.
This command is not supported in the Python interface.
The following subcommands exist:
cmdx defined cmd
Check whether a module for the specified command is either already loaded, or available. If a module can be found, and it not yet loaded, it is automatically loaded.
The return value is a boolean status code. No error is generated when the command cannot be resolved to a module.
cmdx exists cmd
Check whether a module for the specified command is already loaded. No attempt is made to auto-load a module if it is not already loaded.
The return value is a boolean status code. No error is generated when the command cannot be resolved to a module.
cmdx get cmd attribute
cmdx get missed
Query the value of an attribute of the extension module. Tcl command extension modules are static. There are no
cmdx create
or
cmdx set
commands to define command extensions in a script, or to modify the attribute set of a module. The following attributes can be queried:
The second variant with the missed special command name lists all commands which could not be resolved via load subcommands - which could have occurred implicitly via the standard (but extended to include
cmdx load
attempts)
Tcl
external command executable lookup function. The
cmdx
command maintains a cache of such misses in order to avoid searching the command extension path repeatedly, which can generate significant network traffic if this happens frequently. On the other hand, it also means that it is not possible to supply a
cmdx
module late during a script run when a command load attempt has already failed.
cmdx list ?pattern?
Get a list of all currently loaded Cactvs Tcl command extensions. This list does not include standard Tcl extensions. If desired, the list can be filtered by a string match pattern.
cmdx load cmd ?objectfile?
Explicitly load a command extension module. If the module is already loaded, the current version is unloaded first. If no specific object file (a shared library on Unix/Linux, a DLL on Windows, a bundle file for MacOSX) is specified, the standard name of the module file is automatically generated from the data type name, and then the file searched in the directories in the data type handler module path. The module path can be customized in the control variable ::cactvs(cmdxpath) .
After loading, the
cmd
command is available in the interpreter which executed the script command. It is essentially indistinguishable from built-in commands. Command extensions are global and automatically available both in
Tcl
slave interpreters (for scripted property computations) and forked threading
Tcl
interpreters, provided that these interpreters are created after the extension has been loaded into the main interpreter. Pre-existing interpreters of these types do not retroactively obtain access to the command when it is loaded into the main interpreter. Loading extensions directly into slave interpreters or thread interpreters is not possible, because these do not support the
cmdx
command. Because of these complications, command extensions should preferably be loaded at the very beginning of a script, before threads are forked or property slave interpreters are instantiated.
The return value of the command is the slot in the command extension table the module has been loaded into.
cmdx unload ?cmd?..
Unload one or more Tcl extension modules. It is an error to specify the name of a module which is not loaded. It is not advisable to unload a command extension which has already been exported to slave or thread interpreters, because this can lead to crashes if these interpreters attempt to use the extension after it has been unloaded.