Package org.mozilla.javascript

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


    cx.setOptimizationLevel(9);
    Global global = new Global();
    global.init(cx);
    Scriptable scope = cx.initStandardObjects(global);
    cx.evaluateString(scope, "var exports = {};", "exports", 1, null);
    cx.evaluateReader(scope, new InputStreamReader(cssmin.openConnection()
        .getInputStream()), cssmin.getFile(), 1, null);
    Scriptable exports = (Scriptable) scope.get("exports", scope);
    Scriptable compressor = (Scriptable) exports.get("compressor", exports);
    Function fn = (Function) compressor.get("cssmin", compressor);
    content = ((String) Context.call(null, fn, compressor, compressor,
View Full Code Here


        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

            cx = Context.enter();
            cx.setGeneratingDebug(false);
            cx.setGeneratingSource(false);
            cx.setOptimizationLevel(-1);
            Scriptable sc = getScope(context);
            retVal = cx.evaluateReader(sc, reader, source, 0, null);
        } catch (JavaScriptException ex) {
            errorHandler(ex);
        } catch (IOException ioe) {
            errorHandler(ioe);
View Full Code Here

          cx.setOptimizationLevel(-1);
          cx.setLanguageVersion(Context.VERSION_1_5);
          final ScriptableObject scope = cx.initStandardObjects();
          String printFunction = "function print(message) {java.lang.System.out.println(message);}";
          cx.evaluateString(scope, printFunction, "print", 1, null);
          cx.evaluateReader(scope, new InputStreamReader(Thread.currentThread().getContextClassLoader()
              .getResourceAsStream("env.rhino.js")), "env.rhino.js", 1, null);
          cx.evaluateString(scope, "window.location='" + getStartPageUrl(getId(), false) + "';", "eval", 1,
              null);
        } catch (IOException e) {
          throw new RuntimeException(e);
View Full Code Here

                int i = 0;
                for (String javaScripthPath : javaScripts) {
                    File file = new File(javaScripthPath);
                    InputStream is = new FileInputStream(file);
                    Reader inputStreamReader = new InputStreamReader(is, "UTF-8");
                    context.evaluateReader(globalScope, inputStreamReader, "init" + i++ + ".js", 0, null);
                }

                context.evaluateString(globalScope, "var moment = require('moment.min.js');", "init-moment-amd.js", 0, null);
            } finally {
                Context.exit();
View Full Code Here

    public Object evaluate(Reader scriptreader)
        throws InterpreterException, IOException {
        Object rv = null;
        Context ctx = Context.enter(context);
        try {
            rv = ctx.evaluateReader(scope,
                                    scriptreader,
                                    "<SVG>",
                                    1, null);
        } catch (JavaScriptException e) {
            throw new InterpreterException(e, e.getMessage(), -1, -1);
View Full Code Here

      lessEnv.put("optimization", lessEnv, options.getOptimization());
      lessEnv.put("loader", lessEnv, Context.javaToJS(loader, scope));
      cx.evaluateReader(scope, new InputStreamReader(less
          .openConnection().getInputStream()), less.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(cssmin
          .openConnection().getInputStream()), cssmin.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(engine
          .openConnection().getInputStream()), engine.getFile(), 1,
          null);
View Full Code Here

          .openConnection().getInputStream()), less.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(cssmin
          .openConnection().getInputStream()), cssmin.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(engine
          .openConnection().getInputStream()), engine.getFile(), 1,
          null);
      compile = (Function) scope.get("compile", scope);
      Context.exit();
    } catch (Exception e) {
View Full Code Here

          + cx.getImplementationVersion());
      cx.setOptimizationLevel(-1);
      Global global = new Global();
      global.init(cx);
      scope = cx.initStandardObjects(global);
      cx.evaluateReader(scope, new InputStreamReader(env.openConnection()
          .getInputStream()), env.getFile(), 1, null);
      Scriptable lessEnv = (Scriptable) scope.get("lessenv", scope);
      lessEnv.put("charset", lessEnv, options.getCharset());
      lessEnv.put("css", lessEnv, options.isCss());
      lessEnv.put("lineNumbers", lessEnv, options.getLineNumbers());
View Full Code Here

      lessEnv.put("charset", lessEnv, options.getCharset());
      lessEnv.put("css", lessEnv, options.isCss());
      lessEnv.put("lineNumbers", lessEnv, options.getLineNumbers());
      lessEnv.put("optimization", lessEnv, options.getOptimization());
      lessEnv.put("loader", lessEnv, Context.javaToJS(loader, scope));
      cx.evaluateReader(scope, new InputStreamReader(less
          .openConnection().getInputStream()), less.getFile(), 1,
          null);
      cx.evaluateReader(scope, new InputStreamReader(cssmin
          .openConnection().getInputStream()), cssmin.getFile(), 1,
          null);
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.