本文整理了Java中org.mozilla.javascript.ScriptableObject.getTopLevelScope()
方法的一些代码示例,展示了ScriptableObject.getTopLevelScope()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScriptableObject.getTopLevelScope()
方法的具体详情如下:
包路径:org.mozilla.javascript.ScriptableObject
类名称:ScriptableObject
方法名:getTopLevelScope
[英]Get the global scope.
Walks the parent scope chain to find an object with a null parent scope (the global object).
[中]获取全球范围。
遍历父作用域链以查找父作用域为空的对象(全局对象)。
代码示例来源:origin: org.freemarker/freemarker
public Object exec(List arguments) throws TemplateModelException {
Context cx = Context.getCurrentContext();
Object[] args = arguments.toArray();
BeansWrapper wrapper = getWrapper();
for (int i = 0; i < args.length; i++) {
args[i] = wrapper.unwrap((TemplateModel) args[i]);
}
return wrapper.wrap(((Function) getScriptable()).call(cx,
ScriptableObject.getTopLevelScope(fnThis), fnThis, args));
}
}
代码示例来源:origin: rhino/js
/**
* Get the value of the "StopIteration" object. Note that this value
* is stored in the top-level scope using "associateValue" so the
* value can still be found even if a script overwrites or deletes
* the global "StopIteration" property.
* @param scope a scope whose parent chain reaches a top-level scope
* @return the StopIteration object
*/
public static Object getStopIterationObject(Scriptable scope) {
Scriptable top = ScriptableObject.getTopLevelScope(scope);
return ScriptableObject.getTopScopeValue(top, ITERATOR_TAG);
}
代码示例来源:origin: geogebra/geogebra
/**
* Get the Object.prototype property.
* See ECMA 15.2.4.
*/
public static Scriptable getObjectPrototype(Scriptable scope) {
return TopLevel.getBuiltinPrototype(getTopLevelScope(scope),
TopLevel.Builtins.Object);
}
代码示例来源:origin: geogebra/geogebra
/**
* This is an indirect call to eval, and thus uses the global environment.
* Direct calls are executed via ScriptRuntime.callSpecial().
*/
private Object js_eval(Context cx, Scriptable scope, Object[] args)
{
Scriptable global = ScriptableObject.getTopLevelScope(scope);
return ScriptRuntime.evalSpecial(cx, global, global, args, "eval code", 1);
}
代码示例来源:origin: io.apigee/rhino
/**
* This is an indirect call to eval, and thus uses the global environment.
* Direct calls are executed via ScriptRuntime.callSpecial().
*/
private Object js_eval(Context cx, Scriptable scope, Object[] args)
{
Scriptable global = ScriptableObject.getTopLevelScope(scope);
return ScriptRuntime.evalSpecial(cx, global, global, args, "eval code", 1);
}
代码示例来源:origin: rhino/js
protected void addIdFunctionProperty(Scriptable obj, Object tag, int id,
String name, int arity)
{
Scriptable scope = ScriptableObject.getTopLevelScope(obj);
IdFunctionObject f = newIdFunction(tag, id, name, arity, scope);
f.addAsProperty(obj);
}
代码示例来源:origin: rhino/js
public static Scriptable createAdapterWrapper(Scriptable obj,
Object adapter)
{
Scriptable scope = ScriptableObject.getTopLevelScope(obj);
NativeJavaObject res = new NativeJavaObject(scope, adapter, null, true);
res.setPrototype(obj);
return res;
}
代码示例来源:origin: rhino/js
public final void initPrototypeMethod(Object tag, int id, String name,
int arity)
{
Scriptable scope = ScriptableObject.getTopLevelScope(this);
IdFunctionObject f = newIdFunction(tag, id, name, arity, scope);
prototypeValues.initValue(id, name, f, DONTENUM);
}
代码示例来源:origin: rhino/js
public static Scriptable newObject(Context cx, Scriptable scope,
String constructorName, Object[] args)
{
scope = ScriptableObject.getTopLevelScope(scope);
Function ctor = getExistingCtor(cx, scope, constructorName);
if (args == null) { args = ScriptRuntime.emptyArgs; }
return ctor.construct(cx, scope, args);
}
代码示例来源:origin: geogebra/geogebra
public static Scriptable newObject(Context cx, Scriptable scope,
String constructorName, Object[] args)
{
scope = ScriptableObject.getTopLevelScope(scope);
Function ctor = getExistingCtor(cx, scope, constructorName);
if (args == null) { args = ScriptRuntime.emptyArgs; }
return ctor.construct(cx, scope, args);
}
代码示例来源:origin: geogebra/geogebra
public static Scriptable newBuiltinObject(Context cx, Scriptable scope,
TopLevel.Builtins type,
Object[] args)
{
scope = ScriptableObject.getTopLevelScope(scope);
Function ctor = TopLevel.getBuiltinCtor(cx, scope, type);
if (args == null) { args = ScriptRuntime.emptyArgs; }
return ctor.construct(cx, scope, args);
}
代码示例来源:origin: geogebra/geogebra
public final void initPrototypeMethod(Object tag, int id, String name,
int arity)
{
Scriptable scope = ScriptableObject.getTopLevelScope(this);
IdFunctionObject f = newIdFunction(tag, id, name, arity, scope);
prototypeValues.initValue(id, name, f, DONTENUM);
}
代码示例来源:origin: geogebra/geogebra
protected void addIdFunctionProperty(Scriptable obj, Object tag, int id,
String name, int arity)
{
Scriptable scope = ScriptableObject.getTopLevelScope(obj);
IdFunctionObject f = newIdFunction(tag, id, name, arity, scope);
f.addAsProperty(obj);
}
代码示例来源:origin: io.apigee/rhino
public static Scriptable newBuiltinObject(Context cx, Scriptable scope,
TopLevel.Builtins type,
Object[] args)
{
scope = ScriptableObject.getTopLevelScope(scope);
Function ctor = TopLevel.getBuiltinCtor(cx, scope, type);
if (args == null) { args = ScriptRuntime.emptyArgs; }
return ctor.construct(cx, scope, args);
}
代码示例来源:origin: rhino/js
private static void match_glob(GlobData mdata, Context cx,
Scriptable scope, int count,
RegExpImpl reImpl)
{
if (mdata.arrayobj == null) {
Scriptable s = ScriptableObject.getTopLevelScope(scope);
mdata.arrayobj = ScriptRuntime.newObject(cx, s, "Array", null);
}
SubString matchsub = reImpl.lastMatch;
String matchstr = matchsub.toString();
mdata.arrayobj.put(count, mdata.arrayobj, matchstr);
}
代码示例来源:origin: geogebra/geogebra
public static void setBuiltinProtoAndParent(ScriptableObject object,
Scriptable scope,
TopLevel.Builtins type)
{
scope = ScriptableObject.getTopLevelScope(scope);
object.setParentScope(scope);
object.setPrototype(TopLevel.getBuiltinPrototype(scope, type));
}
代码示例来源:origin: rhino/js
public static void setObjectProtoAndParent(ScriptableObject object,
Scriptable scope)
{
// Compared with function it always sets the scope to top scope
scope = ScriptableObject.getTopLevelScope(scope);
object.setParentScope(scope);
Scriptable proto
= ScriptableObject.getClassPrototype(scope, object.getClassName());
object.setPrototype(proto);
}
代码示例来源:origin: geogebra/geogebra
public static void setObjectProtoAndParent(ScriptableObject object,
Scriptable scope)
{
// Compared with function it always sets the scope to top scope
scope = ScriptableObject.getTopLevelScope(scope);
object.setParentScope(scope);
Scriptable proto
= ScriptableObject.getClassPrototype(scope, object.getClassName());
object.setPrototype(proto);
}
代码示例来源:origin: rhino/js
static Object newWithSpecial(Context cx, Scriptable scope, Object[] args)
{
ScriptRuntime.checkDeprecated(cx, "With");
scope = ScriptableObject.getTopLevelScope(scope);
NativeWith thisObj = new NativeWith();
thisObj.setPrototype(args.length == 0
? ScriptableObject.getClassPrototype(scope,
"Object")
: ScriptRuntime.toObject(cx, scope, args[0]));
thisObj.setParentScope(scope);
return thisObj;
}
代码示例来源:origin: io.apigee/rhino
static Object newWithSpecial(Context cx, Scriptable scope, Object[] args)
{
ScriptRuntime.checkDeprecated(cx, "With");
scope = ScriptableObject.getTopLevelScope(scope);
NativeWith thisObj = new NativeWith();
thisObj.setPrototype(args.length == 0
? ScriptableObject.getObjectPrototype(scope)
: ScriptRuntime.toObject(cx, scope, args[0]));
thisObj.setParentScope(scope);
return thisObj;
}
内容来源于网络,如有侵权,请联系作者删除!