本文整理汇总了Java中org.mozilla.javascript.ScriptRuntime.toObject方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRuntime.toObject方法的具体用法?Java ScriptRuntime.toObject怎么用?Java ScriptRuntime.toObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ScriptRuntime
的用法示例。
在下文中一共展示了ScriptRuntime.toObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeModuleScript
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private Scriptable executeModuleScript(Context cx, String id,
Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
nativeScope);
URI uri = moduleScript.getUri();
URI base = moduleScript.getBase();
defineReadOnlyProperty(moduleObject, "id", id);
if(!sandboxed) {
defineReadOnlyProperty(moduleObject, "uri", uri.toString());
}
final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
// Set this so it can access the global JS environment objects.
// This means we're currently using the "MGN" approach (ModuleScript
// with Global Natives) as specified here:
// <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
executionScope.put("exports", executionScope, exports);
executionScope.put("module", executionScope, moduleObject);
moduleObject.put("exports", moduleObject, exports);
install(executionScope);
if(isMain) {
defineReadOnlyProperty(this, "main", moduleObject);
}
executeOptionalScript(preExec, cx, executionScope);
moduleScript.getScript().exec(cx, executionScope);
executeOptionalScript(postExec, cx, executionScope);
return ScriptRuntime.toObject(cx, nativeScope,
ScriptableObject.getProperty(moduleObject, "exports"));
}
示例2: get
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
@Override
public Object get(String name, Scriptable start) {
if (this == thePrototypeInstance)
return super.get(name, start);
String result = System.getProperty(name);
if (result != null)
return ScriptRuntime.toObject(getParentScope(), result);
else
return Scriptable.NOT_FOUND;
}
示例3: executeModuleScript
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private Scriptable executeModuleScript(Context cx, String id,
Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
nativeScope);
URI uri = moduleScript.getUri();
URI base = moduleScript.getBase();
defineReadOnlyProperty(moduleObject, "id", id);
if(!sandboxed) {
defineReadOnlyProperty(moduleObject, "uri", uri.toString());
}
final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
// Set this so it can access the global JS environment objects.
// This means we're currently using the "MGN" approach (ModuleScript
// with Global Natives) as specified here:
// <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
executionScope.put("exports", executionScope, exports);
executionScope.put("module", executionScope, moduleObject);
moduleObject.put("exports", moduleObject, exports);
install(executionScope);
if(isMain) {
defineReadOnlyProperty(this, "main", moduleObject);
}
executeOptionalScript(preExec, cx, executionScope);
moduleScript.getScript().exec(cx, executionScope);
executeOptionalScript(postExec, cx, executionScope);
return ScriptRuntime.toObject(nativeScope,
ScriptableObject.getProperty(moduleObject, "exports"));
}
示例4: executeModuleScript
import org.mozilla.javascript.ScriptRuntime; //导入方法依赖的package包/类
private Scriptable executeModuleScript(Context cx, String id,
Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
nativeScope);
URI uri = moduleScript.getUri();
URI base = moduleScript.getBase();
defineReadOnlyProperty(moduleObject, "id", id);
if(!sandboxed) {
defineReadOnlyProperty(moduleObject, "uri", uri.toString());
}
final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
// Set this so it can access the global JS environment objects.
// This means we're currently using the "MGN" approach (ModuleScript
// with Global Natives) as specified here:
// <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
executionScope.put("exports", executionScope, exports);
executionScope.put("module", executionScope, moduleObject);
moduleObject.put("exports", moduleObject, exports);
install(executionScope);
if(isMain) {
defineReadOnlyProperty(this, "main", moduleObject);
}
executeOptionalScript(preExec, cx, executionScope);
moduleScript.getScript().exec(cx, executionScope);
executeOptionalScript(postExec, cx, executionScope);
return ScriptRuntime.toObject(nativeScope,
ScriptableObject.getProperty(moduleObject, "exports"));
}