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

fusion: COM cleanup for the IAssemblyName iface.

parent 7f39b9e9
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(fusion); WINE_DEFAULT_DEBUG_CHANNEL(fusion);
typedef struct { typedef struct {
const IAssemblyNameVtbl *lpIAssemblyNameVtbl; IAssemblyName IAssemblyName_iface;
LPWSTR path; LPWSTR path;
...@@ -67,10 +67,15 @@ static const WCHAR procarch[] = {'p','r','o','c','e','s','s','o','r', ...@@ -67,10 +67,15 @@ static const WCHAR procarch[] = {'p','r','o','c','e','s','s','o','r',
#define CHARS_PER_PUBKEY 16 #define CHARS_PER_PUBKEY 16
static inline IAssemblyNameImpl *impl_from_IAssemblyName(IAssemblyName *iface)
{
return CONTAINING_RECORD(iface, IAssemblyNameImpl, IAssemblyName_iface);
}
static HRESULT WINAPI IAssemblyNameImpl_QueryInterface(IAssemblyName *iface, static HRESULT WINAPI IAssemblyNameImpl_QueryInterface(IAssemblyName *iface,
REFIID riid, LPVOID *ppobj) REFIID riid, LPVOID *ppobj)
{ {
IAssemblyNameImpl *This = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *This = impl_from_IAssemblyName(iface);
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj); TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppobj);
...@@ -90,7 +95,7 @@ static HRESULT WINAPI IAssemblyNameImpl_QueryInterface(IAssemblyName *iface, ...@@ -90,7 +95,7 @@ static HRESULT WINAPI IAssemblyNameImpl_QueryInterface(IAssemblyName *iface,
static ULONG WINAPI IAssemblyNameImpl_AddRef(IAssemblyName *iface) static ULONG WINAPI IAssemblyNameImpl_AddRef(IAssemblyName *iface)
{ {
IAssemblyNameImpl *This = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *This = impl_from_IAssemblyName(iface);
ULONG refCount = InterlockedIncrement(&This->ref); ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before = %u)\n", This, refCount - 1); TRACE("(%p)->(ref before = %u)\n", This, refCount - 1);
...@@ -100,7 +105,7 @@ static ULONG WINAPI IAssemblyNameImpl_AddRef(IAssemblyName *iface) ...@@ -100,7 +105,7 @@ static ULONG WINAPI IAssemblyNameImpl_AddRef(IAssemblyName *iface)
static ULONG WINAPI IAssemblyNameImpl_Release(IAssemblyName *iface) static ULONG WINAPI IAssemblyNameImpl_Release(IAssemblyName *iface)
{ {
IAssemblyNameImpl *This = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *This = impl_from_IAssemblyName(iface);
ULONG refCount = InterlockedDecrement(&This->ref); ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before = %u)\n", This, refCount + 1); TRACE("(%p)->(ref before = %u)\n", This, refCount + 1);
...@@ -132,7 +137,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetProperty(IAssemblyName *iface, ...@@ -132,7 +137,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetProperty(IAssemblyName *iface,
LPVOID pvProperty, LPVOID pvProperty,
LPDWORD pcbProperty) LPDWORD pcbProperty)
{ {
IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
TRACE("(%p, %d, %p, %p)\n", iface, PropertyId, pvProperty, pcbProperty); TRACE("(%p, %d, %p, %p)\n", iface, PropertyId, pvProperty, pcbProperty);
...@@ -223,7 +228,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetDisplayName(IAssemblyName *iface, ...@@ -223,7 +228,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetDisplayName(IAssemblyName *iface,
LPDWORD pccDisplayName, LPDWORD pccDisplayName,
DWORD dwDisplayFlags) DWORD dwDisplayFlags)
{ {
IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
WCHAR verstr[30]; WCHAR verstr[30];
DWORD size; DWORD size;
LPWSTR cultureval = 0; LPWSTR cultureval = 0;
...@@ -363,7 +368,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetName(IAssemblyName *iface, ...@@ -363,7 +368,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetName(IAssemblyName *iface,
LPDWORD lpcwBuffer, LPDWORD lpcwBuffer,
WCHAR *pwzName) WCHAR *pwzName)
{ {
IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
TRACE("(%p, %p, %p)\n", iface, lpcwBuffer, pwzName); TRACE("(%p, %p, %p)\n", iface, lpcwBuffer, pwzName);
...@@ -384,7 +389,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetVersion(IAssemblyName *iface, ...@@ -384,7 +389,7 @@ static HRESULT WINAPI IAssemblyNameImpl_GetVersion(IAssemblyName *iface,
LPDWORD pdwVersionHi, LPDWORD pdwVersionHi,
LPDWORD pdwVersionLow) LPDWORD pdwVersionLow)
{ {
IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *name = impl_from_IAssemblyName(iface);
TRACE("(%p, %p, %p)\n", iface, pdwVersionHi, pdwVersionLow); TRACE("(%p, %p, %p)\n", iface, pdwVersionHi, pdwVersionLow);
...@@ -431,11 +436,16 @@ static const IAssemblyNameVtbl AssemblyNameVtbl = { ...@@ -431,11 +436,16 @@ static const IAssemblyNameVtbl AssemblyNameVtbl = {
}; };
/* Internal methods */ /* Internal methods */
HRESULT IAssemblyName_SetPath(IAssemblyName *iface, LPCWSTR path) static inline IAssemblyNameImpl *unsafe_impl_from_IAssemblyName(IAssemblyName *iface)
{ {
IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; assert(iface->lpVtbl == &AssemblyNameVtbl);
assert(name->lpIAssemblyNameVtbl == &AssemblyNameVtbl); return impl_from_IAssemblyName(iface);
}
HRESULT IAssemblyName_SetPath(IAssemblyName *iface, LPCWSTR path)
{
IAssemblyNameImpl *name = unsafe_impl_from_IAssemblyName(iface);
name->path = strdupW(path); name->path = strdupW(path);
if (!name->path) if (!name->path)
...@@ -447,9 +457,7 @@ HRESULT IAssemblyName_SetPath(IAssemblyName *iface, LPCWSTR path) ...@@ -447,9 +457,7 @@ HRESULT IAssemblyName_SetPath(IAssemblyName *iface, LPCWSTR path)
HRESULT IAssemblyName_GetPath(IAssemblyName *iface, LPWSTR buf, ULONG *len) HRESULT IAssemblyName_GetPath(IAssemblyName *iface, LPWSTR buf, ULONG *len)
{ {
ULONG buffer_size = *len; ULONG buffer_size = *len;
IAssemblyNameImpl *name = (IAssemblyNameImpl *)iface; IAssemblyNameImpl *name = unsafe_impl_from_IAssemblyName(iface);
assert(name->lpIAssemblyNameVtbl == &AssemblyNameVtbl);
if (!name->path) if (!name->path)
return S_OK; return S_OK;
...@@ -672,7 +680,7 @@ HRESULT WINAPI CreateAssemblyNameObject(LPASSEMBLYNAME *ppAssemblyNameObj, ...@@ -672,7 +680,7 @@ HRESULT WINAPI CreateAssemblyNameObject(LPASSEMBLYNAME *ppAssemblyNameObj,
if (!name) if (!name)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
name->lpIAssemblyNameVtbl = &AssemblyNameVtbl; name->IAssemblyName_iface.lpVtbl = &AssemblyNameVtbl;
name->ref = 1; name->ref = 1;
hr = parse_display_name(name, szAssemblyName); hr = parse_display_name(name, szAssemblyName);
...@@ -682,7 +690,7 @@ HRESULT WINAPI CreateAssemblyNameObject(LPASSEMBLYNAME *ppAssemblyNameObj, ...@@ -682,7 +690,7 @@ HRESULT WINAPI CreateAssemblyNameObject(LPASSEMBLYNAME *ppAssemblyNameObj,
return hr; return hr;
} }
*ppAssemblyNameObj = (IAssemblyName *)name; *ppAssemblyNameObj = &name->IAssemblyName_iface;
return S_OK; return S_OK;
} }
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