зеркало из https://github.com/mozilla/gecko-dev.git
Fix XULRunner simple example from bug 568691.
This commit is contained in:
Родитель
2b520c0d73
Коммит
f004b53e62
|
@ -55,6 +55,6 @@ EXTRA_DSO_LDOPTS = \
|
|||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_COMPONENTS = $(srcdir)/SimpleTest.js
|
||||
EXTRA_COMPONENTS = SimpleTest.js SimpleTest.manifest
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "nsISimpleTest.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
|
||||
class SimpleTest : public nsISimpleTest
|
||||
{
|
||||
|
@ -64,13 +64,22 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(SimpleTest)
|
|||
{ 0x5e14b432, 0x37b6, 0x4377, \
|
||||
{ 0x92, 0x3b, 0xc9, 0x87, 0x41, 0x8d, 0x84, 0x29 } }
|
||||
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "SimpleTest in C++",
|
||||
SIMPLETEST_CID,
|
||||
"@test.mozilla.org/simple-test;1?impl=c++",
|
||||
SimpleTestConstructor
|
||||
}
|
||||
NS_DEFINE_NAMED_CID(SIMPLETEST_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kSimpleCIDs[] = {
|
||||
{ &kSIMPLETEST_CID, false, NULL, SimpleTestConstructor },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(SimpleTestModule, components)
|
||||
static const mozilla::Module::ContractIDEntry kSimpleContracts[] = {
|
||||
{ "@test.mozilla.org/simple-test;1?impl=c++", &kSIMPLETEST_CID },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const mozilla::Module kSimpleModule = {
|
||||
mozilla::Module::kVersion,
|
||||
kSimpleCIDs,
|
||||
kSimpleContracts
|
||||
};
|
||||
|
||||
NSMODULE_DEFN(SimpleTestModule) = &kSimpleModule;
|
||||
|
|
|
@ -35,13 +35,14 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const SIMPLETEST_CONTRACTID = "@test.mozilla.org/simple-test;1?impl=js";
|
||||
const SIMPLETEST_CLASSID = Components.ID("{4177e257-a0dc-49b9-a774-522a000a49fa}");
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function SimpleTest() {
|
||||
}
|
||||
|
||||
SimpleTest.prototype = {
|
||||
classID: Components.ID("{4177e257-a0dc-49b9-a774-522a000a49fa}"),
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsISimpleTest) ||
|
||||
iid.equals(Components.interfaces.nsISupports))
|
||||
|
@ -55,54 +56,4 @@ SimpleTest.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
var Module = {
|
||||
_classes: {
|
||||
simpletest: {
|
||||
classID : SIMPLETEST_CLASSID,
|
||||
contractID : SIMPLETEST_CONTRACTID,
|
||||
className : "SimpleTest",
|
||||
factory : {
|
||||
createInstance: function(delegate, iid) {
|
||||
if (delegate)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
return new SimpleTest().QueryInterface(iid);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
registerSelf: function(compMgr, fileSpec, location, type)
|
||||
{
|
||||
var reg = compMgr.QueryInterface(
|
||||
Components.interfaces.nsIComponentRegistrar);
|
||||
|
||||
for (var key in this._classes) {
|
||||
var c = this._classes[key];
|
||||
reg.registerFactoryLocation(c.classID, c.className, c.contractID,
|
||||
fileSpec, location, type);
|
||||
}
|
||||
},
|
||||
|
||||
getClassObject: function(compMgr, cid, iid)
|
||||
{
|
||||
if (!iid.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
for (var key in this._classes) {
|
||||
var c = this._classes[key];
|
||||
if (cid.equals(c.classID))
|
||||
return c.factory;
|
||||
}
|
||||
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
canUnload: function (aComponentManager)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return Module;
|
||||
}
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([SimpleTest]);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
component {4177e257-a0dc-49b9-a774-522a000a49fa} SimpleTest.js
|
||||
contract @test.mozilla.org/simple-test;1?impl=js {4177e257-a0dc-49b9-a774-522a000a49fa}
|
Загрузка…
Ссылка в новой задаче