PACKAGECOMMANDS::pluginmgrobjectName ?optionvalue...?
This command creates a new plugin manager object with an associated Tcl command whose name is
objectName. This object command is explained in full detail in the sections OBJECTCOMMAND and
OBJECTMETHODS. The object command will be created under the current namespace if the objectName
is not fully qualified, and in the specified namespace otherwise.
The options and their values coming after the name of the object are used to set the initial
configuration of the mamager object, specifying the applicable plugins and their API.
::pluginmgr::pathsobjectNamename...
This utility command adds a set of paths to the specified object, based on the given names. It
will search for:
[1] The environment variable name_PLUGINS. Its contents will be interpreted as a list of
package paths. The entries have to be separated by either : (unix) or ; (windows).
The name will be converted to upper-case letters.
[2] The registry entry "HKEY_LOCAL_MACHINE\SOFTWARE\name\PLUGINS". Its contents will be
interpreted as a list of package paths. The entries have to be separated by ;. This item is
considered only when on Windows (tm).
The casing of letters is not changed.
[3] The registry entry "HKEY_CURRENT_USER\SOFTWARE\name\PLUGINS". Its contents will be
interpreted as a list of package paths. The entries have to be separated by ;. This item is
considered only when on Windows (tm).
The casing of letters is not changed.
[4] The directory "~/.name/plugin".
[5] The directory "~/.name/plugins".
The casing of letters is not changed.
and add all the paths found that way to the list of package paths maintained by the object.
If name is namespaced each item in the list will be repeated per prefix of name, with conversion of
:-sequences into the proper separator (underscore for environment variables, backslash for registry
entries, and / for directories).
Examples:
::pluginmgr::paths ::obj docidx
=> env DOCIDX_PLUGINS
reg HKEY_LOCAL_MACHINE\SOFTWARE\docidx\PLUGINS
reg HKEY_CURRENT_USER\SOFTWARE\docidx\PLUGINS
path ~/.docidx/plugins
::pluginmgr::paths ::obj doctools::idx
=> env DOCTOOLS_PLUGINS
env DOCTOOLS_IDX_PLUGINS
reg HKEY_LOCAL_MACHINE\SOFTWARE\doctools\PLUGINS
reg HKEY_LOCAL_MACHINE\SOFTWARE\doctools\idx\PLUGINS
reg HKEY_CURRENT_USER\SOFTWARE\doctools\PLUGINS
reg HKEY_CURRENT_USER\SOFTWARE\doctools\idx\PLUGINS
path ~/.doctools/plugin
path ~/.doctools/idx/pluginOBJECTCOMMAND
All commands created by the command ::pluginmgr (See section PACKAGECOMMANDS) have the following general
form and may be used to invoke various operations on their plugin manager object.
objectNamemethod ?argarg...?
The method method and its arg'uments determine the exact behavior of the command. See section
OBJECTMETHODS for the detailed specifications.
OBJECTMETHODSobjectNameclone
This method creates a new plugin management object and returns the associated object command. The
generated object is a clone of the object the method was invoked on. I.e. the new object will have
the same configuration as the current object. With regard to state, if the current object has a
plugin loaded then this plugin and all associated state is moved to the generated clone and the
current object is reset into the base state (no plugin loaded). In this manner a configured plugin
manager is also a factory for loaded plugins.
objectNameconfigure
The method returns a list of all known options and their current values when called without any
arguments.
objectNameconfigureoption
The method behaves like the method cget when called with a single argument and returns the value
of the option specified by said argument.
objectNameconfigure-optionvalue...
The method reconfigures the specified options of the object, setting them to the associated
values, when called with an even number of arguments, at least two.
The legal options are described in the section OBJECTCONFIGURATION.
objectNamecget-option
This method expects a legal configuration option as argument and will return the current value of
that option for the object the method was invoked for.
The legal configuration options are described in section OBJECTCONFIGURATION.
objectNamedestroy
This method destroys the object it is invoked for.
objectNamedoarg...
This method interprets its list of arguments as the words of a command and invokes this command in
the execution context of the plugin. The result of the invoked command is made the result of the
method. The call will fail with an error if no valid plugin has been loaded into the manager
object.
objectNameinterpreter
This method returns the handle of the safe interpreter the current plugin is loaded into. An empty
string as return value signals that the manager currently has no valid plugin loaded.
objectNameplugin
This method returns the name of the plugin currently loaded. An empty string as return value
signals that the manager currently has no valid plugin loaded.
objectNameloadstring
This method loads, validates, and initializes a named plugin into the manager object.
The algorithm to locate and load the plugin employed is:
[1] If the string contains the path to an existing file then this file is taken as the
implementation of the plugin.
[2] Otherwise the plugin name is translated into a package name via the value of the option
-pattern and then loaded through the regular package management.
[3] The load fails.
The algorithm to validate and initialize the loaded code is:
[1] If the option -api is non-empty introspection commands are used to ascertain that the
plugin provides the listed commands.
[2] If the option -check is non-empty the specified command prefix is called.
[3] If either of the above fails the candidate plugin is unloaded again
[4] Otherwise all the commands specified via the option -cmds are installed in the plugin.
A previously loaded plugin is discarded, but only if the new plugin was found and sucessfully validated
and initialized. Note that there will be no intereference between old and new plugin as both will be put
into separate safe interpreters.
objectNameunload
This method unloads the currently loaded plugin. It returns the empty string. The call will be
silently ignored if no plugin is loaded at all.
objectNamelist
This method uses the contents of the option -pattern to find all packages which can be plugins
under the purview of this manager object. It translates their names into plugin names and returns
a list containing them.
objectNamepathpath
This methods adds the specified path to the list of additional package paths to look at when
searching for a plugin. It returns the empty string. Duplicate paths are ignored, i.e. each path
is added only once. Paths are made absolute, but are not normalized.
objectNamepaths
This method returns a list containing all additional paths which have been added to the plugin
manager object since its creation.
OBJECTCONFIGURATION
All plugin manager objects understand the following configuration options:
-patternstring
The value of this option is a glob pattern which has to contain exactly one '*'-operator. All
packages whose names match this pattern are the plugins recognized by the manager object. And vice
versa, the replacement of the '*'-operator with a plugin name will yield the name of the package
implementing that plugin.
This option has no default, except if option -name was set. It has to be set before attempting to
load a plugin, either directly, or through option -name.
-apilist
The value of this option is a list of command names, and any plugin loaded has to provide these
commands. Names which are not fully qualified are considered to be rooted in the global namespace.
If empty no expectations are made on the plugin. The default value is the empty list.
-checkcmdprefix
The value of this option is interpreted as a command prefix. Its purpose is to perform complex
checks on a loaded plugin package to validate it, which go beyond a simple list of provided
commands.
It is called with the manager object command as the only argument and has to return a boolean
value. A value of true will be interpreted to mean that the candidate plugin passed the test. The
call will happen if and only if the candidate plugin already passed the basic API check specified
through the option -api.
The default value is the empty list, which causes the manager object to suppress the call and to
assume the candidate plugin passes.
-cmdsdict
The value of this option is a dictionary. It specifies the commands which will be made available
to the plugin (as keys), and the trusted commands in the environment which implement them (as
values). The trusted commands will be executed in the interpreter specified by the option -cmdip.
The default value is the empty dictionary.
-cmdipipspec
The value of this option is the path of the interpreter where the trusted commands given to the
plugin will be executed in. The default is the empty string, referring to the current
interpreter.
-setupcmdprefix
The value of this option is interpreted as a command prefix.
It is called whenever a new safe interpreter for a plugin has been created, but before a plugin is
loaded. It is provided with the manager object command and the interpreter handle as its only
arguments. Any return value will be ignored.
Its purpose is give a user of the plugin management the ability to define commands, packages, etc.
a chosen plugin may need while being loaded.