模块 ringo/engine

提供对 Rhino JavaScript 引擎的访问。


addHostObject (javaClass)

将一个类定义为 Rhino 主机对象。

Parameters

JavaClass javaClass

the class to define as host object


addRepository (repo)

将存储库添加到模块搜索路径

Parameters

Repository repo

a repository


addShutdownHook (funcOrObject, sync)

当当前的 RingoJS 实例终止时,注册一个要调用的回调函数。

Parameters

Function|Object funcOrObject

Either a JavaScript function or a JavaScript object containing properties called module and name specifying a function exported by a RingoJS module.

Boolean sync

(optional) whether to invoke the callback synchronously (on the main shutdown thread) or asynchronously (on the worker's event loop thread)


asJavaObject (object)

获取将它作为 Java 对象公开为 JavaScript 的对象的包装器。

Parameters

Object object

an object

Returns

Object

the object wrapped as native java object


asJavaString (object)

获取将 java.lang.String 方法公开给 JavaScript 的字符串的包装器这对于以无 java.lang.String 的形式访问字符串非常有用,无需创建新实例。

Parameters

Object object

an object

Returns

Object

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


createSandbox (modulePath, globals, options)

使用与此相同的安装目录创建一个Sandbox脚本引擎,以及给定的模块路径,全局属性,类shutter和密封

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

getCurrentWorker (obj)

获取与当前线程或给定范围或函数对象关联的worker实例。

Parameters

Object obj

optional scope or function to get the worker from.

Returns

org.ringojs.engine.RingoWorker

the current worker


getErrors ()

获取包含当前worker中遇到的语法错误的列表

Returns

ScriptableList

a list containing the errors encountered in the current worker


getOptimizationLevel ()

获取当前线程和上下文的 Rhino 优化级别。优化级别是-1(解释器模式)和 9(编译模式,所有优化启用)之间的整数。默认级别是 0。

Returns

Number

level an integer between -1 and 9


getRepositories ()

获取应用程序的模块搜索路径作为存储库列表。

Returns

ScriptableList

a list containing the module search path repositories


getRhinoContext ()

获取与当前线程关联的 org.mozilla.javascript.Context。


getRhinoEngine ()

获取与此应用程序关联的 org.ringojs.engine.RhinoEngine。

Returns

org.ringojs.engine.RhinoEngine

the current RhinoEngine instance


getRingoHome ()

获取 RingoJS 安装目录。

Returns

Repository

a Repository representing the Ringo installation directory


getWorker ()

获取一个新的worker实例。

Returns

org.ringojs.engine.RingoWorker

a new RingoWorker instance


setOptimizationLevel (level)

为当前线程和上下文设置 Rhino 优化级别。优化级别是 -1(解释器模式)和 9(编译模式,所有优化启用)之间的整数。默认级别是 0。

Parameters

Number level

an integer between -1 and 9


version

RingoJS 版本是一个类似数组的对象,主要和次要版本号作为第一个和第二个元素。