phid-srcgentools
v1.0.23
Published
Source Generation Tools
Downloads
74
Readme
Source Generation Tools
Source gen tools includes various methods that assist in the generation of source code from the Phidget Specification files.
The module exports two variables SrcGenTools and Lint.
To create and instance:
var PhidgetSrcGenTools = require('phid-srcgentools');
var gentools = new PhidgetSrcGenTools.SrcGenTools()
A number of C language specific bridge packet functions are also defined. Check the source or the SpecTools Class Generator project for details.
Methods
loadPhidgetSpec()
loadPhidgetSpec() loads each of the .js files found in the phidspec folder as node.js modules, and returns them as an array.
The phidspec folder is stored in the SrcGenTools instance specdir member, and defaults to phidhome/phidspec.
Lint is executed on each of the loaded spec files.
var PhidgetSrcGenTools = require('phid-srcgentools');
var gentools = new PhidgetSrcGenTools.SrcGenTools()
var mods = gentools.loadPhidgetSpec();
writeObjectJS(obj, writeln, name)
Writes the contents of the specified object with the specified writeln instance as a JavaScript object named name.
var WriteLn = require('phid-writeln');
var PhidgetSrcGenTools = require('phid-srcgentools');
var gentools = new PhidgetSrcGenTools.SrcGenTools()
var w = new WriteLn();
w.open('output.js');
gentools.writeObjectJS(obj, w, 'Object');
foreachDeviceChannel(cls, cb, arg)
Walks each device and class in Devices.js, an calls the specified callback function cb for each class that matches the specified class cls. arg is a context variable that is supplied by the called and passed to each invocation of the callback cb.
The specified class is expected to have been processed by mkTree(). The class comparison is done via the cls basename and the channel.class.
var PhidgetSrcGenTools = require('phid-srcgentools');
var gentools = new PhidgetSrcGenTools.SrcGenTools()
function cb(cls, dev, ch, arg) {
}
gentools.foreachDeviceChannel(cls, cb, null);
Helper methods
The following methods are added if not already set:
- String.endsWith()
- String.startsWith()
- String.lowerFirst()
- String.upperFirst()