Examples of evaluateReader()


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

    Reader underscoreReader = new InputStreamReader(JSConverter.class.getResourceAsStream("underscore.js"));
    context.evaluateReader(globalScope, underscoreReader, "underscore.js", 1, null);
    Reader srReader = new InputStreamReader(JSConverter.class.getResourceAsStream("SaikuRenderer.js"));
    context.evaluateReader(globalScope, srReader, "SaikuRenderer.js", 1, null);
    Reader strReader = new InputStreamReader(JSConverter.class.getResourceAsStream("SaikuTableRenderer.js"));
    context.evaluateReader(globalScope, strReader, "SaikuTableRenderer.js", 1, null);
    String data = om.writeValueAsString(qr);
    Object wrappedQr = Context.javaToJS(data, globalScope);
    ScriptableObject.putProperty(globalScope, "data", wrappedQr);
    Object wrappedOut = Context.javaToJS(sw, globalScope);
    ScriptableObject.putProperty(globalScope, "out", wrappedOut);
View Full Code Here

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

                try {
                    Context context = Context.enter();
                    context.setOptimizationLevel(-1); // Without this, Rhino hits a 64K bytecode limit and fails
                    try {
                        globalScope = context.initStandardObjects();
                        context.evaluateReader(globalScope, reader, "coffee-script.js", 0, null);
                    } finally {
                        Context.exit();
                    }
                } finally {
                    reader.close();
View Full Code Here

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

   
    try {
      if(args.length > 1){
        for(int i=1; i<args.length; i++){
          File includeFile = new File(args[i]);
          cx.evaluateReader(scope, new FileReader(includeFile), includeFile.getName(), 1, null);
        }
      }
      cx.evaluateReader(scope, new FileReader(file), file.getName(), 1, null);
     
    } finally {
View Full Code Here

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

        for(int i=1; i<args.length; i++){
          File includeFile = new File(args[i]);
          cx.evaluateReader(scope, new FileReader(includeFile), includeFile.getName(), 1, null);
        }
      }
      cx.evaluateReader(scope, new FileReader(file), file.getName(), 1, null);
     
    } finally {
      Context.exit();
    }
View Full Code Here

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

   
    public Object eval(Scriptable scope,Reader source, String path) {
       
        try {
            Context context = Context.enter();
            return context.evaluateReader(scope, source, path, 1, null);
        } catch(Exception e) {
            throw new RuntimeException("An error occurred when evaluating \"" + path + "\". Exception: "  + e, e);
        } finally {
          Context.exit();
        }
View Full Code Here

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

        InputSupplier<InputStreamReader> supplier = Resources.newReaderSupplier(url, Charsets.UTF_8);
        Context context = Context.enter();
        context.setOptimizationLevel(-1); // Without this, Rhino hits a 64K bytecode limit and fails
        try {
            globalScope = context.initStandardObjects();
            context.evaluateReader(globalScope, supplier.getInput(), "coffee-script.js", 0, null);
            version = (String) context.evaluateString(globalScope, "CoffeeScript.VERSION;", "source", 0, null);
        } catch (IOException e1) {
            throw new CoffeeScriptException(e1.getMessage());
        } finally {
            Context.exit();
View Full Code Here

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

            NativeObject exports = new NativeObject();
            global.put("exports", global, exports);

            InputStream resourceAsStream = Rhinodo.class.getClassLoader().getResourceAsStream("META-INF/env/path.js");
            ctx.evaluateReader(global,new InputStreamReader(resourceAsStream), "path",-1, null);

            Function function = (Function) exports.get("basename");
            Object result = (Object) function.call(ctx, global, exports, new Object[]{"hello/bye/now"});

            assertEquals("now", Context.toString(result));
View Full Code Here

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

            global.put("__dirname", global, "/a/b/c/");

            System.setProperty("user.dir", "/a/b/c/");

            InputStream resourceAsStream = Rhinodo.class.getClassLoader().getResourceAsStream("META-INF/env/path.js");
            ctx.evaluateReader(global,new InputStreamReader(resourceAsStream), "path",-1, null);

            Function function = (Function) exports.get("resolve");
            Object result = (Object) function.call(ctx, global, exports, new Object[]{"../hello"});
            assertEquals("/a/b/hello", Context.toString(result));
View Full Code Here

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

                try {
                    Context context = Context.enter();
                    context.setOptimizationLevel(-1); // Without this, Rhino hits a 64K bytecode limit and fails
                    try {
                        globalScope = context.initStandardObjects();
                        context.evaluateReader(globalScope, reader, "coffee-script.js", 0, null);
                    } finally {
                        Context.exit();
                    }
                } finally {
                    reader.close();
View Full Code Here

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

    public void testRelativeId() throws Exception {
        final Context cx = createContext();
        final Scriptable scope = cx.initStandardObjects();
        final Require require = getSandboxedRequire(cx, scope, false);
        require.install(scope);
        cx.evaluateReader(scope, getReader("testRelativeId.js"),
                "testRelativeId.js", 1, null);
    }

    public void testSetMainForAlreadyLoadedModule() throws Exception {
        final Context cx = createContext();
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.