Java 类org.mozilla.javascript.TopLevel 实例源码

项目:jsen-js    文件:HostedJavaObject.java   
/**
 * 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;
            }
        }
    }
}
项目:jsen-js    文件:JavaScriptEngine.java   
/**
 * 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);
}
项目:ScriptBox    文件:WindowJavaScriptEngine.java   
/**
 * 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);
}
项目:ScriptBox    文件:HostedJavaObject.java   
/**
 * 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;
            }
        }
    }
}
项目:jsen-js    文件:HostedJavaMethod.java   
/**
 * 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);
}
项目:ScriptBox    文件:HostedJavaMethod.java   
/**
 * 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);
}
项目:ScriptBox    文件:CollectionsWrapFactoryTests.java   
@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();
        }
    };
}
项目:ScriptBox    文件:JavaScriptAnnotationsTests.java   
@Override
public BrowserScriptEngine getScriptEngineProtected(final Object object) {
    return new WindowJavaScriptEngine(this, null) {
        @Override
        protected TopLevel initializeTopLevel() {
            return new ObjectTopLevel(object, this);
        }
    };
}
项目:ScriptBox    文件:HostedJavaObjectTests.java   
@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();
        }
    };
}
项目:HL4A    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0d;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:whackpad    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, Object regexpCompiled)
{
    this.re = (RECompiled)regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:TaleCraft    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:code404    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:rhino-jscover    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:LoboEvolution    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0d;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:astor    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:Rhino-Prov-Mod    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:android-js    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:closure-compiler-old    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}
项目:closure-compiler-copy    文件:NativeRegExp.java   
NativeRegExp(Scriptable scope, RECompiled regexpCompiled)
{
    this.re = regexpCompiled;
    this.lastIndex = 0;
    ScriptRuntime.setBuiltinProtoAndParent(this, scope, TopLevel.Builtins.RegExp);
}