Module ringo/engine

Provides access to the Rhino JavaScript engine.


addHostObject (javaClass)

Define a class as Rhino host object.

Parameters

JavaClass javaClass the class to define as host object

addRepository (repo)

Add a repository to the module search path

Parameters

Repository repo a repository

asJavaObject (object)

Get a wrapper for an object that exposes it as Java object to JavaScript.

Parameters

Object object an object

Returns

Object the object wrapped as native java object

asJavaString (object)

Get a wrapper for a string that exposes the java.lang.String methods to JavaScript This is useful for accessing strings as java.lang.String without the cost of creating a new instance.

Parameters

Object object an object

Returns

Object the object converted to a string and wrapped as native java object

createSandbox (modulePath, globals, options)

Create a sandboxed scripting engine with the same install directory as this and the given module paths, global properties, class shutter and sealing

Parameters

Array modulePath the comma separated module search path
Object globals a map of predefined global properties (may be undefined)
Object options an options object (may be undefined). The following options are supported: - systemModules array of system module directories to add to the module search path (may be relative to the ringo install dir) - classShutter a Rhino class shutter, may be null - sealed if the global object should be sealed, defaults to false

Returns

RhinoEngine a sandboxed RhinoEngine instance

Throws

{FileNotFoundException} if any part of the module paths does not exist

evaluate (moduleName, scope)

Evaluate a module script on an existing scope instead of creating a new module scope. This can be used to mimic traditional JavaScript environments such as those found in web browsers.

Parameters

String moduleName the name of the module to evaluate
Object scope the JavaScript object to evaluate the script on

getErrors ()

Get a list containing the syntax errors encountered in the current context.

Returns

ScriptableList a list containing the errors encountered in the current context

getOptimizationLevel ()

Get the Rhino optimization level for the current thread and context. The optimization level is an integer between -1 (interpreter mode) and 9 (compiled mode, all optimizations enabled). The default level is 0.

Returns

Number level an integer between -1 and 9

getRepositories ()

Get the app's module search path as list of repositories.

Returns

ScriptableList a list containing the module search path repositories

getRhinoContext ()

Get the org.mozilla.javascript.Context associated with the current thread.


getRhinoEngine ()

Get the org.ringojs.engine.RhinoEngine associated with this application.

Returns

org.ringojs.engine.RhinoEngine the current RhinoEngine instance

getRingoHome ()

Get the RingoJS installation directory.

Returns

Repository a Repository representing the Ringo installation directory

properties

An object reflecting the Java system properties.


setOptimizationLevel (level)

Set the Rhino optimization level for the current thread and context. The optimization level is an integer between -1 (interpreter mode) and 9 (compiled mode, all optimizations enabled). The default level is 0.

Parameters

Number level an integer between -1 and 9

version

The RingoJS version as [major, minor] array.