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

ole32: Standardize the COM usage in git.c.

parent 4c200a20
...@@ -64,7 +64,7 @@ typedef struct StdGITEntry ...@@ -64,7 +64,7 @@ typedef struct StdGITEntry
/* Class data */ /* Class data */
typedef struct StdGlobalInterfaceTableImpl typedef struct StdGlobalInterfaceTableImpl
{ {
const IGlobalInterfaceTableVtbl *lpVtbl; IGlobalInterfaceTable IGlobalInterfaceTable_iface;
ULONG ref; ULONG ref;
struct list list; struct list list;
...@@ -84,13 +84,18 @@ static CRITICAL_SECTION_DEBUG critsect_debug = ...@@ -84,13 +84,18 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
static CRITICAL_SECTION git_section = { &critsect_debug, -1, 0, 0, 0, 0 }; static CRITICAL_SECTION git_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static inline StdGlobalInterfaceTableImpl *impl_from_IGlobalInterfaceTable(IGlobalInterfaceTable *iface)
{
return CONTAINING_RECORD(iface, StdGlobalInterfaceTableImpl, IGlobalInterfaceTable_iface);
}
/** This destroys it again. It should revoke all the held interfaces first **/ /** This destroys it again. It should revoke all the held interfaces first **/
static void StdGlobalInterfaceTable_Destroy(void* self) static void StdGlobalInterfaceTable_Destroy(void* This)
{ {
TRACE("(%p)\n", self); TRACE("(%p)\n", This);
FIXME("Revoke held interfaces here\n"); FIXME("Revoke held interfaces here\n");
HeapFree(GetProcessHeap(), 0, self); HeapFree(GetProcessHeap(), 0, This);
StdGlobalInterfaceTableInstance = NULL; StdGlobalInterfaceTableInstance = NULL;
} }
...@@ -98,15 +103,14 @@ static void StdGlobalInterfaceTable_Destroy(void* self) ...@@ -98,15 +103,14 @@ static void StdGlobalInterfaceTable_Destroy(void* self)
* A helper function to traverse the list and find the entry that matches the cookie. * A helper function to traverse the list and find the entry that matches the cookie.
* Returns NULL if not found. Must be called inside git_section critical section. * Returns NULL if not found. Must be called inside git_section critical section.
*/ */
static StdGITEntry* static StdGITEntry* StdGlobalInterfaceTable_FindEntry(StdGlobalInterfaceTableImpl* This,
StdGlobalInterfaceTable_FindEntry(IGlobalInterfaceTable* iface, DWORD cookie) DWORD cookie)
{ {
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface;
StdGITEntry* e; StdGITEntry* e;
TRACE("iface=%p, cookie=0x%x\n", iface, cookie); TRACE("This=%p, cookie=0x%x\n", This, cookie);
LIST_FOR_EACH_ENTRY(e, &self->list, StdGITEntry, entry) { LIST_FOR_EACH_ENTRY(e, &This->list, StdGITEntry, entry) {
if (e->cookie == cookie) if (e->cookie == cookie)
return e; return e;
} }
...@@ -143,25 +147,25 @@ StdGlobalInterfaceTable_QueryInterface(IGlobalInterfaceTable* iface, ...@@ -143,25 +147,25 @@ StdGlobalInterfaceTable_QueryInterface(IGlobalInterfaceTable* iface,
static ULONG WINAPI static ULONG WINAPI
StdGlobalInterfaceTable_AddRef(IGlobalInterfaceTable* iface) StdGlobalInterfaceTable_AddRef(IGlobalInterfaceTable* iface)
{ {
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface; StdGlobalInterfaceTableImpl* const This = impl_from_IGlobalInterfaceTable(iface);
/* InterlockedIncrement(&self->ref); */ /* InterlockedIncrement(&This->ref); */
return self->ref; return This->ref;
} }
static ULONG WINAPI static ULONG WINAPI
StdGlobalInterfaceTable_Release(IGlobalInterfaceTable* iface) StdGlobalInterfaceTable_Release(IGlobalInterfaceTable* iface)
{ {
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface; StdGlobalInterfaceTableImpl* const This = impl_from_IGlobalInterfaceTable(iface);
/* InterlockedDecrement(&self->ref); */ /* InterlockedDecrement(&This->ref); */
if (self->ref == 0) { if (This->ref == 0) {
/* Hey ho, it's time to go, so long again 'till next weeks show! */ /* Hey ho, it's time to go, so long again 'till next weeks show! */
StdGlobalInterfaceTable_Destroy(self); StdGlobalInterfaceTable_Destroy(This);
return 0; return 0;
} }
return self->ref; return This->ref;
} }
/*** /***
...@@ -173,7 +177,7 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal( ...@@ -173,7 +177,7 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal(
IGlobalInterfaceTable* iface, IUnknown* pUnk, IGlobalInterfaceTable* iface, IUnknown* pUnk,
REFIID riid, DWORD* pdwCookie) REFIID riid, DWORD* pdwCookie)
{ {
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface; StdGlobalInterfaceTableImpl* const This = impl_from_IGlobalInterfaceTable(iface);
IStream* stream = NULL; IStream* stream = NULL;
HRESULT hres; HRESULT hres;
StdGITEntry* entry; StdGITEntry* entry;
...@@ -205,11 +209,11 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal( ...@@ -205,11 +209,11 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal(
entry->iid = *riid; entry->iid = *riid;
entry->stream = stream; entry->stream = stream;
entry->cookie = self->nextCookie; entry->cookie = This->nextCookie;
self->nextCookie++; /* inc the cookie count */ This->nextCookie++; /* inc the cookie count */
/* insert the new entry at the end of the list */ /* insert the new entry at the end of the list */
list_add_tail(&self->list, &entry->entry); list_add_tail(&This->list, &entry->entry);
/* and return the cookie */ /* and return the cookie */
*pdwCookie = entry->cookie; *pdwCookie = entry->cookie;
...@@ -224,6 +228,7 @@ static HRESULT WINAPI ...@@ -224,6 +228,7 @@ static HRESULT WINAPI
StdGlobalInterfaceTable_RevokeInterfaceFromGlobal( StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(
IGlobalInterfaceTable* iface, DWORD dwCookie) IGlobalInterfaceTable* iface, DWORD dwCookie)
{ {
StdGlobalInterfaceTableImpl* This = impl_from_IGlobalInterfaceTable(iface);
StdGITEntry* entry; StdGITEntry* entry;
HRESULT hr; HRESULT hr;
...@@ -231,7 +236,7 @@ StdGlobalInterfaceTable_RevokeInterfaceFromGlobal( ...@@ -231,7 +236,7 @@ StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(
EnterCriticalSection(&git_section); EnterCriticalSection(&git_section);
entry = StdGlobalInterfaceTable_FindEntry(iface, dwCookie); entry = StdGlobalInterfaceTable_FindEntry(This, dwCookie);
if (entry == NULL) { if (entry == NULL) {
TRACE("Entry not found\n"); TRACE("Entry not found\n");
LeaveCriticalSection(&git_section); LeaveCriticalSection(&git_section);
...@@ -260,6 +265,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal( ...@@ -260,6 +265,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal(
IGlobalInterfaceTable* iface, DWORD dwCookie, IGlobalInterfaceTable* iface, DWORD dwCookie,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
StdGlobalInterfaceTableImpl* This = impl_from_IGlobalInterfaceTable(iface);
StdGITEntry* entry; StdGITEntry* entry;
HRESULT hres; HRESULT hres;
IStream *stream; IStream *stream;
...@@ -268,7 +274,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal( ...@@ -268,7 +274,7 @@ StdGlobalInterfaceTable_GetInterfaceFromGlobal(
EnterCriticalSection(&git_section); EnterCriticalSection(&git_section);
entry = StdGlobalInterfaceTable_FindEntry(iface, dwCookie); entry = StdGlobalInterfaceTable_FindEntry(This, dwCookie);
if (entry == NULL) { if (entry == NULL) {
WARN("Entry for cookie 0x%x not found\n", dwCookie); WARN("Entry for cookie 0x%x not found\n", dwCookie);
LeaveCriticalSection(&git_section); LeaveCriticalSection(&git_section);
...@@ -380,7 +386,7 @@ void* StdGlobalInterfaceTable_Construct(void) ...@@ -380,7 +386,7 @@ void* StdGlobalInterfaceTable_Construct(void)
newGIT = HeapAlloc(GetProcessHeap(), 0, sizeof(StdGlobalInterfaceTableImpl)); newGIT = HeapAlloc(GetProcessHeap(), 0, sizeof(StdGlobalInterfaceTableImpl));
if (newGIT == 0) return newGIT; if (newGIT == 0) return newGIT;
newGIT->lpVtbl = &StdGlobalInterfaceTableImpl_Vtbl; newGIT->IGlobalInterfaceTable_iface.lpVtbl = &StdGlobalInterfaceTableImpl_Vtbl;
newGIT->ref = 1; /* Initialise the reference count */ newGIT->ref = 1; /* Initialise the reference count */
list_init(&newGIT->list); list_init(&newGIT->list);
newGIT->nextCookie = 0xf100; /* that's where windows starts, so that's where we start */ newGIT->nextCookie = 0xf100; /* that's where windows starts, so that's where we start */
......
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