michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozilla/ModuleUtils.h" michael@0: #include "nsIClassInfoImpl.h" michael@0: michael@0: #include "nsSample.h" michael@0: michael@0: //////////////////////////////////////////////////////////////////////// michael@0: // With the below sample, you can define an implementation glue michael@0: // that talks with xpcom for creation of component nsSampleImpl michael@0: // that implement the interface nsISample. This can be extended for michael@0: // any number of components. michael@0: //////////////////////////////////////////////////////////////////////// michael@0: michael@0: //////////////////////////////////////////////////////////////////////// michael@0: // Define the contructor function for the object nsSampleImpl michael@0: // michael@0: // What this does is defines a function nsSampleImplConstructor which we michael@0: // will specific in the nsModuleComponentInfo table. This function will michael@0: // be used by the generic factory to create an instance of nsSampleImpl. michael@0: // michael@0: // NOTE: This creates an instance of nsSampleImpl by using the default michael@0: // constructor nsSampleImpl::nsSampleImpl() michael@0: // michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleImpl) michael@0: michael@0: // The following line defines a kNS_SAMPLE_CID CID variable. michael@0: NS_DEFINE_NAMED_CID(NS_SAMPLE_CID); michael@0: michael@0: // Build a table of ClassIDs (CIDs) which are implemented by this module. CIDs michael@0: // should be completely unique UUIDs. michael@0: // each entry has the form { CID, service, factoryproc, constructorproc } michael@0: // where factoryproc is usually nullptr. michael@0: static const mozilla::Module::CIDEntry kSampleCIDs[] = { michael@0: { &kNS_SAMPLE_CID, false, nullptr, nsSampleImplConstructor }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: // Build a table which maps contract IDs to CIDs. michael@0: // A contract is a string which identifies a particular set of functionality. In some michael@0: // cases an extension component may override the contract ID of a builtin gecko component michael@0: // to modify or extend functionality. michael@0: static const mozilla::Module::ContractIDEntry kSampleContracts[] = { michael@0: { NS_SAMPLE_CONTRACTID, &kNS_SAMPLE_CID }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: // Category entries are category/key/value triples which can be used michael@0: // to register contract ID as content handlers or to observe certain michael@0: // notifications. Most modules do not need to register any category michael@0: // entries: this is just a sample of how you'd do it. michael@0: // @see nsICategoryManager for information on retrieving category data. michael@0: static const mozilla::Module::CategoryEntry kSampleCategories[] = { michael@0: { "my-category", "my-key", NS_SAMPLE_CONTRACTID }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: static const mozilla::Module kSampleModule = { michael@0: mozilla::Module::kVersion, michael@0: kSampleCIDs, michael@0: kSampleContracts, michael@0: kSampleCategories michael@0: }; michael@0: michael@0: // The following line implements the one-and-only "NSModule" symbol exported from this michael@0: // shared library. michael@0: NSMODULE_DEFN(nsSampleModule) = &kSampleModule; michael@0: michael@0: // The following line implements the one-and-only "NSGetModule" symbol michael@0: // for compatibility with mozilla 1.9.2. You should only use this michael@0: // if you need a binary which is backwards-compatible and if you use michael@0: // interfaces carefully across multiple versions. michael@0: NS_IMPL_MOZILLA192_NSGETMODULE(&kSampleModule)