Examples of initStandardObjects()


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

   * @throws WinkBuildException
   */
  private static void executeJs(final String filename) throws WinkBuildException {
    final Context cx = Context.enter();
    cx.setOptimizationLevel(-1);
    final ScriptableObject scope = cx.initStandardObjects();

    final String fileToInspect = new String(filename);
    boolean goodExecution = false;
    try {
      final Reader buildFile = new FileReader(new File(fileToInspect));
View Full Code Here

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

      Constants.fileInMemory = Boolean.valueOf(getProperty(Constants.OPTION_FILE_IN_MEMORY));
    }

    final Context cx = Context.enter();
    cx.setOptimizationLevel(-1);
    final ScriptableObject scope = cx.initStandardObjects();

    putFunctions(cx, scope);
    putConf(cx, scope);

    final String mainFile = getProperty(Constants.JS_PATH) + File.separator + getProperty(Constants.JS_MAIN_FILE);
View Full Code Here

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

*/
public final class Main {
    public static void main(String[] args) throws Exception {
        final Context context = Context.enter();
        try {
            final ScriptableObject global = context.initStandardObjects();
            final Module module = new Module("global", new File(System.getProperty("user.dir")));
            module.init(context, global);
        } finally {
            Context.exit();
        }
View Full Code Here

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

        Context.setCachingEnabled(true)// enable caching again
        // entering a context
        Context ctx = enterContext();
        try {
            try {
                Scriptable scriptable = ctx.initStandardObjects(null, false);
                ScriptableObject.defineClass(scriptable, WindowWrapper.class);
            } catch (Exception e) {
                // cannot happen
            }
            // we now have the window object as the global object from the
View Full Code Here

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

    }

    private Scriptable getRootScope() {
        if (rootScope == null) {
            final Context rhinoContext = Context.enter();
            rootScope = rhinoContext.initStandardObjects();

            for (Class<?> clazz : HOSTOBJECT_CLASSES) {
                try {

                    // register the host object
View Full Code Here

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

        // build the code, something like
        //  data = <jsonData> ;
        //  <code>
        final String jsCode = "data=" + jsonData + ";\n" + code;
        final Context rhinoContext = Context.enter();
        final ScriptableObject scope = rhinoContext.initStandardObjects();

        // execute the script, out script variable maps to sw
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        ScriptableObject.putProperty(scope, "out", Context.javaToJS(pw, scope));
View Full Code Here

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

      boolean result = false;

      // now evaluate the condition using JavaScript
      Context cx = Context.enter();
      try {
          Scriptable scope = cx.initStandardObjects(null);
          Object cxResultObject =
            cx.evaluateString(scope, cond
          /*** conditionString ***/
          , "<cmd>", 1, null);
          resultStr = Context.toString(cxResultObject);
View Full Code Here

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

                Reader reader = new InputStreamReader(inputStream, "UTF-8");
                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 {
View Full Code Here

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

        }

        public XLoper execute(IFunctionContext context, XLoper[] args) throws RequestException {
            Context ctx = Context.enter();
            Object[] oargs = converter.convert(args, BSFScript.createArgHints(args));
            ScriptableObject so = ctx.initStandardObjects();
            Scriptable argsObj = ctx.newArray(so, oargs);
            so.defineProperty("args", argsObj, ScriptableObject.DONTENUM);
            try {
                return converter.createFrom(script.exec(ctx, so));
            } catch (Throwable t) {
View Full Code Here

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

    public Object evaluate(String script, String filename, Map<String, Object> args)
            throws ScriptException, Throwable {
        RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
        Context cx = factory.enterContext();
        ScriptableObject scriptable = new ImporterTopLevel(cx);
        Scriptable scope = cx.initStandardObjects(scriptable);

        for (Map.Entry<String, Object> entry : args.entrySet()) {
            ScriptableObject.putProperty(scope, entry.getKey(),
                    Context.javaToJS(entry.getValue(), scope));
        }
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.