Module ringo/engine
Functions
- addHostObject(javaClass)
- addRepository(repo)
- asJavaObject(object)
- asJavaString(object)
- createSandbox(modulePath, globals, options)
- deserialize(input)
- evaluate(moduleName, scope)
- getErrors()
- getOptimizationLevel()
- getRepositories()
- getRhinoContext()
- getRhinoEngine()
- getRingoHome()
- serialize(object, output)
- setOptimizationLevel(level)
Properties
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: - includeSystemModules whether to include the system modules in the module search path - 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
deserialize (input)
Deserialize a previously serialized object graph from a java.io.Inputstream or a byte array.
Parameters
| java.io.InputStream | input | a InputStream or byte array containing a serialized object |
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.
serialize (object, output)
Serialize a JavaScript object graph to a java.io.OutputStream. If the function is called without second argument the serialized object is returned as byte array.
Parameters
| Object | object | the object to serialize |
| java.io.OutputStream | output | a java.io.OutputStream |
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.
