Package org.mozilla.javascript

Examples of org.mozilla.javascript.Scriptable


                );
            }

            Context cx = Context.enter();
            try {
                Scriptable scope = cx.initStandardObjects();
                FileReader reader = new FileReader(script);

                Object wrappedRequest = Context.javaToJS(request, scope);
                Object wrappedResponse = Context.javaToJS(response, scope);
                Object wrappedCatalog = Context.javaToJS(catalog, scope);
View Full Code Here


        if (!(scriptXML instanceof XMLObject)) {
            return null;
        }

        // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost???
        Scriptable jsXML =
            (Scriptable) ScriptableObject.callMethod((Scriptable) scriptXML, "copy", new Object[0]);
        Wrapper wrapper =
            (Wrapper) ScriptableObject.callMethod(jsXML, "getXmlObject", new Object[0]);

        XmlObject xmlObject = (XmlObject) wrapper.unwrap();
View Full Code Here

            logger.debug("entering script context");
            Context ctx = Context.enter();
            logger.trace("ctx: " + ctx);
           
            logger.debug("initializing standard objects");
            Scriptable scope = ctx.initStandardObjects();
            logger.debug("scope: " + scope);
           
            logger.debug("setting script bindings");
            for(String key : pairs.keySet())
            {
View Full Code Here

     */
    @Override
    public boolean hasInstance(Scriptable instance) {
        // Default for JS objects (other than Function) is to do prototype
        // chasing.
        Scriptable proto = instance.getPrototype();
        while (proto != null) {
            if (proto.equals(this)) return true;
            proto = proto.getPrototype();
        }
        return false;
    }
View Full Code Here

    throws ScriptException {
        Object ret;
       
        Context cx = enterContext();
        try {
            Scriptable scope = getRuntimeScope(ctxt);
            scope.put("context", scope, ctxt);

            // NOTE (RRC) - why does it look straight into the engine instead of asking
            // the given ScriptContext object?
            // Modified to use the context
            // String filename = (String) get(ScriptEngine.FILENAME);
View Full Code Here

            if (thiz != null && !(thiz instanceof Scriptable)) {
                thiz = Context.toObject(thiz, topLevel);
            }
           
            Scriptable engineScope = getRuntimeScope(context);
            Scriptable localScope = (thiz != null)? (Scriptable) thiz :
                                                    engineScope;
            Object obj = ScriptableObject.getProperty(localScope, name);
            if (! (obj instanceof Function)) {
                throw new NoSuchMethodException("no such method: " + name);
            }

            Function func = (Function) obj;
            Scriptable scope = func.getParentScope();
            if (scope == null) {
                scope = engineScope;
            }
            Object result = func.call(cx, scope, localScope,
                                      wrapArguments(args));
View Full Code Here

        if (ctxt == null) {
            throw new NullPointerException("null script context");
        }

        // we create a scope for the given ScriptContext
        Scriptable newScope = new ExternalScriptable(ctxt, indexedProps);

        // Set the prototype of newScope to be 'topLevel' so that
        // JavaScript standard objects are visible from the scope.
        newScope.setPrototype(topLevel);

        // define "context" variable in the new scope
        newScope.put("context", newScope, ctxt);
      
       
        // RRC - save some time and don't define print
        // LK - these functions are assumed by a lot of code so let's
        //      make them available
View Full Code Here

                arg = ((Wrapper)arg).unwrap();
            }
            if (arg instanceof Bindings) {
                ScriptContext ctx = new SimpleScriptContext();
                ctx.setBindings((Bindings)arg, ScriptContext.ENGINE_SCOPE);
                Scriptable res = new ExternalScriptable(ctx);
                res.setPrototype(ScriptableObject.getObjectPrototype(thisObj));
                res.setParentScope(ScriptableObject.getTopLevelScope(thisObj));
                return res;
            }
        }
        return Context.getUndefinedValue();
    }
View Full Code Here

    @Override
    public boolean hasInstance(Scriptable scriptable) {
        if (scriptable instanceof JSAdapter) {
            return true;
        } else {
            Scriptable proto = scriptable.getPrototype();
            while (proto != null) {
                if (proto.equals(this)) return true;
                proto = proto.getPrototype();
            }
            return false;
        }
    }
View Full Code Here

            Object[] args)
            throws RhinoException {
        if (isPrototype) {
            return construct(cx, scope, args);
        } else {
            Scriptable tmp = getAdaptee();
            if (tmp instanceof Function) {
                return ((Function)tmp).call(cx, scope, tmp, args);
            } else {
                throw Context.reportRuntimeError("TypeError: not a function");
            }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Scriptable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.