Michael Stefaniuc : quartz: Use an iface instead of a vtbl pointer in SystemClockImpl.
Alexandre Julliard
julliard at winehq.org
Thu Dec 9 12:26:26 CST 2010
Module: wine
Branch: master
Commit: 9a0f38e21111821941d02f8416cf71ed37cb51b1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9a0f38e21111821941d02f8416cf71ed37cb51b1
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Wed Dec 8 22:59:35 2010 +0100
quartz: Use an iface instead of a vtbl pointer in SystemClockImpl.
---
dlls/quartz/systemclock.c | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/dlls/quartz/systemclock.c b/dlls/quartz/systemclock.c
index e48dbe4..842541b 100644
--- a/dlls/quartz/systemclock.c
+++ b/dlls/quartz/systemclock.c
@@ -37,7 +37,7 @@ struct SystemClockAdviseEntry {
};
typedef struct SystemClockImpl {
- const IReferenceClockVtbl *lpVtbl;
+ IReferenceClock IReferenceClock_iface;
LONG ref;
/** IReferenceClock */
@@ -52,6 +52,11 @@ typedef struct SystemClockImpl {
SystemClockAdviseEntry* pPeriodicAdvise;
} SystemClockImpl;
+static inline SystemClockImpl *impl_from_IReferenceClock(IReferenceClock *iface)
+{
+ return CONTAINING_RECORD(iface, SystemClockImpl, IReferenceClock_iface);
+}
+
static void QUARTZ_RemoveAviseEntryFromQueue(SystemClockImpl* This, SystemClockAdviseEntry* pEntry) {
if (pEntry->prev) pEntry->prev->next = pEntry->next;
@@ -104,7 +109,7 @@ static DWORD WINAPI SystemClockAdviseThread(LPVOID lpParam) {
EnterCriticalSection(&This->safe);
/*timeOut = IReferenceClock_OnTimerUpdated(This); */
- hr = IReferenceClock_GetTime((IReferenceClock*) This, &curTime);
+ hr = IReferenceClock_GetTime(&This->IReferenceClock_iface, &curTime);
if (FAILED(hr)) {
timeOut = INFINITE;
goto outrefresh;
@@ -191,7 +196,7 @@ static BOOL SystemClockPostMessageToAdviseThread(SystemClockImpl* This, UINT iMs
}
static ULONG WINAPI SystemClockImpl_AddRef(IReferenceClock* iface) {
- SystemClockImpl *This = (SystemClockImpl *)iface;
+ SystemClockImpl *This = impl_from_IReferenceClock(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p): AddRef from %d\n", This, ref - 1);
@@ -200,7 +205,7 @@ static ULONG WINAPI SystemClockImpl_AddRef(IReferenceClock* iface) {
}
static HRESULT WINAPI SystemClockImpl_QueryInterface(IReferenceClock* iface, REFIID riid, void** ppobj) {
- SystemClockImpl *This = (SystemClockImpl *)iface;
+ SystemClockImpl *This = impl_from_IReferenceClock(iface);
TRACE("(%p, %s,%p)\n", This, debugstr_guid(riid), ppobj);
if (IsEqualIID (riid, &IID_IUnknown) ||
@@ -216,7 +221,7 @@ static HRESULT WINAPI SystemClockImpl_QueryInterface(IReferenceClock* iface, REF
}
static ULONG WINAPI SystemClockImpl_Release(IReferenceClock* iface) {
- SystemClockImpl *This = (SystemClockImpl *)iface;
+ SystemClockImpl *This = impl_from_IReferenceClock(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p): ReleaseRef to %d\n", This, ref);
if (ref == 0) {
@@ -232,7 +237,7 @@ static ULONG WINAPI SystemClockImpl_Release(IReferenceClock* iface) {
}
static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock* iface, REFERENCE_TIME* pTime) {
- SystemClockImpl *This = (SystemClockImpl *)iface;
+ SystemClockImpl *This = impl_from_IReferenceClock(iface);
DWORD curTimeTickCount;
HRESULT hr = S_OK;
@@ -254,7 +259,7 @@ static HRESULT WINAPI SystemClockImpl_GetTime(IReferenceClock* iface, REFERENCE_
}
static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock* iface, REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, HEVENT hEvent, DWORD_PTR* pdwAdviseCookie) {
- SystemClockImpl *This = (SystemClockImpl *)iface;
+ SystemClockImpl *This = impl_from_IReferenceClock(iface);
SystemClockAdviseEntry* pEntry = NULL;
TRACE("(%p, 0x%s, 0x%s, %ld, %p)\n", This, wine_dbgstr_longlong(rtBaseTime),
@@ -290,7 +295,7 @@ static HRESULT WINAPI SystemClockImpl_AdviseTime(IReferenceClock* iface, REFEREN
}
static HRESULT WINAPI SystemClockImpl_AdvisePeriodic(IReferenceClock* iface, REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, HSEMAPHORE hSemaphore, DWORD_PTR* pdwAdviseCookie) {
- SystemClockImpl *This = (SystemClockImpl *)iface;
+ SystemClockImpl *This = impl_from_IReferenceClock(iface);
SystemClockAdviseEntry* pEntry = NULL;
TRACE("(%p, 0x%s, 0x%s, %ld, %p)\n", This, wine_dbgstr_longlong(rtStartTime),
@@ -326,7 +331,7 @@ static HRESULT WINAPI SystemClockImpl_AdvisePeriodic(IReferenceClock* iface, REF
}
static HRESULT WINAPI SystemClockImpl_Unadvise(IReferenceClock* iface, DWORD_PTR dwAdviseCookie) {
- SystemClockImpl *This = (SystemClockImpl *)iface;
+ SystemClockImpl *This = impl_from_IReferenceClock(iface);
SystemClockAdviseEntry* pEntry = NULL;
SystemClockAdviseEntry* it = NULL;
HRESULT ret = S_OK;
@@ -377,12 +382,12 @@ HRESULT QUARTZ_CreateSystemClock(IUnknown * pUnkOuter, LPVOID * ppv) {
}
ZeroMemory(obj, sizeof(SystemClockImpl));
- obj->lpVtbl = &SystemClock_Vtbl;
+ obj->IReferenceClock_iface.lpVtbl = &SystemClock_Vtbl;
obj->ref = 0; /* will be inited by QueryInterface */
obj->lastTimeTickCount = GetTickCount();
InitializeCriticalSection(&obj->safe);
obj->safe.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SystemClockImpl.safe");
- return SystemClockImpl_QueryInterface((IReferenceClock*) obj, &IID_IReferenceClock, ppv);
+ return SystemClockImpl_QueryInterface(&obj->IReferenceClock_iface, &IID_IReferenceClock, ppv);
}
More information about the wine-cvs
mailing list