Skip to content
Browse files

FIX: components changes needed by firefox4/gecko2

  • Loading branch information...
1 parent a009edf commit 52ea51f9e2ebe652981ddfd958a1be33533524f5 @rpl committed Jul 25, 2010
Showing with 66 additions and 136 deletions.
  1. +9 −0 chrome.manifest
  2. +31 −70 components/CommandLine.js
  3. +26 −66 components/MozRepl.js
View
9 chrome.manifest
@@ -4,3 +4,12 @@ skin mozrepl classic/1.0 chrome/skin/classic/
overlay chrome://browser/content/browser.xul chrome://mozrepl/content/overlay_browser.xul
overlay chrome://messenger/content/messenger.xul chrome://mozrepl/content/overlay_mail.xul
overlay chrome://songbird/content/xul/menuOverlay.xul chrome://mozrepl/conte/overlay_songbird.xul
+
+interfaces components/MozRepl.xpt
+component {57f4284b-1f9b-4990-8525-9ed5cbb23e01} components/MozRepl.js
+contract @hyperstruct.net/mozlab/mozrepl;1 {57f4284b-1f9b-4990-8525-9ed5cbb23e01}
+category profile-after-change nsIMozRepl @hyperstruct.net/mozlab/mozrepl;1
+
+component {f62cbe68-ee70-4264-8586-66df185244f5} components/CommandLine.js
+contract @mozilla.org/commandlinehandler/general-startup;1?type=repl {f62cbe68-ee70-4264-8586-66df185244f5}
+category command-line-handler mozrepl @mozilla.org/commandlinehandler/general-startup;1?type=repl
View
101 components/CommandLine.js
@@ -7,82 +7,43 @@ const Ci = Components.interfaces;
const Cr = Components.results;
const CLASS_ID = Components.ID('{f62cbe68-ee70-4264-8586-66df185244f5}');
-const Handler = {
- QueryInterface: function(iid) {
- if(iid.equals(Ci.nsICommandLineHandler) ||
- iid.equals(Ci.nsIFactory) ||
- iid.equals(Ci.nsISupports))
- return this;
+const INTERFACE = Ci.nsICommandLineHandler;
- throw Cr.NS_ERROR_NO_INTERFACE;
- },
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
- handle: function(cmdLine) {
- var uri;
- try {
- uri = cmdLine.handleFlagWithParam('repl', false);
- } catch (e) {
- }
+function MozReplCommandLineHandler() {
- if(uri || cmdLine.handleFlag('repl', false))
- Cc['@hyperstruct.net/mozlab/mozrepl;1']
- .getService(Ci.nsIMozRepl)
- .start(uri ? parseInt(uri) : 4242);
- },
-
- helpInfo: '-repl Start REPL.\n',
-
- createInstance: function(outer, iid) {
- if(outer != null)
- throw Cr.NS_ERROR_NO_AGGREGATION;
-
- return this.QueryInterface(iid);
- },
+}
- lockFactory: function(lock) {
- /* no-op */
+MozReplCommandLineHandler.prototype = {
+ classDescription: "MozREPL command line handler",
+ classID: CLASS_ID,
+ contactID: CONTRACT_ID,
+ QueryInterface: XPCOMUtils.generateQI([
+ Ci.nsICommandLineHandler
+ ]),
+
+ handle: function(cmdLine) {
+ var uri;
+ try {
+ uri = cmdLine.handleFlagWithParam('repl', false);
+ } catch (e) {
}
-};
-
-
-const Module = {
- QueryInterface: function(iid) {
- if(iid.equals(Ci.nsIModule) ||
- iid.equals(Ci.nsISupports))
- return this;
-
- throw Cr.NS_ERROR_NO_INTERFACE;
- },
- getClassObject: function(compMgr, cid, iid) {
- if(cid.equals(CLASS_ID))
- return Handler.QueryInterface(iid);
+ if(uri || cmdLine.handleFlag('repl', false))
+ Cc['@hyperstruct.net/mozlab/mozrepl;1']
+ .getService(Ci.nsIMozRepl)
+ .start(uri ? parseInt(uri) : 4242);
+ },
- throw Cr.NS_ERROR_NOT_REGISTERED;
- },
-
- registerSelf: function(compMgr, fileSpec, location, type) {
- compMgr.QueryInterface(Ci.nsIComponentRegistrar);
- compMgr.registerFactoryLocation(CLASS_ID, 'Handler', CONTRACT_ID, fileSpec, location, type);
-
- var catMan = Cc['@mozilla.org/categorymanager;1'].getService(Ci.nsICategoryManager);
- catMan.addCategoryEntry('command-line-handler', CATEGORY, CONTRACT_ID, true, true);
- },
-
- unregisterSelf: function mod_unreg(compMgr, location, type) {
- compMgr.QueryInterface(Ci.nsIComponentRegistrar);
- compMgr.unregisterFactoryLocation(CLASS_ID, location);
-
- var catMan = Cc['@mozilla.org/categorymanager;1'].getService(Ci.nsICategoryManager);
- catMan.deleteCategoryEntry('command-line-handler', CATEGORY);
- },
-
- canUnload: function (compMgr) {
- return true;
- }
+ helpInfo: '-repl Start REPL.\n'
};
-function NSGetModule(comMgr, fileSpec) {
- return Module;
-}
-
+/**
+* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
+* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
+*/
+if (XPCOMUtils.generateNSGetFactory)
+ var NSGetFactory = XPCOMUtils.generateNSGetFactory([MozReplCommandLineHandler]);
+else
+ var NSGetModule = XPCOMUtils.generateNSGetModule([MozReplCommandLineHandler]);
View
92 components/MozRepl.js
@@ -17,73 +17,33 @@ const Cu = Components.utils;
const loader = Cc['@mozilla.org/moz/jssubscript-loader;1']
.getService(Ci.mozIJSSubScriptLoader);
-function Component() {
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+function MozRepl() {
this.wrappedJSObject = this;
}
-Component.prototype = {
- reload: function() {
- loader.loadSubScript(SOURCE, this.__proto__);
- },
-
- QueryInterface: function(aIID) {
- if(!aIID.equals(INTERFACE) &&
- !aIID.equals(Ci.nsISupports) &&
- !aIID.equals(Ci.nsIObserver))
- throw Cr.NS_ERROR_NO_INTERFACE;
- return this;
- }
-};
-loader.loadSubScript(SOURCE, Component.prototype);
-
-var Factory = {
- createInstance: function(aOuter, aIID) {
- if(aOuter != null)
- throw Cr.NS_ERROR_NO_AGGREGATION;
- var component = new Component();
-
- return component.QueryInterface(aIID);
- }
+MozRepl.prototype = {
+ classDescription: CLASS_NAME,
+ classID: CLASS_ID,
+ contactID: CONTRACT_ID,
+ QueryInterface: XPCOMUtils.generateQI([
+ INTERFACE,
+ Ci.nsISupports,
+ Ci.nsIObserver
+ ]),
+
+ reload: function() {
+ loader.loadSubScript(SOURCE, this.__proto__);
+ }
};
-
-var Module = {
- _firstTime: true,
-
- registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) {
- if (this._firstTime) {
- this._firstTime = false;
- throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
- };
-
- aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
- aCompMgr.registerFactoryLocation(
- CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
-
- var catMan = Cc['@mozilla.org/categorymanager;1'].
- getService(Ci.nsICategoryManager);
- catMan.addCategoryEntry('app-startup', 'MozRepl', 'service,' + CONTRACT_ID, true, true);
- },
-
- unregisterSelf: function(aCompMgr, aLocation, aType) {pp
- aCompMgr = aCompMgr.QueryInterface(Ci.nsIComponentRegistrar);
- aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
-
- var catMan = Cc['@mozilla.org/categorymanager;1'].
- getService(Ci.nsICategoryManager);
- catMan.deleteCategoryEntry('app-startup', 'service,' + CONTRACT_ID, true);
- },
-
- getClassObject: function(aCompMgr, aCID, aIID) {
- if (!aIID.equals(Ci.nsIFactory))
- throw Cr.NS_ERROR_NOT_IMPLEMENTED;
-
- if (aCID.equals(CLASS_ID))
- return Factory;
-
- throw Cr.NS_ERROR_NO_INTERFACE;
- },
-
- canUnload: function(aCompMgr) { return true; }
-};
-
-function NSGetModule(aCompMgr, aFileSpec) { return Module; }
+loader.loadSubScript(SOURCE, MozRepl.prototype);
+
+/**
+* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4).
+* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6).
+*/
+if (XPCOMUtils.generateNSGetFactory)
+ var NSGetFactory = XPCOMUtils.generateNSGetFactory([MozRepl]);
+else
+ var NSGetModule = XPCOMUtils.generateNSGetModule([MozRepl]);

0 comments on commit 52ea51f

Please sign in to comment.
Something went wrong with that request. Please try again.