mshtml: Use an iface instead of a vtbl pointer in HTMLLoadOptions.

Michael Stefaniuc mstefani at redhat.de
Mon Dec 6 16:32:10 CST 2010


---
 dlls/mshtml/loadopts.c |   35 +++++++++++++++++------------------
 1 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/dlls/mshtml/loadopts.c b/dlls/mshtml/loadopts.c
index 8648f16..bc5e31f 100644
--- a/dlls/mshtml/loadopts.c
+++ b/dlls/mshtml/loadopts.c
@@ -44,37 +44,38 @@ typedef struct load_opt {
 } load_opt;
 
 typedef struct {
-    const IHtmlLoadOptionsVtbl *lpHtmlLoadOptionsVtbl;
+    IHtmlLoadOptions IHtmlLoadOptions_iface;
 
     LONG ref;
 
     load_opt *opts;
 } HTMLLoadOptions;
 
-#define LOADOPTS(x)  ((IHtmlLoadOptions*) &(x)->lpHtmlLoadOptionsVtbl)
-
-#define LOADOPTS_THIS(iface) DEFINE_THIS(HTMLLoadOptions, HtmlLoadOptions, iface)
+static inline HTMLLoadOptions *impl_from_IHtmlLoadOptions(IHtmlLoadOptions *iface)
+{
+    return CONTAINING_RECORD(iface, HTMLLoadOptions, IHtmlLoadOptions_iface);
+}
 
 static HRESULT WINAPI HtmlLoadOptions_QueryInterface(IHtmlLoadOptions *iface,
         REFIID riid, void **ppv)
 {
-    HTMLLoadOptions *This = LOADOPTS_THIS(iface);
+    HTMLLoadOptions *This = impl_from_IHtmlLoadOptions(iface);
 
     *ppv = NULL;
 
     if(IsEqualGUID(&IID_IUnknown, riid)) {
         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
-        *ppv = LOADOPTS(This);
+        *ppv = &This->IHtmlLoadOptions_iface;
     }else if(IsEqualGUID(&IID_IOptionArray, riid)) {
         TRACE("(%p)->(IID_IOptionArray %p)\n", This, ppv);
-        *ppv = LOADOPTS(This);
+        *ppv = &This->IHtmlLoadOptions_iface;
     }else if(IsEqualGUID(&IID_IHtmlLoadOptions, riid)) {
         TRACE("(%p)->(IID_IHtmlLoadOptions %p)\n", This, ppv);
-        *ppv = LOADOPTS(This);
+        *ppv = &This->IHtmlLoadOptions_iface;
     }
 
     if(*ppv) {
-        IHtmlLoadOptions_AddRef(LOADOPTS(This));
+        IHtmlLoadOptions_AddRef(&This->IHtmlLoadOptions_iface);
         return S_OK;
     }
 
@@ -84,7 +85,7 @@ static HRESULT WINAPI HtmlLoadOptions_QueryInterface(IHtmlLoadOptions *iface,
 
 static ULONG WINAPI HtmlLoadOptions_AddRef(IHtmlLoadOptions *iface)
 {
-    HTMLLoadOptions *This = LOADOPTS_THIS(iface);
+    HTMLLoadOptions *This = impl_from_IHtmlLoadOptions(iface);
     LONG ref = InterlockedIncrement(&This->ref);
 
     TRACE("(%p) ref=%d\n", This, ref);
@@ -94,7 +95,7 @@ static ULONG WINAPI HtmlLoadOptions_AddRef(IHtmlLoadOptions *iface)
 
 static ULONG WINAPI HtmlLoadOptions_Release(IHtmlLoadOptions *iface)
 {
-    HTMLLoadOptions *This = LOADOPTS_THIS(iface);
+    HTMLLoadOptions *This = impl_from_IHtmlLoadOptions(iface);
     LONG ref = InterlockedDecrement(&This->ref);
 
     TRACE("(%p) ref=%d\n", This, ref);
@@ -119,7 +120,7 @@ static ULONG WINAPI HtmlLoadOptions_Release(IHtmlLoadOptions *iface)
 static HRESULT WINAPI HtmlLoadOptions_QueryOption(IHtmlLoadOptions *iface, DWORD dwOption,
         LPVOID pBuffer, ULONG *pcbBuf)
 {
-    HTMLLoadOptions *This = LOADOPTS_THIS(iface);
+    HTMLLoadOptions *This = impl_from_IHtmlLoadOptions(iface);
     load_opt *iter;
 
     TRACE("(%p)->(%d %p %p)\n", This, dwOption, pBuffer, pcbBuf);
@@ -148,7 +149,7 @@ static HRESULT WINAPI HtmlLoadOptions_QueryOption(IHtmlLoadOptions *iface, DWORD
 static HRESULT WINAPI HtmlLoadOptions_SetOption(IHtmlLoadOptions *iface, DWORD dwOption,
         LPVOID pBuffer, ULONG cbBuf)
 {
-    HTMLLoadOptions *This = LOADOPTS_THIS(iface);
+    HTMLLoadOptions *This = impl_from_IHtmlLoadOptions(iface);
     load_opt *iter = NULL;
 
     TRACE("(%p)->(%d %p %d)\n", This, dwOption, pBuffer, cbBuf);
@@ -182,8 +183,6 @@ static HRESULT WINAPI HtmlLoadOptions_SetOption(IHtmlLoadOptions *iface, DWORD d
     return S_OK;
 }
 
-#undef LOADOPTS_THIS
-
 static const IHtmlLoadOptionsVtbl HtmlLoadOptionsVtbl = {
     HtmlLoadOptions_QueryInterface,
     HtmlLoadOptions_AddRef,
@@ -201,12 +200,12 @@ HRESULT HTMLLoadOptions_Create(IUnknown *pUnkOuter, REFIID riid, void** ppv)
 
     ret = heap_alloc(sizeof(HTMLLoadOptions));
 
-    ret->lpHtmlLoadOptionsVtbl = &HtmlLoadOptionsVtbl;
+    ret->IHtmlLoadOptions_iface.lpVtbl = &HtmlLoadOptionsVtbl;
     ret->ref = 1;
     ret->opts = NULL;
 
-    hres = IHtmlLoadOptions_QueryInterface(LOADOPTS(ret), riid, ppv);
-    IHtmlLoadOptions_Release(LOADOPTS(ret));
+    hres = IHtmlLoadOptions_QueryInterface(&ret->IHtmlLoadOptions_iface, riid, ppv);
+    IHtmlLoadOptions_Release(&ret->IHtmlLoadOptions_iface);
 
     return hres;
 }
-- 
1.7.3.2



More information about the wine-patches mailing list