本文整理汇总了Java中org.mozilla.javascript.TopLevel类的典型用法代码示例。如果您正苦于以下问题:Java TopLevel类的具体用法?Java TopLevel怎么用?Java TopLevel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TopLevel类属于org.mozilla.javascript包,在下文中一共展示了TopLevel类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HostedJavaObject
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
/**
* Constructs new scope that contains the passed object members.
*
* @param scope Scope to become the parent scope of this Java object.
* @param objectMembers Object and its members to be put into this new scope.
*/
public HostedJavaObject(Scriptable scope, ObjectMembers objectMembers) {
super(objectMembers.getObject(), scope, null);
this.objectMembers = objectMembers;
TopLevel topLevel = JavaScriptEngine.getObjectTopLevel(scope);
Scriptable builtinObject = topLevel.getBuiltinCtor(Builtins.Object);
setPrototype(builtinObject);
if (object instanceof ObjectGetter) {
Class<?>[] getterArgs = ObjectGetter.METHOD_ARG_TYPES;
String getterName = ObjectGetter.METHOD_NAME;
for (Method method : objectClass.getMethods()) {
String methodName = method.getName();
Class<?>[] methodParams = method.getParameterTypes();
if (methodName.equals(getterName) && !Arrays.equals(methodParams, getterArgs)) {
hasNonObjectGetterGet = true;
break;
}
}
}
}
示例2: initializeTopLevel
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
/**
* Initializes global top level scope.
*
* @return New top level scope.
*/
protected TopLevel initializeTopLevel() {
@SuppressWarnings("unchecked")
Object object = (scriptSettings != null)? ((GlobalObjectScriptSettings<GlobalObject>)scriptSettings).getGlobalObject() : null;
if (object == null) {
TopLevel topLevel = new TopLevel();
Context cx = enterContext();
try {
cx.initStandardObjects(topLevel, true);
} finally {
exitContext();
}
return topLevel;
}
return new ObjectTopLevel(object, this);
}
示例3: initializeTopLevel
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
/**
* Initializes global top level scope.
*
* @return New top level scope.
*/
protected TopLevel initializeTopLevel() {
Object object = (scriptSettings != null)? scriptSettings.getGlobalObject() : null;
if (object == null) {
TopLevel topLevel = new TopLevel();
Context cx = enterContext();
try {
cx.initStandardObjects(topLevel, true);
} finally {
exitContext();
}
return topLevel;
}
return new ObjectTopLevel(object, this);
}
示例4: HostedJavaObject
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
/**
* Constructs new scope that contains the passed object members.
*
* @param scope Scope to become the parent scope of this Java object.
* @param objectMembers Object and its members to be put into this new scope.
*/
public HostedJavaObject(Scriptable scope, ObjectMembers objectMembers) {
super(objectMembers.getObject(), scope, null);
this.objectMembers = objectMembers;
TopLevel topLevel = WindowJavaScriptEngine.getObjectTopLevel(scope);
Scriptable builtinObject = topLevel.getBuiltinCtor(Builtins.Object);
setPrototype(builtinObject);
if (object instanceof ObjectGetter) {
Class<?>[] getterArgs = ObjectGetter.METHOD_ARG_TYPES;
String getterName = ObjectGetter.METHOD_NAME;
for (Method method : objectClass.getMethods()) {
String methodName = method.getName();
Class<?>[] methodParams = method.getParameterTypes();
if (methodName.equals(getterName) && !Arrays.equals(methodParams, getterArgs)) {
hasNonObjectGetterGet = true;
break;
}
}
}
}
示例5: HostedJavaMethod
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
/**
* Constructs new hosted Java method for given parent scope, of the passed object and with the passed overloaded function members.
*
* @param scope Scope to become the parent scope of this function.
* @param object Object with the wrapped method.
* @param objectFunctions Overloaded function members which should have the same name.
*/
public HostedJavaMethod(Scriptable scope, Object object, Set<? extends FunctionMember> objectFunctions) {
super(objectFunctions.iterator().next().getMember().getName(), FUNCTION_METHOD, scope);
this.object = object;
this.objectFunctions = new HashSet<FunctionMember>();
this.objectFunctions.addAll(objectFunctions);
TopLevel topLevel = JavaScriptEngine.getObjectTopLevel(scope);
Scriptable builtinFunction = topLevel.getBuiltinCtor(Builtins.Function);
setPrototype(builtinFunction);
}
示例6: HostedJavaMethod
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
/**
* Constructs new hosted Java method for given parent scope, of the passed object and with the passed overloaded function members.
*
* @param scope Scope to become the parent scope of this function.
* @param object Object with the wrapped method.
* @param objectFunctions Overloaded function members which should have the same name.
*/
public HostedJavaMethod(Scriptable scope, Object object, Set<? extends FunctionMember> objectFunctions) {
super(objectFunctions.iterator().next().getMember().getName(), FUNCTION_METHOD, scope);
this.object = object;
this.objectFunctions = new HashSet<FunctionMember>();
this.objectFunctions.addAll(objectFunctions);
TopLevel topLevel = WindowJavaScriptEngine.getObjectTopLevel(scope);
Scriptable builtinFunction = topLevel.getBuiltinCtor(Builtins.Function);
setPrototype(builtinFunction);
}
示例7: getScriptEngineProtected
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
@Override
public BrowserScriptEngine getScriptEngineProtected(final Object object) {
return new WindowJavaScriptEngine(null, null, new CollectionsContextFactory()) {
@Override
protected TopLevel initializeTopLevel() {
return new ObjectTopLevel(object, this);
}
@Override
protected ClassMembersResolverFactory initializeClassMembersResolverFactory() {
return new DefaultClassMembersResolverFactory();
}
};
}
示例8: getScriptEngineProtected
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
@Override
public BrowserScriptEngine getScriptEngineProtected(final Object object) {
return new WindowJavaScriptEngine(this, null) {
@Override
protected TopLevel initializeTopLevel() {
return new ObjectTopLevel(object, this);
}
};
}
示例9: getScriptEngineProtected
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
@Override
public BrowserScriptEngine getScriptEngineProtected(final Object object) {
return new WindowJavaScriptEngine(null, null, new DefaultContextFactory()) {
@Override
protected TopLevel initializeTopLevel() {
return new ObjectTopLevel(object, this);
}
@Override
protected ClassMembersResolverFactory initializeClassMembersResolverFactory() {
return new DefaultClassMembersResolverFactory();
}
};
}
示例10: NativeRegExp
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
this.re = regexpCompiled;
this.lastIndex = 0d;
ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
示例11: NativeRegExp
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
NativeRegExp(Scriptable scope, Object regexpCompiled)
{
this.re = (RECompiled)regexpCompiled;
this.lastIndex = 0;
ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
示例12: NativeRegExp
import org.mozilla.javascript.TopLevel; //导入依赖的package包/类
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
this.re = regexpCompiled;
this.lastIndex = 0;
ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}