Examples of initStandardObjects()


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, getCondition()
          /*** conditionString ***/
          , "<cmd>", 1, null);
          resultStr = Context.toString(cxResultObject);
View Full Code Here

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

    protected Scriptable scope;

    public JSOMElementConvertor() {
        Context cx = Context.enter();
        try {
            this.scope = cx.initStandardObjects();
        } finally {
            Context.exit();
        }
    }
View Full Code Here

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

        Context cx = Context.enter();
        try
        {

            Scriptable scope = cx.initStandardObjects(null);
            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null);

            resultStr = Context.toString(result);
            vars.put(varName, resultStr);
View Full Code Here

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

                    @Override
                    public RhinoExecutor invoke()
                    {
                        final Context context = contextFactory.enterContext();

                        final ScriptableObject scope = context.initStandardObjects();

                        try
                        {
                            context.setOptimizationLevel(-1);
View Full Code Here

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

    private void compileScripts() throws IOException {
        try {
            Context.enter();
            Context ctx = Context.getCurrentContext();
            ctx.setOptimizationLevel(-1);
            globalScope = ctx.initStandardObjects();
            RequireBuilder require = new RequireBuilder();
            require.setSandboxed(false);
            require.setModuleScriptProvider(new SoftCachingModuleScriptProvider(new ClasspathModuleSourceProvider()));
            require.createRequire(ctx, globalScope).install(globalScope);
            nodeScript = compile(ctx, "node.js");
View Full Code Here

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

    public CoffeeScriptCompiler(String version) {
        this.version = version;

        try {
            Context context = createContext();
            globalScope = context.initStandardObjects();
            final Require require = getSandboxedRequire(context, globalScope, true);
            coffeeScript = require.requireMain(context, "coffee-script");
        } catch (Exception e1) {
            throw new CoffeeScriptException("Unable to load the coffeeScript compiler into Rhino", e1);
        } finally {
View Full Code Here

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

public class ScriptTest1 {
    public static void main(String[] args) throws Exception {
        //VTCollection input = new VTCollection();
        Object[] input = {new Integer(4), new Integer(5)};
        Context cx = Context.enter();
        Scriptable scope = cx.initStandardObjects();
        Script sc = cx.compileReader(new FileReader("functions/sum.js"), "sum",
                1, null);
        ScriptableObject.putProperty(scope, "args", Context.javaToJS(input, scope));
        Object o = sc.exec(cx, scope);
        System.out.println(o);
View Full Code Here

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

        cx.setErrorReporter(reporter);
        try {
            // Initialize the standard objects (Object, Function, etc.)
            // This must be done before scripts can be executed.
            RhinoRunner runner = new RhinoRunner();
            cx.initStandardObjects(runner);

            // Define some global functions particular to the BasicRhinoShell.
            // Note
            // that these functions are not part of ECMA.
            String[] names = { "print", "load", "readFile", "warn", "getResourceAsStream" };
View Full Code Here

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

    public JSRunner()
    {
        Context context = Context.enter();
        context.setOptimizationLevel(-1); // Without this, Rhino hits a 64K bytecode limit and fails
        try {
            globalScope = context.initStandardObjects();
           
            String[] names = { "print", "load", "readFile", "warn", "getResourceAsStream" };
            globalScope.defineFunctionProperties(names, JSRunner.class, ScriptableObject.DONTENUM);
           
        } finally {
View Full Code Here

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

  private void init(final Class<?> clazz) {
    final Context context = Context.enter();
    context.setOptimizationLevel(this.optimizationLevel);
    context.setLanguageVersion(Context.VERSION_1_7);
    final ScriptableObject scope = context.initStandardObjects();
    final Require require = new Require(Context.getCurrentContext(), scope,
        getModuleScriptProvider(clazz), null, null, false);
    require.install(scope);
    try {
      this.moduleScope = new ModuleScope(scope, new URI("./" + this.name), 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.