From 2e0ae08faee8493b567122535ffda213975d2746 Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Sun, 28 Feb 1999 19:04:47 +0000 Subject: [PATCH] SetDestructor git-svn-id: svn://10.0.0.236/trunk@22403 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/components/nsGenericFactory.cpp | 15 +++++++++++++-- mozilla/xpcom/components/nsGenericFactory.h | 12 ++++++++++++ mozilla/xpcom/components/nsIGenericFactory.h | 8 ++++++++ mozilla/xpcom/glue/nsGenericFactory.cpp | 15 +++++++++++++-- mozilla/xpcom/glue/nsGenericFactory.h | 12 ++++++++++++ mozilla/xpcom/glue/nsIGenericFactory.h | 8 ++++++++ mozilla/xpcom/public/nsIGenericFactory.h | 8 ++++++++ mozilla/xpcom/src/nsGenericFactory.cpp | 15 +++++++++++++-- mozilla/xpcom/src/nsGenericFactory.h | 12 ++++++++++++ 9 files changed, 99 insertions(+), 6 deletions(-) diff --git a/mozilla/xpcom/components/nsGenericFactory.cpp b/mozilla/xpcom/components/nsGenericFactory.cpp index c3f7f4a20bc..1f7f1b3c6c1 100644 --- a/mozilla/xpcom/components/nsGenericFactory.cpp +++ b/mozilla/xpcom/components/nsGenericFactory.cpp @@ -18,12 +18,17 @@ #include "nsGenericFactory.h" -nsGenericFactory::nsGenericFactory(ConstructorProcPtr constructor) : mConstructor(constructor) +nsGenericFactory::nsGenericFactory(ConstructorProcPtr constructor) + : mConstructor(constructor), mDestructor(NULL) { NS_INIT_ISUPPORTS(); } -nsGenericFactory::~nsGenericFactory() {} +nsGenericFactory::~nsGenericFactory() +{ + if (mDestructor != NULL) + (*mDestructor) (); +} NS_METHOD nsGenericFactory::QueryInterface(const nsIID& aIID, void** aInstancePtr) { @@ -59,6 +64,12 @@ NS_IMETHODIMP nsGenericFactory::SetConstructor(ConstructorProcPtr constructor) return NS_OK; } +NS_IMETHODIMP nsGenericFactory::SetDestructor(DestructorProcPtr destructor) +{ + mDestructor = destructor; + return NS_OK; +} + NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) { // sorry, aggregation not spoken here. diff --git a/mozilla/xpcom/components/nsGenericFactory.h b/mozilla/xpcom/components/nsGenericFactory.h index f53aa5498f8..9f87bc688d1 100644 --- a/mozilla/xpcom/components/nsGenericFactory.h +++ b/mozilla/xpcom/components/nsGenericFactory.h @@ -38,11 +38,23 @@ public: NS_IMETHOD LockFactory(PRBool aLock); + /** + * Establishes the generic factory's constructor function, which will be called + * by CreateInstance. + */ NS_IMETHOD SetConstructor(ConstructorProcPtr constructor); + /** + * Establishes the generic factory's destructor function, which will be called + * whe the generic factory is deleted. This is used to notify the DLL that + * an instance of one of its generic factories is going away. + */ + NS_IMETHOD SetDestructor(DestructorProcPtr destructor); + static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); private: ConstructorProcPtr mConstructor; + DestructorProcPtr mDestructor; }; #endif /* nsGenericFactory_h___ */ diff --git a/mozilla/xpcom/components/nsIGenericFactory.h b/mozilla/xpcom/components/nsIGenericFactory.h index 01b28feccf8..02cf2f1cd97 100644 --- a/mozilla/xpcom/components/nsIGenericFactory.h +++ b/mozilla/xpcom/components/nsIGenericFactory.h @@ -44,12 +44,20 @@ public: static const nsIID& IID() { static nsIID iid = NS_IGENERICFACTORY_IID; return iid; } typedef NS_CALLBACK(ConstructorProcPtr) (nsISupports *aOuter, REFNSIID aIID, void **aResult); + typedef NS_CALLBACK(DestructorProcPtr) (void); /** * Establishes the generic factory's constructor function, which will be called * by CreateInstance. */ NS_IMETHOD SetConstructor(ConstructorProcPtr constructor) = 0; + + /** + * Establishes the generic factory's destructor function, which will be called + * whe the generic factory is deleted. This is used to notify the DLL that + * an instance of one of its generic factories is going away. + */ + NS_IMETHOD SetDestructor(DestructorProcPtr destructor) = 0; }; #endif /* nsIGenericFactory_h___ */ diff --git a/mozilla/xpcom/glue/nsGenericFactory.cpp b/mozilla/xpcom/glue/nsGenericFactory.cpp index c3f7f4a20bc..1f7f1b3c6c1 100644 --- a/mozilla/xpcom/glue/nsGenericFactory.cpp +++ b/mozilla/xpcom/glue/nsGenericFactory.cpp @@ -18,12 +18,17 @@ #include "nsGenericFactory.h" -nsGenericFactory::nsGenericFactory(ConstructorProcPtr constructor) : mConstructor(constructor) +nsGenericFactory::nsGenericFactory(ConstructorProcPtr constructor) + : mConstructor(constructor), mDestructor(NULL) { NS_INIT_ISUPPORTS(); } -nsGenericFactory::~nsGenericFactory() {} +nsGenericFactory::~nsGenericFactory() +{ + if (mDestructor != NULL) + (*mDestructor) (); +} NS_METHOD nsGenericFactory::QueryInterface(const nsIID& aIID, void** aInstancePtr) { @@ -59,6 +64,12 @@ NS_IMETHODIMP nsGenericFactory::SetConstructor(ConstructorProcPtr constructor) return NS_OK; } +NS_IMETHODIMP nsGenericFactory::SetDestructor(DestructorProcPtr destructor) +{ + mDestructor = destructor; + return NS_OK; +} + NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) { // sorry, aggregation not spoken here. diff --git a/mozilla/xpcom/glue/nsGenericFactory.h b/mozilla/xpcom/glue/nsGenericFactory.h index f53aa5498f8..9f87bc688d1 100644 --- a/mozilla/xpcom/glue/nsGenericFactory.h +++ b/mozilla/xpcom/glue/nsGenericFactory.h @@ -38,11 +38,23 @@ public: NS_IMETHOD LockFactory(PRBool aLock); + /** + * Establishes the generic factory's constructor function, which will be called + * by CreateInstance. + */ NS_IMETHOD SetConstructor(ConstructorProcPtr constructor); + /** + * Establishes the generic factory's destructor function, which will be called + * whe the generic factory is deleted. This is used to notify the DLL that + * an instance of one of its generic factories is going away. + */ + NS_IMETHOD SetDestructor(DestructorProcPtr destructor); + static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); private: ConstructorProcPtr mConstructor; + DestructorProcPtr mDestructor; }; #endif /* nsGenericFactory_h___ */ diff --git a/mozilla/xpcom/glue/nsIGenericFactory.h b/mozilla/xpcom/glue/nsIGenericFactory.h index 01b28feccf8..02cf2f1cd97 100644 --- a/mozilla/xpcom/glue/nsIGenericFactory.h +++ b/mozilla/xpcom/glue/nsIGenericFactory.h @@ -44,12 +44,20 @@ public: static const nsIID& IID() { static nsIID iid = NS_IGENERICFACTORY_IID; return iid; } typedef NS_CALLBACK(ConstructorProcPtr) (nsISupports *aOuter, REFNSIID aIID, void **aResult); + typedef NS_CALLBACK(DestructorProcPtr) (void); /** * Establishes the generic factory's constructor function, which will be called * by CreateInstance. */ NS_IMETHOD SetConstructor(ConstructorProcPtr constructor) = 0; + + /** + * Establishes the generic factory's destructor function, which will be called + * whe the generic factory is deleted. This is used to notify the DLL that + * an instance of one of its generic factories is going away. + */ + NS_IMETHOD SetDestructor(DestructorProcPtr destructor) = 0; }; #endif /* nsIGenericFactory_h___ */ diff --git a/mozilla/xpcom/public/nsIGenericFactory.h b/mozilla/xpcom/public/nsIGenericFactory.h index 01b28feccf8..02cf2f1cd97 100644 --- a/mozilla/xpcom/public/nsIGenericFactory.h +++ b/mozilla/xpcom/public/nsIGenericFactory.h @@ -44,12 +44,20 @@ public: static const nsIID& IID() { static nsIID iid = NS_IGENERICFACTORY_IID; return iid; } typedef NS_CALLBACK(ConstructorProcPtr) (nsISupports *aOuter, REFNSIID aIID, void **aResult); + typedef NS_CALLBACK(DestructorProcPtr) (void); /** * Establishes the generic factory's constructor function, which will be called * by CreateInstance. */ NS_IMETHOD SetConstructor(ConstructorProcPtr constructor) = 0; + + /** + * Establishes the generic factory's destructor function, which will be called + * whe the generic factory is deleted. This is used to notify the DLL that + * an instance of one of its generic factories is going away. + */ + NS_IMETHOD SetDestructor(DestructorProcPtr destructor) = 0; }; #endif /* nsIGenericFactory_h___ */ diff --git a/mozilla/xpcom/src/nsGenericFactory.cpp b/mozilla/xpcom/src/nsGenericFactory.cpp index c3f7f4a20bc..1f7f1b3c6c1 100644 --- a/mozilla/xpcom/src/nsGenericFactory.cpp +++ b/mozilla/xpcom/src/nsGenericFactory.cpp @@ -18,12 +18,17 @@ #include "nsGenericFactory.h" -nsGenericFactory::nsGenericFactory(ConstructorProcPtr constructor) : mConstructor(constructor) +nsGenericFactory::nsGenericFactory(ConstructorProcPtr constructor) + : mConstructor(constructor), mDestructor(NULL) { NS_INIT_ISUPPORTS(); } -nsGenericFactory::~nsGenericFactory() {} +nsGenericFactory::~nsGenericFactory() +{ + if (mDestructor != NULL) + (*mDestructor) (); +} NS_METHOD nsGenericFactory::QueryInterface(const nsIID& aIID, void** aInstancePtr) { @@ -59,6 +64,12 @@ NS_IMETHODIMP nsGenericFactory::SetConstructor(ConstructorProcPtr constructor) return NS_OK; } +NS_IMETHODIMP nsGenericFactory::SetDestructor(DestructorProcPtr destructor) +{ + mDestructor = destructor; + return NS_OK; +} + NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) { // sorry, aggregation not spoken here. diff --git a/mozilla/xpcom/src/nsGenericFactory.h b/mozilla/xpcom/src/nsGenericFactory.h index f53aa5498f8..9f87bc688d1 100644 --- a/mozilla/xpcom/src/nsGenericFactory.h +++ b/mozilla/xpcom/src/nsGenericFactory.h @@ -38,11 +38,23 @@ public: NS_IMETHOD LockFactory(PRBool aLock); + /** + * Establishes the generic factory's constructor function, which will be called + * by CreateInstance. + */ NS_IMETHOD SetConstructor(ConstructorProcPtr constructor); + /** + * Establishes the generic factory's destructor function, which will be called + * whe the generic factory is deleted. This is used to notify the DLL that + * an instance of one of its generic factories is going away. + */ + NS_IMETHOD SetDestructor(DestructorProcPtr destructor); + static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); private: ConstructorProcPtr mConstructor; + DestructorProcPtr mDestructor; }; #endif /* nsGenericFactory_h___ */