An accessor host for small embedded systems that uses the Duktape JavaScript interpreter.
- Version:
- $$Id$$
- Source:
Members
(inner) accessorPath
Module variable giving the paths to search for accessors. By default this module assumes that accessors are stored in dirname/../.., where dirname is the directory where this script is located.
Methods
(inner) getAccessorCode(name)
Return the source code for an accessor from its fully qualified name. This will throw an exception if there is no such accessor on the accessor search path.
Parameters:
Name | Type | Description |
---|---|---|
name |
Fully qualified accessor name, e.g. 'net/REST'. |
(inner) getHostName()
Return the name of this host.
Return the string "Duktape".
Returns:
In duktapeHost.js, return "Duktape".
(inner) getResource(uri)
Get a resource.
Parameters:
Name | Type | Description |
---|---|---|
uri |
A specification for the resource. |
(inner) instantiate(accessorName, accessorClass)
Instantiate and return an accessor. This will throw an exception if there is no such accessor class on the accessor search path.
Parameters:
Name | Type | Description |
---|---|---|
accessorName |
The name to give to the instance. |
|
accessorClass |
Fully qualified accessor class name, e.g. 'net/REST'. |
(inner) instantiateAndInitialize(accessorNames)
If there are one or more arguments after duktapeHostInvoke.js, then assume that each argument names a file defining an accessor. Each accessor is instantiated and initialized.
See duktapeHostInvoke.js for a file that requires duktapeHost.js and then invokes this method.
Sample usage:
duktapeHostInvoke.js contains:
var commonHost = require('./duktapeHost.js'); // Remove "node.js" from the array of command line arguments. process.argv.shift(); // Remove "duktapeHostInvoke.js" from the array of command line arguments. process.argv.shift(); instantiateAndInitialize(process.argv);
To invoke:
node duktapeHostInvoke.js test/TestComposite
Parameters:
Name | Type | Description |
---|---|---|
accessorNames |
An array of accessor names in a format suitable for getAccessorCode(name). |