Package org.mozilla.javascript.tools.shell

Examples of org.mozilla.javascript.tools.shell.Global


   * @throws JsonParseException
   */
  public static void main(String[] args) {
    // Use Rhino's global object's as prototype for top scope because
    // logger.js assumes access to "print" function.
    Global global = new Global();
    Context cx = ContextFactory.getGlobal().enterContext();
    global.init(cx);

    // Set up standard scripts
    Scriptable topScope = cx.initStandardObjects(global);

    cx.getWrapFactory().setJavaPrimitiveWrap(false);
View Full Code Here


  public boolean executeBuild() {
    boolean buildCompleted = true;
   
    // Use Rhino's global object's as prototype for top scope because
    // logger.js assumes access to "print" function.
    Global global = new Global();
    Context cx = ContextFactory.getGlobal().enterContext();
    global.init(cx);

    // Set up standard scripts objects
    Scriptable topScope = cx.initStandardObjects(global);

    // Enforce conversion of the Java string arguments array to JavaScript native versions.
View Full Code Here

    }

    protected void begin_scenario(Scenario scenario) throws Throwable {
        clearHooksAndStepDefinitions();
        cx = Context.enter();
        scope = new Global(cx); // This gives us access to global functions like load()
        scope.put("jsLanguage", scope, this);
        cx.evaluateReader(scope, new InputStreamReader(getClass().getResourceAsStream(JS_DSL)), JS_DSL, 1, null);
        for (String jsFile : jsFiles) {
            cx.evaluateReader(scope, new FileReader(jsFile), jsFile, 1, null);
        }
View Full Code Here

        System.setIn(main.getIn());
        System.setOut(main.getOut());
        System.setErr(main.getErr());

        Global global = org.mozilla.javascript.tools.shell.Main.getGlobal();
        global.setIn(main.getIn());
        global.setOut(main.getOut());
        global.setErr(main.getErr());

        main.attachTo(
            org.mozilla.javascript.tools.shell.Main.shellContextFactory);

        main.setScope(global);
View Full Code Here

     * created {@link Global} object.  No I/O redirection is performed
     * as with {@link #main(String[])}.
     */
    public static void mainEmbedded(String title) {
        ContextFactory factory = ContextFactory.getGlobal();
        Global global = new Global();
        global.init(factory);
        mainEmbedded(factory, global, title);
    }
View Full Code Here

        if (scopeProvider instanceof ScopeProvider) {
            main.setScopeProvider((ScopeProvider)scopeProvider);
        } else {
            Scriptable scope = (Scriptable)scopeProvider;
            if (scope instanceof Global) {
                Global global = (Global)scope;
                global.setIn(main.getIn());
                global.setOut(main.getOut());
                global.setErr(main.getErr());
            }
            main.setScope(scope);
        }

        main.pack();
View Full Code Here

    }

    public static void run(final ShellContextFactory shellContextFactory,
            final File jsFile, final Parameters parameters,
            final Status status) throws Exception {
        final Global global = new Global();
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final PrintStream p = new PrintStream(out);
        global.setOut(p);
        global.setErr(p);
        global.defineFunctionProperties(
                new String[] { "options" }, ShellTest.class,
                ScriptableObject.DONTENUM | ScriptableObject.PERMANENT |
                  ScriptableObject.READONLY);
        // test suite expects keywords to be disallowed as identifiers
        shellContextFactory.setAllowReservedKeywords(false);
        final TestState testState = new TestState();
        if (jsFile.getName().endsWith("-n.js")) {
            status.setNegative();
        }
        final Throwable thrown[] = {null};

        Thread t = new Thread(new Runnable()
        {
            public void run()
            {
                try
                {
                    shellContextFactory.call(new ContextAction()
                    {
                        public Object run(Context cx)
                        {
                            status.running(jsFile);
                            testState.errors = new ErrorReporterWrapper(cx.getErrorReporter());
                            cx.setErrorReporter( testState.errors );
                            global.init(cx);
                            try {
                                runFileIfExists(cx, global, new File(jsFile.getParentFile().getParentFile().getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, new File(jsFile.getParentFile().getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, new File(jsFile.getParentFile(), "shell.js"));
                                runFileIfExists(cx, global, jsFile);
View Full Code Here

        JXPathIntrospector.registerDynamicClass(Scriptable.class,
                                                ScriptablePropertyHandler.class);
        JXPathContextReferenceImpl.addNodePointerFactory(new ScriptablePointerFactory());

        try {
            scope = new Global(context);
            // Access to Cocoon internal objects
            FOM_Cocoon.init(scope);
            errorReporter = new JSErrorReporter(getLogger());
        } catch (Exception e) {
            Context.exit();
View Full Code Here

        JXPathIntrospector.registerDynamicClass(Scriptable.class,
                                                ScriptablePropertyHandler.class);
        JXPathContextReferenceImpl.addNodePointerFactory(new ScriptablePointerFactory());

        try {
            scope = new Global(context);
            // Access to Cocoon internal objects
            FOM_Cocoon.init(scope);
            errorReporter = new JSErrorReporter(getLogger());
        } catch (Exception e) {
            Context.exit();
View Full Code Here

public class WrappingConsoleFactoryTest {
    @Test
    public void testGetConsoleAsScriptable() throws Exception {

        final Global globalScope = new Global();

        final WrappingConsoleProvider wrappingConsoleFactory =
                new WrappingConsoleProvider(new SystemOutConsole());

        ContextFactory contextFactory = new ContextFactory();
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.tools.shell.Global

Copyright © 2018 www.massapicom. 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.