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