Commit a59cc1a6 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

mshtml: COM cleanup for the nsIFactory iface.

parent 95d8566a
...@@ -377,27 +377,28 @@ static const nsITooltipTextProviderVtbl nsTooltipTextProviderVtbl = { ...@@ -377,27 +377,28 @@ static const nsITooltipTextProviderVtbl nsTooltipTextProviderVtbl = {
static nsITooltipTextProvider nsTooltipTextProvider = { &nsTooltipTextProviderVtbl }; static nsITooltipTextProvider nsTooltipTextProvider = { &nsTooltipTextProviderVtbl };
typedef struct { typedef struct {
const nsIFactoryVtbl *lpFactoryVtbl; nsIFactory nsIFactory_iface;
nsISupports *service; nsISupports *service;
} nsServiceFactory; } nsServiceFactory;
#define NSFACTORY(x) ((nsIFactory*) &(x)->lpFactoryVtbl) static inline nsServiceFactory *impl_from_nsIFactory(nsIFactory *iface)
{
#define NSFACTORY_THIS(iface) DEFINE_THIS(nsServiceFactory, Factory, iface) return CONTAINING_RECORD(iface, nsServiceFactory, nsIFactory_iface);
}
static nsresult NSAPI nsServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid, static nsresult NSAPI nsServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid,
void **result) void **result)
{ {
nsServiceFactory *This = NSFACTORY_THIS(iface); nsServiceFactory *This = impl_from_nsIFactory(iface);
*result = NULL; *result = NULL;
if(IsEqualGUID(&IID_nsISupports, riid)) { if(IsEqualGUID(&IID_nsISupports, riid)) {
TRACE("(%p)->(IID_nsISupports %p)\n", This, result); TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
*result = NSFACTORY(This); *result = &This->nsIFactory_iface;
}else if(IsEqualGUID(&IID_nsIFactory, riid)) { }else if(IsEqualGUID(&IID_nsIFactory, riid)) {
TRACE("(%p)->(IID_nsIFactory %p)\n", This, result); TRACE("(%p)->(IID_nsIFactory %p)\n", This, result);
*result = NSFACTORY(This); *result = &This->nsIFactory_iface;
} }
if(*result) if(*result)
...@@ -420,7 +421,7 @@ static nsrefcnt NSAPI nsServiceFactory_Release(nsIFactory *iface) ...@@ -420,7 +421,7 @@ static nsrefcnt NSAPI nsServiceFactory_Release(nsIFactory *iface)
static nsresult NSAPI nsServiceFactory_CreateInstance(nsIFactory *iface, static nsresult NSAPI nsServiceFactory_CreateInstance(nsIFactory *iface,
nsISupports *aOuter, const nsIID *iid, void **result) nsISupports *aOuter, const nsIID *iid, void **result)
{ {
nsServiceFactory *This = NSFACTORY_THIS(iface); nsServiceFactory *This = impl_from_nsIFactory(iface);
TRACE("(%p)->(%p %s %p)\n", This, aOuter, debugstr_guid(iid), result); TRACE("(%p)->(%p %s %p)\n", This, aOuter, debugstr_guid(iid), result);
...@@ -429,13 +430,11 @@ static nsresult NSAPI nsServiceFactory_CreateInstance(nsIFactory *iface, ...@@ -429,13 +430,11 @@ static nsresult NSAPI nsServiceFactory_CreateInstance(nsIFactory *iface,
static nsresult NSAPI nsServiceFactory_LockFactory(nsIFactory *iface, PRBool lock) static nsresult NSAPI nsServiceFactory_LockFactory(nsIFactory *iface, PRBool lock)
{ {
nsServiceFactory *This = NSFACTORY_THIS(iface); nsServiceFactory *This = impl_from_nsIFactory(iface);
WARN("(%p)->(%x)\n", This, lock); WARN("(%p)->(%x)\n", This, lock);
return NS_OK; return NS_OK;
} }
#undef NSFACTORY_THIS
static const nsIFactoryVtbl nsServiceFactoryVtbl = { static const nsIFactoryVtbl nsServiceFactoryVtbl = {
nsServiceFactory_QueryInterface, nsServiceFactory_QueryInterface,
nsServiceFactory_AddRef, nsServiceFactory_AddRef,
...@@ -445,12 +444,12 @@ static const nsIFactoryVtbl nsServiceFactoryVtbl = { ...@@ -445,12 +444,12 @@ static const nsIFactoryVtbl nsServiceFactoryVtbl = {
}; };
static nsServiceFactory nsPromptServiceFactory = { static nsServiceFactory nsPromptServiceFactory = {
&nsServiceFactoryVtbl, { &nsServiceFactoryVtbl },
(nsISupports*)&nsPromptService (nsISupports*)&nsPromptService
}; };
static nsServiceFactory nsTooltipTextFactory = { static nsServiceFactory nsTooltipTextFactory = {
&nsServiceFactoryVtbl, { &nsServiceFactoryVtbl },
(nsISupports*)&nsTooltipTextProvider (nsISupports*)&nsTooltipTextProvider
}; };
...@@ -460,7 +459,7 @@ void register_nsservice(nsIComponentRegistrar *registrar, nsIServiceManager *ser ...@@ -460,7 +459,7 @@ void register_nsservice(nsIComponentRegistrar *registrar, nsIServiceManager *ser
nsresult nsres; nsresult nsres;
nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_PROMPTSERVICE_CID, nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_PROMPTSERVICE_CID,
"Prompt Service", NS_PROMPTSERVICE_CONTRACTID, NSFACTORY(&nsPromptServiceFactory)); "Prompt Service", NS_PROMPTSERVICE_CONTRACTID, &nsPromptServiceFactory.nsIFactory_iface);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
ERR("RegisterFactory failed: %08x\n", nsres); ERR("RegisterFactory failed: %08x\n", nsres);
...@@ -478,7 +477,7 @@ void register_nsservice(nsIComponentRegistrar *registrar, nsIServiceManager *ser ...@@ -478,7 +477,7 @@ void register_nsservice(nsIComponentRegistrar *registrar, nsIServiceManager *ser
nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_TOOLTIPTEXTPROVIDER_CID, nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_TOOLTIPTEXTPROVIDER_CID,
NS_TOOLTIPTEXTPROVIDER_CLASSNAME, NS_TOOLTIPTEXTPROVIDER_CONTRACTID, NS_TOOLTIPTEXTPROVIDER_CLASSNAME, NS_TOOLTIPTEXTPROVIDER_CONTRACTID,
NSFACTORY(&nsTooltipTextFactory)); &nsTooltipTextFactory.nsIFactory_iface);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
ERR("RegisterFactory failed: %08x\n", nsres); ERR("RegisterFactory failed: %08x\n", nsres);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment