X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fmodules%2Fbootstrap.jsm;fp=common%2Fmodules%2Fbootstrap.jsm;h=4343ec215330129868fc4d6a859502f930e8f994;hb=9044153cb63835e39b9de8ec4ade237c03e3888a;hp=d51f8696b1f7192c1c6a47577f01a8c8a7e312dc;hpb=70740024f9c028c1fd63e1a1850ab062ff956054;p=dactyl.git diff --git a/common/modules/bootstrap.jsm b/common/modules/bootstrap.jsm index d51f869..4343ec2 100644 --- a/common/modules/bootstrap.jsm +++ b/common/modules/bootstrap.jsm @@ -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),