]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/bootstrap.jsm
Import 1.0rc1 supporting Firefox up to 11.*
[dactyl.git] / common / modules / bootstrap.jsm
index d51f8696b1f7192c1c6a47577f01a8c8a7e312dc..4343ec215330129868fc4d6a859502f930e8f994 100644 (file)
@@ -2,7 +2,7 @@
 //
 // This work is licensed for reuse under an MIT license. Details are
 // given in the LICENSE.txt file included with this file.
-"use strict";
+/* use strict */
 
 try {
 
@@ -14,16 +14,11 @@ var BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
 var JSMLoader = BOOTSTRAP_CONTRACT in Components.classes &&
     Components.classes[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
 
-if (!JSMLoader && "@mozilla.org/fuel/application;1" in Components.classes)
-    JSMLoader = Components.classes["@mozilla.org/fuel/application;1"]
-                          .getService(Components.interfaces.extIApplication)
-                          .storage.get("dactyl.JSMLoader", null);
-
-if (JSMLoader && JSMLoader.bump === 5)
+if (JSMLoader && JSMLoader.bump === 6)
     JSMLoader.global = this;
 else
     JSMLoader = {
-        bump: 5,
+        bump: 6,
 
         builtin: Cu.Sandbox(this),
 
@@ -31,6 +26,8 @@ else
 
         factories: [],
 
+        name: "dactyl",
+
         global: this,
 
         globals: JSMLoader ? JSMLoader.globals : {},
@@ -133,6 +130,8 @@ else
         purge: function purge() {
             dump("dactyl: JSMLoader: purge\n");
 
+            this.bootstrap = null;
+
             if (Cu.unload) {
                 Object.keys(this.modules).reverse().forEach(function (url) {
                     try {
@@ -167,6 +166,24 @@ else
             }
         },
 
+        Factory: function Factory(clas) ({
+            __proto__: clas.prototype,
+
+            createInstance: function (outer, iid) {
+                try {
+                    if (outer != null)
+                        throw Cr.NS_ERROR_NO_AGGREGATION;
+                    if (!clas.instance)
+                        clas.instance = new clas();
+                    return clas.instance.QueryInterface(iid);
+                }
+                catch (e) {
+                    Cu.reportError(e);
+                    throw e;
+                }
+            }
+        }),
+
         registerFactory: function registerFactory(factory) {
             this.manager.registerFactory(factory.classID,
                                          String(factory.classID),