msxml3: COM cleanup in domdoc.c.

This commit is contained in:
Michael Stefaniuc 2011-04-26 23:47:48 +02:00 committed by Alexandre Julliard
parent 1da5c9d17f
commit 31057e4b75
1 changed files with 49 additions and 48 deletions

View File

@ -94,7 +94,7 @@ typedef struct domdoc domdoc;
struct ConnectionPoint struct ConnectionPoint
{ {
const IConnectionPointVtbl *lpVtblConnectionPoint; IConnectionPoint IConnectionPoint_iface;
const IID *iid; const IID *iid;
ConnectionPoint *next; ConnectionPoint *next;
@ -120,12 +120,12 @@ typedef enum {
struct domdoc struct domdoc
{ {
xmlnode node; xmlnode node;
const struct IXMLDOMDocument3Vtbl *lpVtbl; IXMLDOMDocument3 IXMLDOMDocument3_iface;
const struct IPersistStreamInitVtbl *lpvtblIPersistStreamInit; IPersistStreamInit IPersistStreamInit_iface;
const struct IObjectWithSiteVtbl *lpvtblIObjectWithSite; IObjectWithSite IObjectWithSite_iface;
const struct IObjectSafetyVtbl *lpvtblIObjectSafety; IObjectSafety IObjectSafety_iface;
const struct ISupportErrorInfoVtbl *lpvtblISupportErrorInfo; ISupportErrorInfo ISupportErrorInfo_iface;
const struct IConnectionPointContainerVtbl *lpVtblConnectionPointContainer; IConnectionPointContainer IConnectionPointContainer_iface;
LONG ref; LONG ref;
VARIANT_BOOL async; VARIANT_BOOL async;
VARIANT_BOOL validating; VARIANT_BOOL validating;
@ -181,7 +181,7 @@ static HRESULT set_doc_event(domdoc *doc, eventid_t eid, const VARIANT *v)
static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface) static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface)
{ {
return (ConnectionPoint *)((char*)iface - FIELD_OFFSET(ConnectionPoint, lpVtblConnectionPoint)); return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
} }
/* /*
@ -655,32 +655,32 @@ static HRESULT attach_xmldoc(domdoc *This, xmlDocPtr xml )
static inline domdoc *impl_from_IXMLDOMDocument3( IXMLDOMDocument3 *iface ) static inline domdoc *impl_from_IXMLDOMDocument3( IXMLDOMDocument3 *iface )
{ {
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpVtbl)); return CONTAINING_RECORD(iface, domdoc, IXMLDOMDocument3_iface);
} }
static inline domdoc *impl_from_IPersistStreamInit(IPersistStreamInit *iface) static inline domdoc *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
{ {
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIPersistStreamInit)); return CONTAINING_RECORD(iface, domdoc, IPersistStreamInit_iface);
} }
static inline domdoc *impl_from_IObjectWithSite(IObjectWithSite *iface) static inline domdoc *impl_from_IObjectWithSite(IObjectWithSite *iface)
{ {
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIObjectWithSite)); return CONTAINING_RECORD(iface, domdoc, IObjectWithSite_iface);
} }
static inline domdoc *impl_from_IObjectSafety(IObjectSafety *iface) static inline domdoc *impl_from_IObjectSafety(IObjectSafety *iface)
{ {
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIObjectSafety)); return CONTAINING_RECORD(iface, domdoc, IObjectSafety_iface);
} }
static inline domdoc *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface) static inline domdoc *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
{ {
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblISupportErrorInfo)); return CONTAINING_RECORD(iface, domdoc, ISupportErrorInfo_iface);
} }
static inline domdoc *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface) static inline domdoc *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
{ {
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpVtblConnectionPointContainer)); return CONTAINING_RECORD(iface, domdoc, IConnectionPointContainer_iface);
} }
/************************************************************************ /************************************************************************
@ -690,21 +690,21 @@ static HRESULT WINAPI domdoc_IPersistStreamInit_QueryInterface(
IPersistStreamInit *iface, REFIID riid, void **ppvObj) IPersistStreamInit *iface, REFIID riid, void **ppvObj)
{ {
domdoc* This = impl_from_IPersistStreamInit(iface); domdoc* This = impl_from_IPersistStreamInit(iface);
return IXMLDOMDocument3_QueryInterface((IXMLDOMDocument3*)&This->lpVtbl, riid, ppvObj); return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppvObj);
} }
static ULONG WINAPI domdoc_IPersistStreamInit_AddRef( static ULONG WINAPI domdoc_IPersistStreamInit_AddRef(
IPersistStreamInit *iface) IPersistStreamInit *iface)
{ {
domdoc* This = impl_from_IPersistStreamInit(iface); domdoc* This = impl_from_IPersistStreamInit(iface);
return IXMLDOMDocument3_AddRef((IXMLDOMDocument3*)&This->lpVtbl); return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
} }
static ULONG WINAPI domdoc_IPersistStreamInit_Release( static ULONG WINAPI domdoc_IPersistStreamInit_Release(
IPersistStreamInit *iface) IPersistStreamInit *iface)
{ {
domdoc* This = impl_from_IPersistStreamInit(iface); domdoc* This = impl_from_IPersistStreamInit(iface);
return IXMLDOMDocument3_Release((IXMLDOMDocument3*)&This->lpVtbl); return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
} }
static HRESULT WINAPI domdoc_IPersistStreamInit_GetClassID( static HRESULT WINAPI domdoc_IPersistStreamInit_GetClassID(
@ -791,7 +791,7 @@ static HRESULT WINAPI domdoc_IPersistStreamInit_Save(
TRACE("(%p)->(%p %d)\n", This, stream, clr_dirty); TRACE("(%p)->(%p %d)\n", This, stream, clr_dirty);
hr = IXMLDOMDocument3_get_xml( (IXMLDOMDocument3*)&This->lpVtbl, &xmlString ); hr = IXMLDOMDocument3_get_xml(&This->IXMLDOMDocument3_iface, &xmlString);
if(hr == S_OK) if(hr == S_OK)
{ {
DWORD len = SysStringLen(xmlString) * sizeof(WCHAR); DWORD len = SysStringLen(xmlString) * sizeof(WCHAR);
@ -840,21 +840,21 @@ static HRESULT WINAPI support_error_QueryInterface(
REFIID riid, void** ppvObj ) REFIID riid, void** ppvObj )
{ {
domdoc *This = impl_from_ISupportErrorInfo(iface); domdoc *This = impl_from_ISupportErrorInfo(iface);
return IXMLDOMDocument3_QueryInterface((IXMLDOMDocument3 *)This, riid, ppvObj); return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppvObj);
} }
static ULONG WINAPI support_error_AddRef( static ULONG WINAPI support_error_AddRef(
ISupportErrorInfo *iface ) ISupportErrorInfo *iface )
{ {
domdoc *This = impl_from_ISupportErrorInfo(iface); domdoc *This = impl_from_ISupportErrorInfo(iface);
return IXMLDOMDocument3_AddRef((IXMLDOMDocument3 *)This); return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
} }
static ULONG WINAPI support_error_Release( static ULONG WINAPI support_error_Release(
ISupportErrorInfo *iface ) ISupportErrorInfo *iface )
{ {
domdoc *This = impl_from_ISupportErrorInfo(iface); domdoc *This = impl_from_ISupportErrorInfo(iface);
return IXMLDOMDocument3_Release((IXMLDOMDocument3 *)This); return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
} }
static HRESULT WINAPI support_error_InterfaceSupportsErrorInfo( static HRESULT WINAPI support_error_InterfaceSupportsErrorInfo(
@ -894,19 +894,19 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument3 *iface, REFIID rii
else if (IsEqualGUID(&IID_IPersistStream, riid) || else if (IsEqualGUID(&IID_IPersistStream, riid) ||
IsEqualGUID(&IID_IPersistStreamInit, riid)) IsEqualGUID(&IID_IPersistStreamInit, riid))
{ {
*ppvObject = &(This->lpvtblIPersistStreamInit); *ppvObject = &This->IPersistStreamInit_iface;
} }
else if (IsEqualGUID(&IID_IObjectWithSite, riid)) else if (IsEqualGUID(&IID_IObjectWithSite, riid))
{ {
*ppvObject = &(This->lpvtblIObjectWithSite); *ppvObject = &This->IObjectWithSite_iface;
} }
else if (IsEqualGUID(&IID_IObjectSafety, riid)) else if (IsEqualGUID(&IID_IObjectSafety, riid))
{ {
*ppvObject = &(This->lpvtblIObjectSafety); *ppvObject = &This->IObjectSafety_iface;
} }
else if( IsEqualGUID( riid, &IID_ISupportErrorInfo )) else if( IsEqualGUID( riid, &IID_ISupportErrorInfo ))
{ {
*ppvObject = &This->lpvtblISupportErrorInfo; *ppvObject = &This->ISupportErrorInfo_iface;
} }
else if(node_query_interface(&This->node, riid, ppvObject)) else if(node_query_interface(&This->node, riid, ppvObject))
{ {
@ -914,7 +914,7 @@ static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument3 *iface, REFIID rii
} }
else if (IsEqualGUID( riid, &IID_IConnectionPointContainer )) else if (IsEqualGUID( riid, &IID_IConnectionPointContainer ))
{ {
*ppvObject = &This->lpVtblConnectionPointContainer; *ppvObject = &This->IConnectionPointContainer_iface;
} }
else else
{ {
@ -1043,8 +1043,8 @@ static HRESULT WINAPI domdoc_Invoke(
hr = get_typeinfo(IXMLDOMDocument2_tid, &typeinfo); hr = get_typeinfo(IXMLDOMDocument2_tid, &typeinfo);
if(SUCCEEDED(hr)) if(SUCCEEDED(hr))
{ {
hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams, hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMDocument3_iface, dispIdMember, wFlags,
pVarResult, pExcepInfo, puArgErr); pDispParams, pVarResult, pExcepInfo, puArgErr);
ITypeInfo_Release(typeinfo); ITypeInfo_Release(typeinfo);
} }
@ -3129,19 +3129,19 @@ static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointCo
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
domdoc *This = impl_from_IConnectionPointContainer(iface); domdoc *This = impl_from_IConnectionPointContainer(iface);
return IXMLDOMDocument3_QueryInterface((IXMLDOMDocument3*)This, riid, ppv); return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppv);
} }
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface) static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
{ {
domdoc *This = impl_from_IConnectionPointContainer(iface); domdoc *This = impl_from_IConnectionPointContainer(iface);
return IXMLDOMDocument3_AddRef((IXMLDOMDocument3*)This); return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
} }
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface) static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
{ {
domdoc *This = impl_from_IConnectionPointContainer(iface); domdoc *This = impl_from_IConnectionPointContainer(iface);
return IXMLDOMDocument3_Release((IXMLDOMDocument3*)This); return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
} }
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface, static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
@ -3165,7 +3165,7 @@ static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPo
for(iter = This->cp_list; iter; iter = iter->next) for(iter = This->cp_list; iter; iter = iter->next)
{ {
if (IsEqualGUID(iter->iid, riid)) if (IsEqualGUID(iter->iid, riid))
*cp = (IConnectionPoint*)&iter->lpVtblConnectionPoint; *cp = &iter->IConnectionPoint_iface;
} }
if (*cp) if (*cp)
@ -3297,7 +3297,7 @@ static const IConnectionPointVtbl ConnectionPointVtbl =
static void ConnectionPoint_Init(ConnectionPoint *cp, struct domdoc *doc, REFIID riid) static void ConnectionPoint_Init(ConnectionPoint *cp, struct domdoc *doc, REFIID riid)
{ {
cp->lpVtblConnectionPoint = &ConnectionPointVtbl; cp->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
cp->doc = doc; cp->doc = doc;
cp->iid = riid; cp->iid = riid;
cp->sinks = NULL; cp->sinks = NULL;
@ -3306,7 +3306,7 @@ static void ConnectionPoint_Init(ConnectionPoint *cp, struct domdoc *doc, REFIID
cp->next = doc->cp_list; cp->next = doc->cp_list;
doc->cp_list = cp; doc->cp_list = cp;
cp->container = (IConnectionPointContainer*)&doc->lpVtblConnectionPointContainer; cp->container = &doc->IConnectionPointContainer_iface;
} }
/* domdoc implementation of IObjectWithSite */ /* domdoc implementation of IObjectWithSite */
@ -3314,19 +3314,19 @@ static HRESULT WINAPI
domdoc_ObjectWithSite_QueryInterface( IObjectWithSite* iface, REFIID riid, void** ppvObject ) domdoc_ObjectWithSite_QueryInterface( IObjectWithSite* iface, REFIID riid, void** ppvObject )
{ {
domdoc *This = impl_from_IObjectWithSite(iface); domdoc *This = impl_from_IObjectWithSite(iface);
return IXMLDOMDocument3_QueryInterface( (IXMLDOMDocument3 *)This, riid, ppvObject ); return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppvObject);
} }
static ULONG WINAPI domdoc_ObjectWithSite_AddRef( IObjectWithSite* iface ) static ULONG WINAPI domdoc_ObjectWithSite_AddRef( IObjectWithSite* iface )
{ {
domdoc *This = impl_from_IObjectWithSite(iface); domdoc *This = impl_from_IObjectWithSite(iface);
return IXMLDOMDocument3_AddRef((IXMLDOMDocument3 *)This); return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
} }
static ULONG WINAPI domdoc_ObjectWithSite_Release( IObjectWithSite* iface ) static ULONG WINAPI domdoc_ObjectWithSite_Release( IObjectWithSite* iface )
{ {
domdoc *This = impl_from_IObjectWithSite(iface); domdoc *This = impl_from_IObjectWithSite(iface);
return IXMLDOMDocument3_Release((IXMLDOMDocument3 *)This); return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
} }
static HRESULT WINAPI domdoc_ObjectWithSite_GetSite( IObjectWithSite *iface, REFIID iid, void **ppvSite ) static HRESULT WINAPI domdoc_ObjectWithSite_GetSite( IObjectWithSite *iface, REFIID iid, void **ppvSite )
@ -3380,19 +3380,19 @@ static const IObjectWithSiteVtbl domdocObjectSite =
static HRESULT WINAPI domdoc_Safety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv) static HRESULT WINAPI domdoc_Safety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
{ {
domdoc *This = impl_from_IObjectSafety(iface); domdoc *This = impl_from_IObjectSafety(iface);
return IXMLDOMDocument3_QueryInterface( (IXMLDOMDocument3 *)This, riid, ppv ); return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppv);
} }
static ULONG WINAPI domdoc_Safety_AddRef(IObjectSafety *iface) static ULONG WINAPI domdoc_Safety_AddRef(IObjectSafety *iface)
{ {
domdoc *This = impl_from_IObjectSafety(iface); domdoc *This = impl_from_IObjectSafety(iface);
return IXMLDOMDocument3_AddRef((IXMLDOMDocument3 *)This); return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
} }
static ULONG WINAPI domdoc_Safety_Release(IObjectSafety *iface) static ULONG WINAPI domdoc_Safety_Release(IObjectSafety *iface)
{ {
domdoc *This = impl_from_IObjectSafety(iface); domdoc *This = impl_from_IObjectSafety(iface);
return IXMLDOMDocument3_Release((IXMLDOMDocument3 *)This); return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
} }
#define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER) #define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER)
@ -3456,12 +3456,12 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document)
if( !doc ) if( !doc )
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
doc->lpVtbl = &domdoc_vtbl; doc->IXMLDOMDocument3_iface.lpVtbl = &domdoc_vtbl;
doc->lpvtblIPersistStreamInit = &xmldoc_IPersistStreamInit_VTable; doc->IPersistStreamInit_iface.lpVtbl = &xmldoc_IPersistStreamInit_VTable;
doc->lpvtblIObjectWithSite = &domdocObjectSite; doc->IObjectWithSite_iface.lpVtbl = &domdocObjectSite;
doc->lpvtblIObjectSafety = &domdocObjectSafetyVtbl; doc->IObjectSafety_iface.lpVtbl = &domdocObjectSafetyVtbl;
doc->lpvtblISupportErrorInfo = &support_error_vtbl; doc->ISupportErrorInfo_iface.lpVtbl = &support_error_vtbl;
doc->lpVtblConnectionPointContainer = &ConnectionPointContainerVtbl; doc->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
doc->ref = 1; doc->ref = 1;
doc->async = VARIANT_TRUE; doc->async = VARIANT_TRUE;
doc->validating = 0; doc->validating = 0;
@ -3480,9 +3480,10 @@ HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document)
ConnectionPoint_Init(&doc->cp_propnotif, doc, &IID_IPropertyNotifySink); ConnectionPoint_Init(&doc->cp_propnotif, doc, &IID_IPropertyNotifySink);
ConnectionPoint_Init(&doc->cp_domdocevents, doc, &DIID_XMLDOMDocumentEvents); ConnectionPoint_Init(&doc->cp_domdocevents, doc, &DIID_XMLDOMDocumentEvents);
init_xmlnode(&doc->node, (xmlNodePtr)xmldoc, (IXMLDOMNode*)&doc->lpVtbl, &domdoc_dispex); init_xmlnode(&doc->node, (xmlNodePtr)xmldoc, (IXMLDOMNode*)&doc->IXMLDOMDocument3_iface,
&domdoc_dispex);
*document = (IXMLDOMDocument3*)&doc->lpVtbl; *document = &doc->IXMLDOMDocument3_iface;
TRACE("returning iface %p\n", *document); TRACE("returning iface %p\n", *document);
return S_OK; return S_OK;