Home >User Guide> Using the Module Generator

See Also

Using the Module Generator

The ejsmod command is a utility program for Ejscript module files to generate symbolic assembler listings, slot binding definition files and HTML documentation for Ejscript modules.

Generating Assembler Listings

The ejsmod program can create assembler listing files for input modules. To generate symbolic assembler listings, compile your source using the ejsc command with the --debug switch. Then invoke ejsmod with the --listing switch. An assembler listing file with a ".lst" extension will be generated for each corresponding module. For example:

ejsc --debug myfile.es
ejsmod --listing default.mod

If your script has module declarations, then run ejsmod with the list of modules you wish to disassemble. Note: this creates assembler listings on a per module basis and not per input source file.

The listing will interleave disassembled byte code with the relevant source code statements. The listing also describes each module and its constituent functions and initializers. The bindings for all types and the constant pool are also listed.

Generating Documentation

To generate HTML documentation for your code, first compile using the ejsc command with the --doc switch. Then invoke "ejsmod --html dir modules..." where dir is the directory where you want the documentation located and modules is a list of the relevant modules. For example:

ejsc --debug --doc myfile.es
ejsmod --html ./htmlDir *.mod

The HTML documentation will include all modules, namespaces, types, functions, properties and variable declarations.

Generating Slot Definition Files

Ejscript supports the creation of Native types which are coded in the C language. Native types are useful for core system types and for classes that must run at near binary speed. To facilitate creating native types, ejsmod generates slot binding files which define symbolic offsets for type properties and functions. See the Native class samples for further information.

Command Options

The ejsmod command may be invoked with the following command options:

ejsmod [--cslots] [--html path] [--listing] [--out slot-file] 
       [--require modules] [--searchPath ejsPath] [--version] [--warn]
       modules ...
The meaning of each switch is listed below:
Switch Description
--cslots Generate slot binding headers for the input modules.
--html dir Generate HTML documentation to the specified directory. The source files must have been compiled by ejsc with the --doc switch to include the documentation strings in the module files.
--listing Generate symbolic assembler files for each input module.
--out file Output file for generate slot definitions.
--require modules Required modules to pre-load before generating.
--searchPath ejsPath

Override the module search path. The module search path is a set of directories that the ejs command will use when locating and loading Ejscript modules. Given a module named "a.b.c" in a script, ejs will use the following search strategy to locate the module:

1. Search for a module file named "a.b.c.mod"

2. Search for a module file named "a/b/c.mod"

3. Search for a module file named "a.b.c.mod" in EJSPATH

4. Search for a module file named c.mod in EJSPATH

The search path is initially specified via the environment variable EJSPATH and may be overridden via the --searchPath ejsPath switch. EJSPATH and the ejsPath command line value are similar to the system PATH formats. On windows, path segments are separated by ";" and on Linux, Unix, FreeBSD and MAC, the path segments are separated by ":" delimiters.

--version Print the ejsmod command version and exit.
--warn Warn about undocumented methods or parameters in documentation.

© Embedthis Software LLC, 2003-2014. All rights reserved. Embedthis, Ejscript and Appweb are trademarks of Embedthis Software LLC.