Class: CodeGenUtils

CodeGenUtils

mmir.tools.CodeGenUtils

Utilities for handling generated code (e.g. grammars, views etc.)
Example
var codeGenUtils = mmir.require('mmirf/codeGenUtils');
 var prefixCode = codeGenUtils.getCodeWrapPrefix();
 //...

Methods

getCodeWrapPrefix(disableStrictMode){String}

Prefix for wrapping persisted objects:
  • wraps code into a closure
  • makes global namespace available as variable global
  • makes mmirf/core available as variable mmir (if mmirf/core is present in global namespace)
  • makes mmirf/core's require function available as require (if mmirf/core is present and has require function)
Name Type Description
disableStrictMode Boolean optional OPTIONAL disable JavaScript strict mode in the generated closure (i.e. allow non-strict JS code in the generated code)
See:
Returns:
Type Description
String the prefix code for closure-wrapping generated code (i.e. prepend to generated code)

getCodeWrapSuffix(){String}

Suffix for wrapping generated code in a closure:
  • closes and self-calls closure
  • sets global namespace to window (browser) or self (browser webworker) or global (node module) (via the closure function's argument)
See:
Returns:
Type Description
String the suffix code for closure-wrapping of generated code (i.e. append to generated code)