Package org.mozilla.javascript

Examples of org.mozilla.javascript.ImporterTopLevel


    public RhinoInterpreter() {
        // entering a context
        context = Context.enter();
        try {
            // init std object with an importer
            ImporterTopLevel importer = new ImporterTopLevel(context);
            globalObject = (ScriptableObject)context.initStandardObjects(importer);
            // import Java lang package & DOM Level 2 & SVG DOM packages
            NativeJavaPackage[] p= new NativeJavaPackage[TO_BE_IMPORTED.length];
            for (int i = 0; i < TO_BE_IMPORTED.length; i++) {
                p[i] = new NativeJavaPackage(TO_BE_IMPORTED[i]);
            }
            importer.importPackage(context, globalObject, p, null);
            context.setWrapHandler(new EventTargetWrapHandler(this));
        } finally {
            Context.exit();
        }
    }
View Full Code Here


        return getContext().newArray(scope, (int)size);
    }

    public JsScriptEngine() {
        Context context = getContext();
        scope = new ImporterTopLevel(context); // so that we can use importPackage()
        context.evaluateString(scope, printSource, "print", 1, null); // so that we can print on std out

    }
View Full Code Here

        super.initialize(mgr, lang, declaredBeans);

        // Initialize context and global scope object
        try {
            Context cx = Context.enter();
            global = new ImporterTopLevel(cx);
            Scriptable bsf = cx.toObject(new BSFFunctions(mgr, this), global);
            global.put("bsf", global, bsf);

            int size = declaredBeans.size();
            for (int i = 0; i < size; i++) {
View Full Code Here

    this.scope = scope;
    this.engine = null;
  }
 
  public RhinoNamespaceBridge(RhinoScriptEngine engine) {
    ImporterTopLevel importer = new ImporterTopLevel();
    Context cx = Context.getCurrentContext();
   
    /* CHECK ME */
    if (cx == null) {
      try {
        cx = Context.enter();
        importer.initStandardObjects(cx, false);
        Context.exit();
      } catch (Exception ex) {
        System.err.println("Error : " + ex.getMessage());
      }
    } else {
      importer.initStandardObjects(cx, false);
    }
    this.scope = importer;
    this.engine = engine;
    this.engineNamespace = null
  }
View Full Code Here

    this.engine = engine;
    this.engineNamespace = null
  }
 
  public RhinoNamespaceBridge(Namespace engineNamespace) {
    ImporterTopLevel importer = new ImporterTopLevel();
    Context cx = Context.getCurrentContext();
   
    /* CHECK ME */
    if (cx == null) {
      try {
        cx = Context.enter();
        importer.initStandardObjects(cx, false);
        Context.exit();     
      } catch (Exception ex) {
        System.err.println("Error : " + ex.getMessage());
      }
    } else {
      importer.initStandardObjects(cx, false);
    }
   
    this.scope = importer;
    this.engineNamespace = engineNamespace;
    this.engine = null
View Full Code Here

    public RhinoInterpreter() {
        // entering a context
        context = Context.enter();
        // init std object with an importer
        ImporterTopLevel importer = new ImporterTopLevel();
        scope = context.initStandardObjects(importer);
        // import Java lang package & DOM Level 2 & SVG DOM packages
        NativeJavaPackage[] p={new NativeJavaPackage("java.lang"),
                               new NativeJavaPackage("org.w3c.dom"),
                               new NativeJavaPackage("org.w3c.dom.css"),
                               new NativeJavaPackage("org.w3c.dom.events"),
                               new NativeJavaPackage("org.w3c.dom.smil"),
                               new NativeJavaPackage("org.w3c.dom.stylesheets"),
                               new NativeJavaPackage("org.w3c.dom.svg"),
                               new NativeJavaPackage("org.w3c.dom.views")};
        importer.importPackage(context, scope, p, null);
        context.setWrapHandler(new EventTargetWrapHandler(this));
        Context.exit();
    }
View Full Code Here

  private final ScriptableObject parent;
  private final Map<String, Script> mapping = new HashMap<String, Script>();
 
  public ScriptLoader() throws Exception {
    Context cx = ContextFactory.getGlobal().enterContext();
    this.parent = new ImporterTopLevel(cx);
    cx.initStandardObjects(parent);
   
    register("require", new Callable() {
      public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] params) {
        try {
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ImporterTopLevel

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.