Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.newObject()


            Object inDoc = null;
            if (isE4X) {
                try {
                    inDoc = Context.toObject(node, scope);
                    Object[] args = {inDoc};
                    inDoc = cx.newObject(scope, "XML", args);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                inDoc = Context.toObject(node, scope);
View Full Code Here


    options = new Options(optionArgs);

    Context context = Context.enter();
    try {
      Scriptable compileScope = context.newObject(globalScope);
      compileScope.setParentScope(globalScope);
      compileScope.put("coffeeScriptSource", compileScope, coffeeScriptSource);
      try {

        return (String) context.evaluateString(compileScope, String.format("CoffeeScript.compile(coffeeScriptSource, %s);", options.toJavaScript()),
View Full Code Here

            // Create it if never used up to now
            if (rootScope == null) {
                rootScope = ctx.initStandardObjects(null);
            }
            try {
                Scriptable scope = ctx.newObject(rootScope);
                scope.setPrototype(rootScope);
                scope.setParentScope(null);
                return scope;
            } catch (Exception e) {
                throw new RuntimeException("Exception", e);
View Full Code Here

            // Create it if never used up to now
            if (rootScope == null) {
                rootScope = ctx.initStandardObjects(null);
            }
            try {
                Scriptable scope = ctx.newObject(rootScope);
                scope.setPrototype(rootScope);
                scope.setParentScope(null);
                return scope;
            } catch (Exception e) {
                throw new RuntimeException("Exception", e);
View Full Code Here

    }

    public Object evaluate(ObjectModel objectModel) throws ExpressionException {
        Context ctx = Context.enter();
        try {
            Scriptable scope = ctx.newObject(getScope(rootScope));

            // Populate the scope
            Iterator iter = objectModel.entrySet().iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry) iter.next();
View Full Code Here

    private Scriptable getScope(Scriptable rootScope) {
        Scriptable scope;
        Context ctx = Context.enter();
        try {
            scope = ctx.newObject(rootScope);
            scope.setPrototype(rootScope);
            scope.setParentScope(null);
        } catch (Exception e) {
            throw new RuntimeException("Exception", e);
        } finally {
View Full Code Here

        ContextFactory factory = ContextFactory.getGlobal();
        Context cx = factory.enterContext();
        try {
            cx.setOptimizationLevel(optimizationLevel);
            Global global = new Global(cx);
            Scriptable scope = cx.newObject(global);
            scope.setPrototype(global);
            // global.runDoctest throws an exception on any failure
            int testsPassed = global.runDoctest(cx, scope, source, name, 1);
            System.out.println(name + "(" + optimizationLevel + "): " +
                    testsPassed + " passed.");
View Full Code Here

        Context.enter();
        Context ctx = new StoppableContext();
        try {
            ctx.setInstructionObserverThreshold(1);
            ctx.setOptimizationLevel(-1);
            Scriptable scope = ctx.newObject(ctx.initStandardObjects());
            getScriptFromClasspath("coffeescript/nb/resources/coffee-script.js").exec(ctx, scope);
            scope.put("code", scope, code);
            String options = String.format("{bare: %b}", bare);
            String script = String.format("CoffeeScript.compile(code, %s);", options);
            return (String) getScriptFromString(script).exec(ctx, scope);
View Full Code Here

     */
    public Scriptable createInstanceScope(Map<String, Object> context) {
        Context cx = Context.enter();
        try {

            Scriptable instanceScope = cx.newObject(scriptScope);
            instanceScope.setPrototype(scriptScope);
            instanceScope.setParentScope(null);

            addContexts(instanceScope, context);

View Full Code Here

        Context cx = Context.enter();
        try {

            Object wrappedXML = cx.getWrapFactory().wrap(cx, scope, xml, XmlObject.class);
            Scriptable jsXML = cx.newObject(scope, "XML", new Object[] { wrappedXML });

            return jsXML;

        } finally {
            Context.exit();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.