Accessors run on Accessor Hosts. This page is about writing Accessor Hosts, not Accessors themselves. See the Accessor Specification for how to write Accessors
See Software Configuration Management for coding style, directory layout, and other useful information.
Remote Resources
- Node.js, JavaScript engine built on Google's Chrome engine
- Project Avatar, JavaScript library on Nashorn with Node-like API
- Nashorn, JavaScript engine for Java 8
How to create a new Accessor Host
- Get write access to the
accessors
repository. If you had read-only access previously, you may need to check out a new copy of the accessors
repo with the read/write URL.
- New hosts go in
accessors/web/hosts/
. The file should be named accessors/web/hosts/xxx/xxxHost.js
. See Directory Structure.
- Looking at the other host declarations can be helpful. Consider using
accessors/web/hosts/nodeHost.js
as a template.
- Get the CommonJS Module Specification command
var commonHost = require('../common/commonHost.js');
working.
- Get
accessors/web/test/TestComposite.js
working.
- Decide on a test infrastructure. Using Mocha is preferred, see Testing
- See Accessor Specification for the functions that must be implemented.
- See Host Provided Libraries for libraries that must be provided.
- The key part of creating a host is implementing the modules that are used in the accessor declaration. So, understand how modules are found with
require
in your host and start implementing modules. The easiest way to do this is to look at how the other hosts implement require().
- Cape Code Host:
$PTII/ptolemy/actor/lib/jjs/external/require.js
- Duktape Host:
accessors/web/hosts/duktape/duktapeHost.js
. Uses FileIo.readFile()
, which is defined in accessors/web/hosts/duktape/duktape/examples/eventloop/fileio.c
and registered in accessors/web/hosts/duktape/duktape/examples/cmdline/duk_cmdline.c
.
eduk
does not have a file system, so it creates arrays that contain the files and then uses accessors/web/hosts/duktape/eduk/nofileio.c
- Impement
getAccessorCode()
so that extend()
and implement()
work. See commonHost.js (jsDoc, source)
- See Optional JavaScript Modules for the the optional modules
Design
Below is a list of design points for hosts
Differentiating the hosts
If a host requires code that is different from other hosts, then create a module that includes that difference and require it.
commonHost.js
should not have host-specific code.
See Also
See Local Resources at the top of this page
Back to main accessors wiki