Bug 568691 part A - register static and binary components using data tables rather than programmatic nsIComponentRegistrar methods. This part contains the important needs-review bits of the change: part B contains the mechanical changes to each module in order to actually get a working build. Part C will contain changes necessary to register JS components from .manifest files

This commit is contained in:
Benjamin Smedberg
2010-06-10 14:11:11 -04:00
parent f845fed30a
commit 0e824d90bb
150 changed files with 2511 additions and 9343 deletions

View File

@@ -35,18 +35,12 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "mozilla/ModuleUtils.h"
#include "nsIClassInfoImpl.h"
#include "nsSample.h"
////////////////////////////////////////////////////////////////////////
// NOTE this file supersedes nsSampleFactory.cpp. nsSampleFactory has
// extensive comments, but it has been CVS removed to reduce clutter
// in this sample. It's available to the interested via CVS history:
// cvs up nsSampleFactory.cpp -r 1.10
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// With the below sample, you can define an implementation glue
// that talks with xpcom for creation of component nsSampleImpl
@@ -66,67 +60,44 @@
//
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleImpl)
////////////////////////////////////////////////////////////////////////
// Define a table of CIDs implemented by this module along with other
// information like the function to create an instance, contractid, and
// class name.
//
// The Registration and Unregistration proc are optional in the structure.
//
static NS_METHOD nsSampleRegistrationProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const char *componentType,
const nsModuleComponentInfo *info)
{
// Do any registration specific activity like adding yourself to a
// category. The Generic Module will take care of registering your
// component with xpcom. You don't need to do that. Only any component
// specific additional activity needs to be done here.
// The following line defines a kNS_SAMPLE_CID CID variable.
NS_DEFINE_NAMED_CID(NS_SAMPLE_CID);
// This functions is optional. If you don't need it, don't add it to the structure.
return NS_OK;
}
static NS_METHOD nsSampleUnregistrationProc(nsIComponentManager *aCompMgr,
nsIFile *aPath,
const char *registryLocation,
const nsModuleComponentInfo *info)
{
// Undo any component specific registration like adding yourself to a
// category here. The Generic Module will take care of unregistering your
// component from xpcom. You don't need to do that. Only any component
// specific additional activity needs to be done here.
// This functions is optional. If you don't need it, don't add it to the structure.
// Return value is not used from this function.
return NS_OK;
}
// For each class that wishes to support nsIClassInfo, add a line like this
NS_DECL_CLASSINFO(nsSampleImpl)
static const nsModuleComponentInfo components[] =
{
{ "Sample Component", NS_SAMPLE_CID, NS_SAMPLE_CONTRACTID, nsSampleImplConstructor,
nsSampleRegistrationProc /* NULL if you don't need one */,
nsSampleUnregistrationProc /* NULL if you don't need one */,
NULL /* no factory destructor */,
NS_CI_INTERFACE_GETTER_NAME(nsSampleImpl),
NULL /* no language helper */,
&NS_CLASSINFO_NAME(nsSampleImpl)
}
// Build a table of ClassIDs (CIDs) which are implemented by this module. CIDs
// should be completely unique UUIDs.
// each entry has the form { CID, service, factoryproc, constructorproc }
// where factoryproc is usually NULL.
static const mozilla::Module::CIDEntry kSampleCIDs[] = {
{ &kNS_SAMPLE_CID, false, NULL, nsSampleImplConstructor },
{ NULL }
};
////////////////////////////////////////////////////////////////////////
// Implement the NSGetModule() exported function for your module
// and the entire implementation of the module object.
//
// NOTE: If you want to use the module shutdown to release any
// module specific resources, use the macro
// NS_IMPL_NSGETMODULE_WITH_DTOR() instead of the vanilla
// NS_IMPL_NSGETMODULE()
//
NS_IMPL_NSGETMODULE(nsSampleModule, components)
// Build a table which maps contract IDs to CIDs.
// A contract is a string which identifies a particular set of functionality. In some
// cases an extension component may override the contract ID of a builtin gecko component
// to modify or extend functionality.
static const mozilla::Module::ContractIDEntry kSampleContracts[] = {
{ NS_SAMPLE_CONTRACTID, &kNS_SAMPLE_CID },
{ NULL }
};
// Category entries are category/key/value triples which can be used
// to register contract ID as content handlers or to observe certain
// notifications. Most modules do not need to register any category
// entries: this is just a sample of how you'd do it.
// @see nsICategoryManager for information on retrieving category data.
static const mozilla::Module::CategoryEntry kSampleCategories[] = {
{ "my-category", "my-key", NS_SAMPLE_CONTRACTID },
{ NULL }
};
static const mozilla::Module kSampleModule = {
mozilla::Module::kVersion,
kSampleCIDs,
kSampleContracts,
kSampleCategories
};
// The following line implements the one-and-only "NSModule" symbol exported from this
// shared library.
NSMODULE_DEFN(nsSampleModule) = &kSampleModule;