Recent Changes - Search:

edit SideBar


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

  1. 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.
  2. New hosts go in accessors/web/hosts/. The file should be named accessors/web/hosts/xxx/xxxHost.js. See Directory Structure.
  3. Looking at the other host declarations can be helpful. Consider using accessors/web/hosts/nodeHost.js as a template.
  4. Get the CommonJS Module Specification command var commonHost = require('../common/commonHost.js'); working.
  5. Get accessors/web/test/TestComposite.js working.
  6. Decide on a test infrastructure. Using Mocha is preferred, see Testing
  7. See Accessor Specification for the functions that must be implemented.
  8. See Host Provided Libraries for libraries that must be provided.
  9. 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().
    1. Cape Code Host: $PTII/ptolemy/actor/lib/jjs/external/require.js
    2. 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.
    3. 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
  10. Impement getAccessorCode() so that extend() and implement() work. See commonHost.js (jsDoc, source)
  11. See Optional JavaScript Modules for the the optional modules


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

Edit - History - Print - Recent Changes - Search
Page last modified on June 02, 2017, at 02:06 PM