Commit 2706e4db authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

msxml3: COM cleanup for factory.c.

parent 5107796f
...@@ -54,18 +54,23 @@ typedef HRESULT (*DOMFactoryCreateInstanceFunc)(const GUID *clsid, IUnknown *pUn ...@@ -54,18 +54,23 @@ typedef HRESULT (*DOMFactoryCreateInstanceFunc)(const GUID *clsid, IUnknown *pUn
*/ */
typedef struct typedef struct
{ {
const struct IClassFactoryVtbl *lpVtbl; IClassFactory IClassFactory_iface;
ClassFactoryCreateInstanceFunc pCreateInstance; ClassFactoryCreateInstanceFunc pCreateInstance;
} ClassFactory; } ClassFactory;
typedef struct typedef struct
{ {
const struct IClassFactoryVtbl *lpVtbl; IClassFactory IClassFactory_iface;
LONG ref; LONG ref;
DOMFactoryCreateInstanceFunc pCreateInstance; DOMFactoryCreateInstanceFunc pCreateInstance;
GUID clsid; GUID clsid;
} DOMFactory; } DOMFactory;
static inline ClassFactory *ClassFactory_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
}
static HRESULT WINAPI ClassFactory_QueryInterface( static HRESULT WINAPI ClassFactory_QueryInterface(
IClassFactory *iface, IClassFactory *iface,
REFIID riid, REFIID riid,
...@@ -100,7 +105,7 @@ static HRESULT WINAPI ClassFactory_CreateInstance( ...@@ -100,7 +105,7 @@ static HRESULT WINAPI ClassFactory_CreateInstance(
REFIID riid, REFIID riid,
void **ppobj ) void **ppobj )
{ {
ClassFactory *This = (ClassFactory*)iface; ClassFactory *This = ClassFactory_from_IClassFactory(iface);
IUnknown *punk; IUnknown *punk;
HRESULT r; HRESULT r;
...@@ -128,9 +133,14 @@ static HRESULT WINAPI ClassFactory_LockServer( ...@@ -128,9 +133,14 @@ static HRESULT WINAPI ClassFactory_LockServer(
return S_OK; return S_OK;
} }
static inline DOMFactory *DOMFactory_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, DOMFactory, IClassFactory_iface);
}
static ULONG WINAPI DOMClassFactory_AddRef(IClassFactory *iface ) static ULONG WINAPI DOMClassFactory_AddRef(IClassFactory *iface )
{ {
DOMFactory *This = (DOMFactory*)iface; DOMFactory *This = DOMFactory_from_IClassFactory(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref = %u\n", This, ref); TRACE("(%p) ref = %u\n", This, ref);
return ref; return ref;
...@@ -138,7 +148,7 @@ static ULONG WINAPI DOMClassFactory_AddRef(IClassFactory *iface ) ...@@ -138,7 +148,7 @@ static ULONG WINAPI DOMClassFactory_AddRef(IClassFactory *iface )
static ULONG WINAPI DOMClassFactory_Release(IClassFactory *iface ) static ULONG WINAPI DOMClassFactory_Release(IClassFactory *iface )
{ {
DOMFactory *This = (DOMFactory*)iface; DOMFactory *This = DOMFactory_from_IClassFactory(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref = %u\n", This, ref); TRACE("(%p) ref = %u\n", This, ref);
if(!ref) { if(!ref) {
...@@ -153,7 +163,7 @@ static HRESULT WINAPI DOMClassFactory_CreateInstance( ...@@ -153,7 +163,7 @@ static HRESULT WINAPI DOMClassFactory_CreateInstance(
REFIID riid, REFIID riid,
void **ppobj ) void **ppobj )
{ {
DOMFactory *This = (DOMFactory*)iface; DOMFactory *This = DOMFactory_from_IClassFactory(iface);
IUnknown *punk; IUnknown *punk;
HRESULT r; HRESULT r;
...@@ -196,12 +206,12 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv ...@@ -196,12 +206,12 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv
DOMFactory *ret = heap_alloc(sizeof(DOMFactory)); DOMFactory *ret = heap_alloc(sizeof(DOMFactory));
HRESULT hres; HRESULT hres;
ret->lpVtbl = &DOMClassFactoryVtbl; ret->IClassFactory_iface.lpVtbl = &DOMClassFactoryVtbl;
ret->ref = 0; ret->ref = 0;
ret->clsid = *clsid; ret->clsid = *clsid;
ret->pCreateInstance = fnCreateInstance; ret->pCreateInstance = fnCreateInstance;
hres = IClassFactory_QueryInterface((IClassFactory*)ret, riid, ppv); hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_free(ret); heap_free(ret);
*ppv = NULL; *ppv = NULL;
...@@ -209,11 +219,11 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv ...@@ -209,11 +219,11 @@ static HRESULT DOMClassFactory_Create(const GUID *clsid, REFIID riid, void **ppv
return hres; return hres;
} }
static ClassFactory xmldoccf = { &ClassFactoryVtbl, XMLDocument_create }; static ClassFactory xmldoccf = { { &ClassFactoryVtbl }, XMLDocument_create };
static ClassFactory saxreadcf = { &ClassFactoryVtbl, SAXXMLReader_create }; static ClassFactory saxreadcf = { { &ClassFactoryVtbl }, SAXXMLReader_create };
static ClassFactory httpreqcf = { &ClassFactoryVtbl, XMLHTTPRequest_create }; static ClassFactory httpreqcf = { { &ClassFactoryVtbl }, XMLHTTPRequest_create };
static ClassFactory xsltemplatecf = { &ClassFactoryVtbl, XSLTemplate_create }; static ClassFactory xsltemplatecf = { { &ClassFactoryVtbl }, XSLTemplate_create };
static ClassFactory mxwritercf = { &ClassFactoryVtbl, MXWriter_create }; static ClassFactory mxwritercf = { { &ClassFactoryVtbl }, MXWriter_create };
/****************************************************************** /******************************************************************
* DllGetClassObject (MSXML3.@) * DllGetClassObject (MSXML3.@)
...@@ -243,7 +253,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv ) ...@@ -243,7 +253,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
} }
else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) ) else if( IsEqualCLSID( rclsid, &CLSID_XMLDocument ) )
{ {
cf = (IClassFactory*) &xmldoccf.lpVtbl; cf = &xmldoccf.IClassFactory_iface;
} }
else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) || /* Version indep. v 2.x */ else if( IsEqualCLSID( rclsid, &CLSID_DOMFreeThreadedDocument ) || /* Version indep. v 2.x */
IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) || IsEqualCLSID( rclsid, &CLSID_FreeThreadedDOMDocument ) ||
...@@ -259,7 +269,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv ) ...@@ -259,7 +269,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ) || IsEqualCLSID( rclsid, &CLSID_SAXXMLReader40 ) ||
IsEqualCLSID( rclsid, &CLSID_SAXXMLReader60 )) IsEqualCLSID( rclsid, &CLSID_SAXXMLReader60 ))
{ {
cf = (IClassFactory*) &saxreadcf.lpVtbl; cf = &saxreadcf.IClassFactory_iface;
} }
else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest ) || else if( IsEqualCLSID( rclsid, &CLSID_XMLHTTPRequest ) ||
IsEqualCLSID( rclsid, &CLSID_XMLHTTP26 ) || IsEqualCLSID( rclsid, &CLSID_XMLHTTP26 ) ||
...@@ -267,7 +277,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv ) ...@@ -267,7 +277,7 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
IsEqualCLSID( rclsid, &CLSID_XMLHTTP40 ) || IsEqualCLSID( rclsid, &CLSID_XMLHTTP40 ) ||
IsEqualCLSID( rclsid, &CLSID_XMLHTTP60 )) IsEqualCLSID( rclsid, &CLSID_XMLHTTP60 ))
{ {
cf = (IClassFactory*) &httpreqcf.lpVtbl; cf = &httpreqcf.IClassFactory_iface;
} }
else if( IsEqualCLSID( rclsid, &CLSID_XSLTemplate ) || else if( IsEqualCLSID( rclsid, &CLSID_XSLTemplate ) ||
IsEqualCLSID( rclsid, &CLSID_XSLTemplate26 ) || IsEqualCLSID( rclsid, &CLSID_XSLTemplate26 ) ||
...@@ -275,14 +285,14 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv ) ...@@ -275,14 +285,14 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
IsEqualCLSID( rclsid, &CLSID_XSLTemplate40 ) || IsEqualCLSID( rclsid, &CLSID_XSLTemplate40 ) ||
IsEqualCLSID( rclsid, &CLSID_XSLTemplate60 )) IsEqualCLSID( rclsid, &CLSID_XSLTemplate60 ))
{ {
cf = (IClassFactory*) &xsltemplatecf.lpVtbl; cf = &xsltemplatecf.IClassFactory_iface;
} }
else if( IsEqualCLSID( rclsid, &CLSID_MXXMLWriter ) || else if( IsEqualCLSID( rclsid, &CLSID_MXXMLWriter ) ||
IsEqualCLSID( rclsid, &CLSID_MXXMLWriter30 ) || IsEqualCLSID( rclsid, &CLSID_MXXMLWriter30 ) ||
IsEqualCLSID( rclsid, &CLSID_MXXMLWriter40 ) || IsEqualCLSID( rclsid, &CLSID_MXXMLWriter40 ) ||
IsEqualCLSID( rclsid, &CLSID_MXXMLWriter60 ) ) IsEqualCLSID( rclsid, &CLSID_MXXMLWriter60 ) )
{ {
cf = (IClassFactory*) &mxwritercf.lpVtbl; cf = &mxwritercf.IClassFactory_iface;
} }
if ( !cf ) if ( !cf )
......
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