2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:21:17 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-02-26 07:05:14 +03:00
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-02-26 07:05:14 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-02-26 07:05:14 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:21:17 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:43:54 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2005-07-21 17:33:43 +04:00
|
|
|
* Benjamin Smedberg <benjamin@smedbergs.us>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:21:17 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:21:17 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:21:17 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-26 07:05:14 +03:00
|
|
|
|
|
|
|
#ifndef nsIGenericFactory_h___
|
|
|
|
#define nsIGenericFactory_h___
|
|
|
|
|
|
|
|
#include "nsIFactory.h"
|
2002-02-05 04:38:43 +03:00
|
|
|
#include "nsIModule.h"
|
2002-09-27 17:07:01 +04:00
|
|
|
#include "nsIClassInfo.h"
|
1999-02-26 07:05:14 +03:00
|
|
|
|
2005-07-21 17:33:43 +04:00
|
|
|
class nsIFile;
|
|
|
|
class nsIComponentManager;
|
|
|
|
|
1999-02-26 07:05:14 +03:00
|
|
|
// {3bc97f01-ccdf-11d2-bab8-b548654461fc}
|
2001-07-31 23:05:34 +04:00
|
|
|
#define NS_GENERICFACTORY_CID \
|
|
|
|
{ 0x3bc97f01, 0xccdf, 0x11d2, \
|
|
|
|
{ 0xba, 0xb8, 0xb5, 0x48, 0x65, 0x44, 0x61, 0xfc } }
|
1999-02-26 07:05:14 +03:00
|
|
|
|
|
|
|
// {3bc97f00-ccdf-11d2-bab8-b548654461fc}
|
2001-07-31 23:05:34 +04:00
|
|
|
#define NS_IGENERICFACTORY_IID \
|
|
|
|
{ 0x3bc97f00, 0xccdf, 0x11d2, \
|
|
|
|
{ 0xba, 0xb8, 0xb5, 0x48, 0x65, 0x44, 0x61, 0xfc } }
|
1999-02-26 07:05:14 +03:00
|
|
|
|
2000-09-14 03:57:52 +04:00
|
|
|
#define NS_GENERICFACTORY_CONTRACTID "@mozilla.org/generic-factory;1"
|
1999-05-28 02:47:27 +04:00
|
|
|
#define NS_GENERICFACTORY_CLASSNAME "Generic Factory"
|
2001-03-12 23:43:02 +03:00
|
|
|
|
|
|
|
struct nsModuleComponentInfo; // forward declaration
|
|
|
|
|
1999-02-26 07:05:14 +03:00
|
|
|
/**
|
|
|
|
* Provides a Generic nsIFactory implementation that can be used by
|
|
|
|
* DLLs with very simple factory needs.
|
|
|
|
*/
|
|
|
|
class nsIGenericFactory : public nsIFactory {
|
|
|
|
public:
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGENERICFACTORY_IID)
|
1999-02-26 07:05:14 +03:00
|
|
|
|
2002-01-30 07:05:47 +03:00
|
|
|
NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info) = 0;
|
|
|
|
NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop) = 0;
|
1999-02-26 07:05:14 +03:00
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIGenericFactory, NS_IGENERICFACTORY_IID)
|
|
|
|
|
2007-04-02 19:29:41 +04:00
|
|
|
#ifndef XPCOM_GLUE_AVOID_NSPR
|
2004-10-29 23:43:51 +04:00
|
|
|
NS_COM_GLUE nsresult
|
2001-03-12 23:43:02 +03:00
|
|
|
NS_NewGenericFactory(nsIGenericFactory **result,
|
2002-01-30 07:05:47 +03:00
|
|
|
const nsModuleComponentInfo *info);
|
2007-04-02 19:29:41 +04:00
|
|
|
#endif
|
2001-03-12 23:43:02 +03:00
|
|
|
|
1999-05-26 05:38:36 +04:00
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
/** Component Callbacks **/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* NSConstructorProcPtr
|
|
|
|
*
|
|
|
|
* This function will be used by the generic factory to create an
|
|
|
|
* instance of the given CID.
|
|
|
|
*
|
|
|
|
* @param aOuter : Pointer to a component that wishes to be aggregated
|
|
|
|
* in the resulting instance. This will be nsnull if no
|
|
|
|
* aggregation is requested.
|
|
|
|
* @param iid : The IID of the interface being requested in
|
|
|
|
* the component which is being currently created.
|
|
|
|
* @param result : [out] Pointer to the newly created instance, if successful.
|
|
|
|
*
|
|
|
|
* @return NS_OK Component successfully created and the interface
|
|
|
|
* being requested was successfully returned in result.
|
|
|
|
* NS_NOINTERFACE Interface not accessible.
|
|
|
|
* NS_ERROR_NO_AGGREGATION if an 'outer' object is supplied, but the
|
|
|
|
* component is not aggregatable.
|
|
|
|
* NS_ERROR* Method failure.
|
|
|
|
**/
|
|
|
|
typedef NS_CALLBACK(NSConstructorProcPtr)(nsISupports *aOuter,
|
|
|
|
REFNSIID aIID,
|
2001-07-31 23:05:34 +04:00
|
|
|
void **aResult);
|
2001-03-12 23:43:02 +03:00
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
/**
|
|
|
|
* NSRegisterSelfProcPtr
|
|
|
|
*
|
|
|
|
* One time registration call back. Allows you to perform registration
|
|
|
|
* specific activity like adding yourself to a category.
|
|
|
|
*
|
|
|
|
* @param aCompMgr : The global component manager
|
|
|
|
* @param aFile : Component File. This file must have an associated
|
|
|
|
* loader and export the required symbols which this
|
|
|
|
* loader defines.
|
|
|
|
* @param aLoaderStr : Opaque loader specific string. This value is
|
|
|
|
* passed into the nsIModule's registerSelf
|
|
|
|
* callback and must be fowarded unmodified when
|
|
|
|
* registering factories via their location.
|
|
|
|
* @param aType : Component Type of CID aClass. This value is
|
|
|
|
* passed into the nsIModule's registerSelf
|
|
|
|
* callback and must be fowarded unmodified when
|
|
|
|
* registering factories via their location.
|
|
|
|
* @param aInfo : Pointer to array of nsModuleComponentInfo
|
|
|
|
*
|
|
|
|
* @param aInfo
|
|
|
|
* @return NS_OK Registration was successful.
|
|
|
|
* NS_ERROR* Method failure.
|
|
|
|
**/
|
2001-07-31 23:05:34 +04:00
|
|
|
typedef NS_CALLBACK(NSRegisterSelfProcPtr)(nsIComponentManager *aCompMgr,
|
|
|
|
nsIFile *aPath,
|
2002-02-05 04:38:43 +03:00
|
|
|
const char *aLoaderStr,
|
|
|
|
const char *aType,
|
2001-08-07 06:55:54 +04:00
|
|
|
const nsModuleComponentInfo *aInfo);
|
2000-01-12 00:18:55 +03:00
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
/**
|
|
|
|
* NSUnregisterSelfProcPtr
|
|
|
|
*
|
|
|
|
* One time unregistration call back. Allows you to perform unregistration
|
|
|
|
* specific activity like removing yourself from a category.
|
|
|
|
*
|
|
|
|
* @param aCompMgr : The global component manager
|
|
|
|
* @param aFile : Component File. This file must have an associated
|
|
|
|
* loader and export the required symbols which this
|
|
|
|
* loader defines.
|
|
|
|
* @param aLoaderStr : Opaque loader specific string. This value is
|
|
|
|
* passed into the nsIModule's registerSelf
|
|
|
|
* callback and must be fowarded unmodified when
|
|
|
|
* registering factories via their location
|
|
|
|
* @param aInfo : Pointer to array of nsModuleComponentInfo
|
|
|
|
*
|
|
|
|
* @param aInfo
|
|
|
|
* @return NS_OK Registration was successful.
|
|
|
|
* NS_ERROR* Method failure.
|
|
|
|
|
|
|
|
**/
|
2001-07-31 23:05:34 +04:00
|
|
|
typedef NS_CALLBACK(NSUnregisterSelfProcPtr)(nsIComponentManager *aCompMgr,
|
|
|
|
nsIFile *aPath,
|
2002-02-05 04:38:43 +03:00
|
|
|
const char *aLoaderStr,
|
2001-08-07 06:55:54 +04:00
|
|
|
const nsModuleComponentInfo *aInfo);
|
2001-03-12 23:43:02 +03:00
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
/**
|
|
|
|
* NSFactoryDestructorProcPtr
|
|
|
|
*
|
|
|
|
* This function will be called when the factory is being destroyed.
|
|
|
|
*
|
|
|
|
**/
|
2001-07-31 23:05:34 +04:00
|
|
|
typedef NS_CALLBACK(NSFactoryDestructorProcPtr)(void);
|
2001-03-12 23:43:02 +03:00
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* NSGetInterfacesProcPtr
|
|
|
|
*
|
|
|
|
* This function is used to implement class info.
|
|
|
|
*
|
|
|
|
* Get an ordered list of the interface ids that instances of the class
|
|
|
|
* promise to implement. Note that nsISupports is an implicit member
|
|
|
|
* of any such list and need not be included.
|
|
|
|
*
|
|
|
|
* Should set *count = 0 and *array = null and return NS_OK if getting the
|
|
|
|
* list is not supported.
|
|
|
|
*
|
|
|
|
* @see nsIClassInfo.idl
|
|
|
|
**/
|
2008-12-11 23:13:52 +03:00
|
|
|
typedef NS_CALLBACK(NSGetInterfacesProcPtr)(PRUint32 * NS_OUTPARAM countp,
|
|
|
|
nsIID* ** NS_OUTPARAM array);
|
2001-03-12 23:43:02 +03:00
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
/**
|
|
|
|
* NSGetLanguageHelperProcPtr
|
|
|
|
*
|
|
|
|
* This function is used to implement class info.
|
|
|
|
*
|
|
|
|
* Get a language mapping specific helper object that may assist in using
|
|
|
|
* objects of this class in a specific lanaguage. For instance, if asked
|
|
|
|
* for the helper for nsIProgrammingLanguage::JAVASCRIPT this might return
|
|
|
|
* an object that can be QI'd into the nsIXPCScriptable interface to assist
|
|
|
|
* XPConnect in supplying JavaScript specific behavior to callers of the
|
|
|
|
* instance object.
|
|
|
|
*
|
|
|
|
* @see: nsIClassInfo.idl, nsIProgrammingLanguage.idl
|
|
|
|
*
|
|
|
|
* Should return null if no helper available for given language.
|
|
|
|
**/
|
2001-07-31 23:05:34 +04:00
|
|
|
typedef NS_CALLBACK(NSGetLanguageHelperProcPtr)(PRUint32 language,
|
|
|
|
nsISupports **helper);
|
2000-01-12 00:18:55 +03:00
|
|
|
|
1999-11-12 12:07:26 +03:00
|
|
|
/**
|
2002-02-05 04:38:43 +03:00
|
|
|
* nsModuleComponentInfo
|
|
|
|
*
|
1999-11-12 12:07:26 +03:00
|
|
|
* Use this type to define a list of module component info to pass to
|
2002-02-05 04:38:43 +03:00
|
|
|
* NS_NewGenericModule.
|
|
|
|
*
|
|
|
|
* @param mDescription : Class Name of given object
|
|
|
|
* @param mCID : CID of given object
|
|
|
|
* @param mContractID : Contract ID of given object
|
|
|
|
* @param mConstructor : Constructor of given object
|
|
|
|
* @param mRegisterSelfProc : (optional) Registration Callback
|
|
|
|
* @param mUnregisterSelfProc : (optional) Unregistration Callback
|
|
|
|
* @param mFactoryDestructor : (optional) Destruction Callback
|
|
|
|
* @param mGetInterfacesProc : (optional) Interfaces Callback
|
|
|
|
* @param mGetLanguageHelperProc : (optional) Language Helper Callback
|
|
|
|
* @param mClassInfoGlobal : (optional) Global Class Info of given object
|
|
|
|
* @param mFlags : (optional) Class Info Flags @see nsIClassInfo
|
|
|
|
*
|
|
|
|
* E.g.:
|
1999-11-12 12:07:26 +03:00
|
|
|
* static nsModuleComponentInfo components[] = { ... };
|
2002-02-05 04:38:43 +03:00
|
|
|
*
|
1999-11-12 12:07:26 +03:00
|
|
|
* See xpcom/sample/nsSampleModule.cpp for more info.
|
|
|
|
*/
|
|
|
|
struct nsModuleComponentInfo {
|
|
|
|
const char* mDescription;
|
|
|
|
nsCID mCID;
|
2000-09-14 03:57:52 +04:00
|
|
|
const char* mContractID;
|
2001-03-12 23:43:02 +03:00
|
|
|
NSConstructorProcPtr mConstructor;
|
2000-01-12 00:18:55 +03:00
|
|
|
NSRegisterSelfProcPtr mRegisterSelfProc;
|
|
|
|
NSUnregisterSelfProcPtr mUnregisterSelfProc;
|
2001-03-12 23:43:02 +03:00
|
|
|
NSFactoryDestructorProcPtr mFactoryDestructor;
|
|
|
|
NSGetInterfacesProcPtr mGetInterfacesProc;
|
|
|
|
NSGetLanguageHelperProcPtr mGetLanguageHelperProc;
|
|
|
|
nsIClassInfo ** mClassInfoGlobal;
|
|
|
|
PRUint32 mFlags;
|
1999-11-12 12:07:26 +03:00
|
|
|
};
|
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
|
|
|
|
/** Module Callbacks **/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsModuleConstructorProc
|
|
|
|
*
|
|
|
|
* This function is called when the module is first being constructed.
|
|
|
|
* @param self module which is being constructed.
|
|
|
|
*
|
|
|
|
* @return NS_OK Construction successful.
|
|
|
|
* NS_ERROR* Method failure which will result in module not being
|
|
|
|
* loaded.
|
|
|
|
**/
|
2008-10-10 19:04:34 +04:00
|
|
|
typedef nsresult (*nsModuleConstructorProc) (nsIModule *self);
|
2002-02-05 04:38:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nsModuleDestructorProc
|
|
|
|
*
|
|
|
|
* This function is called when the module is being destroyed.
|
|
|
|
* @param self module which is being destroyed.
|
|
|
|
*
|
|
|
|
**/
|
2008-10-10 19:04:34 +04:00
|
|
|
typedef void (*nsModuleDestructorProc) (nsIModule *self);
|
2001-08-21 04:55:20 +04:00
|
|
|
|
|
|
|
/**
|
2002-02-05 04:38:43 +03:00
|
|
|
* nsModuleInfo
|
|
|
|
*
|
2001-08-21 04:55:20 +04:00
|
|
|
* Use this structure to define meta-information about the module
|
|
|
|
* itself, including the name, its components, and an optional
|
|
|
|
* module-level initialization or shutdown routine.
|
2002-02-05 04:38:43 +03:00
|
|
|
*
|
|
|
|
* @param mVersion : Module Info Version
|
|
|
|
* @param mModuleName : Module Name
|
|
|
|
* @param mComponents : Array of Components
|
|
|
|
* @param mCount : Count of mComponents
|
|
|
|
* @param mCtor : Module user defined constructor
|
|
|
|
* @param mDtor : Module user defined destructor
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2001-08-21 04:55:20 +04:00
|
|
|
struct nsModuleInfo {
|
|
|
|
PRUint32 mVersion;
|
|
|
|
const char* mModuleName;
|
2005-07-21 17:33:43 +04:00
|
|
|
const nsModuleComponentInfo *mComponents;
|
2001-08-21 04:55:20 +04:00
|
|
|
PRUint32 mCount;
|
|
|
|
nsModuleConstructorProc mCtor;
|
|
|
|
nsModuleDestructorProc mDtor;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rev this if you change the nsModuleInfo, and are worried about
|
2001-08-30 01:59:43 +04:00
|
|
|
* binary compatibility. (Ostensibly fix NS_NewGenericModule2() to deal
|
2001-08-21 04:55:20 +04:00
|
|
|
* with older rev's at the same time.)
|
|
|
|
*/
|
2003-03-05 06:22:12 +03:00
|
|
|
#define NS_MODULEINFO_VERSION 0x00015000UL // 1.5
|
2000-01-07 05:18:13 +03:00
|
|
|
|
2007-04-02 19:29:41 +04:00
|
|
|
#ifndef XPCOM_GLUE_AVOID_NSPR
|
2001-08-30 01:59:43 +04:00
|
|
|
/**
|
|
|
|
* Create a new generic module. Use the NS_IMPL_NSGETMODULE macro, or
|
|
|
|
* one of its relatives, rather than using this directly.
|
|
|
|
*/
|
2004-10-29 23:43:51 +04:00
|
|
|
NS_COM_GLUE nsresult
|
2005-07-21 17:33:43 +04:00
|
|
|
NS_NewGenericModule2(nsModuleInfo const *info, nsIModule* *result);
|
2001-08-30 01:59:43 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Obsolete. Use NS_NewGenericModule2() instead.
|
|
|
|
*/
|
2004-10-29 23:43:51 +04:00
|
|
|
NS_COM_GLUE nsresult
|
2001-08-30 01:59:43 +04:00
|
|
|
NS_NewGenericModule(const char* moduleName,
|
|
|
|
PRUint32 componentCount,
|
|
|
|
nsModuleComponentInfo* components,
|
|
|
|
nsModuleDestructorProc dtor,
|
|
|
|
nsIModule* *result);
|
1999-11-12 12:07:26 +03:00
|
|
|
|
2007-04-02 19:29:41 +04:00
|
|
|
#endif // XPCOM_GLUE_AVOID_NSPR
|
|
|
|
|
2001-06-21 00:21:49 +04:00
|
|
|
#if defined(XPCOM_TRANSLATE_NSGM_ENTRY_POINT)
|
2005-07-21 17:33:43 +04:00
|
|
|
# define NSGETMODULE_ENTRY_POINT(_name) NS_VISIBILITY_HIDDEN nsresult _name##_NSGetModule
|
2001-05-05 09:33:37 +04:00
|
|
|
#else
|
2005-07-21 17:33:43 +04:00
|
|
|
# define NSGETMODULE_ENTRY_POINT(_name) extern "C" NS_EXPORT nsresult NSGetModule
|
2001-05-05 09:33:37 +04:00
|
|
|
#endif
|
|
|
|
|
2002-02-05 04:38:43 +03:00
|
|
|
/**
|
|
|
|
* Ease of use Macros which define NSGetModule for your component.
|
|
|
|
* See xpcom/sample/nsSampleModule.cpp for more info.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2001-07-31 23:05:34 +04:00
|
|
|
#define NS_IMPL_NSGETMODULE(_name, _components) \
|
2001-08-07 06:55:54 +04:00
|
|
|
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(_name, _components, nsnull, nsnull)
|
|
|
|
|
|
|
|
#define NS_IMPL_NSGETMODULE_WITH_CTOR(_name, _components, _ctor) \
|
|
|
|
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(_name, _components, _ctor, nsnull)
|
2000-01-07 05:18:13 +03:00
|
|
|
|
2001-07-31 23:05:34 +04:00
|
|
|
#define NS_IMPL_NSGETMODULE_WITH_DTOR(_name, _components, _dtor) \
|
2001-08-07 06:55:54 +04:00
|
|
|
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(_name, _components, nsnull, _dtor)
|
|
|
|
|
|
|
|
#define NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(_name, _components, _ctor, _dtor) \
|
2005-07-21 17:33:43 +04:00
|
|
|
static nsModuleInfo const kModuleInfo = { \
|
2001-08-21 04:55:20 +04:00
|
|
|
NS_MODULEINFO_VERSION, \
|
|
|
|
(#_name), \
|
|
|
|
(_components), \
|
|
|
|
(sizeof(_components) / sizeof(_components[0])), \
|
|
|
|
(_ctor), \
|
2005-07-14 22:42:59 +04:00
|
|
|
(_dtor) \
|
2001-08-21 04:55:20 +04:00
|
|
|
}; \
|
2005-07-21 17:33:43 +04:00
|
|
|
NSGETMODULE_ENTRY_POINT(_name) \
|
|
|
|
(nsIComponentManager *servMgr, \
|
|
|
|
nsIFile* location, \
|
|
|
|
nsIModule** result) \
|
|
|
|
{ \
|
|
|
|
return NS_NewGenericModule2(&kModuleInfo, result); \
|
|
|
|
}
|
1999-11-12 12:07:26 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-07-31 23:05:34 +04:00
|
|
|
#define NS_GENERIC_FACTORY_CONSTRUCTOR(_InstanceClass) \
|
|
|
|
static NS_IMETHODIMP \
|
|
|
|
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
|
|
|
|
void **aResult) \
|
|
|
|
{ \
|
|
|
|
nsresult rv; \
|
|
|
|
\
|
|
|
|
_InstanceClass * inst; \
|
|
|
|
\
|
|
|
|
*aResult = NULL; \
|
|
|
|
if (NULL != aOuter) { \
|
|
|
|
rv = NS_ERROR_NO_AGGREGATION; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
NS_NEWXPCOM(inst, _InstanceClass); \
|
|
|
|
if (NULL == inst) { \
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
NS_ADDREF(inst); \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
NS_RELEASE(inst); \
|
|
|
|
\
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
|
|
|
|
|
|
|
|
#define NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(_InstanceClass, _InitMethod) \
|
|
|
|
static NS_IMETHODIMP \
|
|
|
|
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
|
|
|
|
void **aResult) \
|
|
|
|
{ \
|
|
|
|
nsresult rv; \
|
|
|
|
\
|
|
|
|
_InstanceClass * inst; \
|
|
|
|
\
|
|
|
|
*aResult = NULL; \
|
|
|
|
if (NULL != aOuter) { \
|
|
|
|
rv = NS_ERROR_NO_AGGREGATION; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
NS_NEWXPCOM(inst, _InstanceClass); \
|
|
|
|
if (NULL == inst) { \
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
NS_ADDREF(inst); \
|
2004-12-27 06:23:01 +03:00
|
|
|
rv = inst->_InitMethod(); \
|
2001-07-31 23:05:34 +04:00
|
|
|
if(NS_SUCCEEDED(rv)) { \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
} \
|
|
|
|
NS_RELEASE(inst); \
|
|
|
|
\
|
|
|
|
return rv; \
|
|
|
|
} \
|
1999-10-11 02:30:55 +04:00
|
|
|
|
2000-01-07 05:18:13 +03:00
|
|
|
// 'Constructor' that uses an existing getter function that gets a singleton.
|
|
|
|
// NOTE: assumes that getter does an AddRef - so additional AddRef is not done.
|
2001-07-31 23:05:34 +04:00
|
|
|
#define NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(_InstanceClass, _GetterProc) \
|
|
|
|
static NS_IMETHODIMP \
|
|
|
|
_InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
|
|
|
|
void **aResult) \
|
|
|
|
{ \
|
|
|
|
nsresult rv; \
|
|
|
|
\
|
|
|
|
_InstanceClass * inst; \
|
|
|
|
\
|
|
|
|
*aResult = NULL; \
|
|
|
|
if (NULL != aOuter) { \
|
|
|
|
rv = NS_ERROR_NO_AGGREGATION; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
inst = _GetterProc(); \
|
|
|
|
if (NULL == inst) { \
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
/* NS_ADDREF(inst); */ \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
NS_RELEASE(inst); \
|
|
|
|
\
|
|
|
|
return rv; \
|
|
|
|
} \
|
2000-01-07 05:18:13 +03:00
|
|
|
|
1999-02-26 07:05:14 +03:00
|
|
|
#endif /* nsIGenericFactory_h___ */
|