next up previous contents index
Next: 2.13 Module reference Up: 2.12 Class reference Previous: 2.12.2 mclass   Contents   Index


2.12.3 module

The module class works in conjunction with the mclass class to encapsulate loaded modules. Each loaded module has a corresponding module instance, which can be used to query, configure, or unload modules.

Table 2.14: module summary
Input(s)
Method
Output(s)
Description
Class-context methods
-
new
instance
Constructor.
Instance-context methods
-
version_get
version
Get module version.
version
version_set
-
Set module version.
-
deps_get
deps
Get module dependencies.
-
mdefs_get
mdefs
Get module definitions.
defname defval defdict
mdef
-
Create module definition defname as defval in defdict.
depname
dep_load
-
Load a dependency module.
hook
pre_unload_hook_set
-
Store pre-unload hook.
hook
post_unload_hook_set
-
Store post-unload hook.
-
unload
-
Unload module.

depname dep_load -:
Input(s):
depname:
The name of a module that this module depends on.
Output(s):
None.
Error(s):
invalidfileaccess.
ioerror.
limitcheck.
rangecheck.
stackunderflow.
typecheck.
undefinedfilename.
Description:
Load the module named depname, and record that this module depends on it.
Example(s):
modfoo/modfoo.nx:


$modclopt ;dep_load

$foo `foo' systemdict ;mdef


onyx:0> mclass:singleton:modules 1 sprint
<$modprompt -instance=$module- $modclopt -instance=$module->
onyx:0> $modfoo mclass:singleton:load
onyx:0> mclass:singleton:modules 1 sprint
<$modprompt -instance=$module- $modclopt -instance=$module-
$modfoo -instance=$module->
onyx:0> 

- deps_get deps:
Input(s):
None.
Output(s):
deps:
A dictionary of module names associated with module instances.
Error(s):
None.
Description:
Get a dictionary of modules that this module depends on.
Example(s):
onyx:0> $modclopt mclass:singleton:load
onyx:0> modclopt:deps_get 1 sprint
<>
onyx:0>
- mdefs_get mdefs:
Input(s):
None.
Output(s):
mdefs:
A dictionary of array keys, associated with the dictionaries in which the definitions reside. Each array key is a tuple; the first array element is the definition key, and the second array element is the definition value.
Error(s):
None.
Description:
Get a dictionary of definitions associated with this module.
Example(s):
onyx:0> $modclopt mclass:singleton:load
onyx:0> modclopt:mdefs_get 2 sprint
<[$clopt -class=$clopt-] <$modprompt -instance=$module- $clopt -class=$clopt-
$modclopt -instance=$module-> [$modclopt -instance=$module-] <$modprompt
-instance=$module- $clopt -class=$clopt- $modclopt -instance=$module->>
onyx:0>
defname defval mdef -:
Input(s):
defname:
A definition key.
defval:
A value to be associated with defname.
defdict:
A dictionary in which to define defname as defval.
Output(s):
None.
Error(s):
typecheck.
Description:
Define defname as defval in defdict.
Example(s):
modfoo/modfoo.nx:


$modclopt ;dep_load

$foo `foo' systemdict ;mdef


onyx:0> $modfoo mclass:singleton:load
onyx:0> foo 1 sprint
`foo'
onyx:0> 

- new instance:
Input(s):
None.
Output(s):
instance:
An instance of class.
Error(s):
typecheck.
Description:
Constructor.
Example(s):
onyx:0> module:new 1 sprint
-instance-
onyx:0>
hook post_unload_hook_set -:
Input(s):
hook:
An object to evaluate after unloading this module.
Output(s):
None.
Error(s):
stackunderflow.
Description:
Register a post-unload hook, which is evaluated after this module is unloaded.
Example(s):
onyx:0> $modclopt mclass:singleton:load
onyx:0> {`Post-unload' 1 sprint} modclopt:post_unload_hook_set
onyx:0> modclopt:unload
`Post-unload'
onyx:0>
hook pre_unload_hook_set -:
Input(s):
hook:
An object to evaluate before unloading this module.
Output(s):
None.
Error(s):
stackunderflow.
Description:
Register a pre-unload hook, which is evaluated before this module is unloaded.
Example(s):
onyx:0> {`Pre-unload' 1 sprint} modclopt:pre_unload_hook_set
onyx:0> modclopt:unload
`Pre-unload'
onyx:0>
- unload -:
Input(s):
None.
Output(s):
None.
Error(s):
None, except errors caused by the evaluation of the pre- and post-unload hooks.
Description:
Unload this module.
Example(s):
onyx:0> $modclopt mclass:singleton:load
onyx:0> modclopt:unload
onyx:0>
- version_get version:
Input(s):
None.
Output(s):
version:
The version of this module.
Error(s):
None.
Description:
Get the version of this module.
Example(s):
onyx:0> $modclopt mclass:singleton:load
onyx:0> modclopt:version_get 1 sprint
0
onyx:0>
version version_set -:
Input(s):
version:
The version of this module.
Output(s):
None.
Error(s):
stackunderflow.
Description:
Example(s):
onyx:0> $modclopt mclass:singleton:load
onyx:0> modclopt:version_get 1 sprint
0
onyx:0> 1 modclopt:version_set
onyx:0> modclopt:version_get 1 sprint
1
onyx:0>


next up previous contents index
Next: 2.13 Module reference Up: 2.12 Class reference Previous: 2.12.2 mclass   Contents   Index
Jason Evans 2005-03-16