oleaut32/tests: COM cleanup in vartype.c.
This commit is contained in:
parent
c7b4964b7e
commit
6fade2400a
|
@ -18,6 +18,8 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define CONST_VTABLE
|
||||||
|
|
||||||
#include "wine/test.h"
|
#include "wine/test.h"
|
||||||
#include "oleauto.h"
|
#include "oleauto.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -514,7 +516,7 @@ typedef struct tagINTERNAL_BSTR
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const IDispatchVtbl *lpVtbl;
|
IDispatch IDispatch_iface;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
VARTYPE vt;
|
VARTYPE vt;
|
||||||
BOOL bFailInvoke;
|
BOOL bFailInvoke;
|
||||||
|
@ -522,16 +524,25 @@ typedef struct
|
||||||
|
|
||||||
static DummyDispatch dispatch;
|
static DummyDispatch dispatch;
|
||||||
|
|
||||||
|
static inline DummyDispatch *impl_from_IDispatch(IDispatch *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, DummyDispatch, IDispatch_iface);
|
||||||
|
}
|
||||||
|
|
||||||
static ULONG WINAPI DummyDispatch_AddRef(LPDISPATCH iface)
|
static ULONG WINAPI DummyDispatch_AddRef(LPDISPATCH iface)
|
||||||
{
|
{
|
||||||
|
DummyDispatch *This = impl_from_IDispatch(iface);
|
||||||
|
|
||||||
trace("AddRef(%p)\n", iface);
|
trace("AddRef(%p)\n", iface);
|
||||||
return InterlockedIncrement(&((DummyDispatch*)iface)->ref);
|
return InterlockedIncrement(&This->ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI DummyDispatch_Release(LPDISPATCH iface)
|
static ULONG WINAPI DummyDispatch_Release(LPDISPATCH iface)
|
||||||
{
|
{
|
||||||
|
DummyDispatch *This = impl_from_IDispatch(iface);
|
||||||
|
|
||||||
trace("Release(%p)\n", iface);
|
trace("Release(%p)\n", iface);
|
||||||
return InterlockedDecrement(&((DummyDispatch*)iface)->ref);
|
return InterlockedDecrement(&This->ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI DummyDispatch_QueryInterface(LPDISPATCH iface,
|
static HRESULT WINAPI DummyDispatch_QueryInterface(LPDISPATCH iface,
|
||||||
|
@ -592,7 +603,7 @@ static const IDispatchVtbl DummyDispatch_VTable =
|
||||||
DummyDispatch_Invoke
|
DummyDispatch_Invoke
|
||||||
};
|
};
|
||||||
|
|
||||||
static DummyDispatch dispatch = { &DummyDispatch_VTable, 1, 0, 0 };
|
static DummyDispatch dispatch = { { &DummyDispatch_VTable }, 1, 0, 0 };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VT_I1/VT_UI1
|
* VT_I1/VT_UI1
|
||||||
|
@ -1094,11 +1105,11 @@ static void test_VarUI1FromDisp(void)
|
||||||
VariantInit(&vDst);
|
VariantInit(&vDst);
|
||||||
|
|
||||||
V_VT(&vSrc) = VT_DISPATCH;
|
V_VT(&vSrc) = VT_DISPATCH;
|
||||||
V_DISPATCH(&vSrc) = (IDispatch*)&dispatch;
|
V_DISPATCH(&vSrc) = &dispatch.IDispatch_iface;
|
||||||
dispatch.vt = VT_UI1;
|
dispatch.vt = VT_UI1;
|
||||||
dispatch.bFailInvoke = FALSE;
|
dispatch.bFailInvoke = FALSE;
|
||||||
|
|
||||||
hres = pVarUI1FromDisp((IDispatch*)&dispatch, in, &out);
|
hres = pVarUI1FromDisp(&dispatch.IDispatch_iface, in, &out);
|
||||||
trace("0x%08x\n", hres);
|
trace("0x%08x\n", hres);
|
||||||
|
|
||||||
hres = VariantChangeTypeEx(&vDst, &vSrc, in, 0, VT_UI1);
|
hres = VariantChangeTypeEx(&vDst, &vSrc, in, 0, VT_UI1);
|
||||||
|
@ -1106,7 +1117,7 @@ static void test_VarUI1FromDisp(void)
|
||||||
|
|
||||||
dispatch.bFailInvoke = TRUE;
|
dispatch.bFailInvoke = TRUE;
|
||||||
|
|
||||||
hres = pVarUI1FromDisp((IDispatch*)&dispatch, in, &out);
|
hres = pVarUI1FromDisp(&dispatch.IDispatch_iface, in, &out);
|
||||||
trace("0x%08x\n", hres);
|
trace("0x%08x\n", hres);
|
||||||
|
|
||||||
hres = VariantChangeTypeEx(&vDst, &vSrc, in, 0, VT_UI1);
|
hres = VariantChangeTypeEx(&vDst, &vSrc, in, 0, VT_UI1);
|
||||||
|
@ -5579,12 +5590,12 @@ static void test_IUnknownClear(void)
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
VARIANTARG v;
|
VARIANTARG v;
|
||||||
DummyDispatch u = { &DummyDispatch_VTable, 1, VT_UI1, FALSE };
|
DummyDispatch u = { { &DummyDispatch_VTable }, 1, VT_UI1, FALSE };
|
||||||
IUnknown* pu = (IUnknown*)&u;
|
IUnknown* pu = (IUnknown*)&u.IDispatch_iface;
|
||||||
|
|
||||||
/* Test that IUnknown_Release is called on by-value */
|
/* Test that IUnknown_Release is called on by-value */
|
||||||
V_VT(&v) = VT_UNKNOWN;
|
V_VT(&v) = VT_UNKNOWN;
|
||||||
V_UNKNOWN(&v) = (IUnknown*)&u;
|
V_UNKNOWN(&v) = (IUnknown*)&u.IDispatch_iface;
|
||||||
hres = VariantClear(&v);
|
hres = VariantClear(&v);
|
||||||
ok(hres == S_OK && u.ref == 0 && V_VT(&v) == VT_EMPTY,
|
ok(hres == S_OK && u.ref == 0 && V_VT(&v) == VT_EMPTY,
|
||||||
"clear unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
|
"clear unknown: expected 0x%08x, %d, %d, got 0x%08x, %d, %d\n",
|
||||||
|
@ -5604,8 +5615,8 @@ static void test_IUnknownCopy(void)
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
VARIANTARG vSrc, vDst;
|
VARIANTARG vSrc, vDst;
|
||||||
DummyDispatch u = { &DummyDispatch_VTable, 1, VT_UI1, FALSE };
|
DummyDispatch u = { { &DummyDispatch_VTable }, 1, VT_UI1, FALSE };
|
||||||
IUnknown* pu = (IUnknown*)&u;
|
IUnknown* pu = (IUnknown*)&u.IDispatch_iface;
|
||||||
|
|
||||||
/* AddRef is called on by-value copy */
|
/* AddRef is called on by-value copy */
|
||||||
VariantInit(&vDst);
|
VariantInit(&vDst);
|
||||||
|
@ -5652,8 +5663,8 @@ static void test_IUnknownChangeTypeEx(void)
|
||||||
VARIANTARG vSrc, vDst;
|
VARIANTARG vSrc, vDst;
|
||||||
LCID lcid;
|
LCID lcid;
|
||||||
VARTYPE vt;
|
VARTYPE vt;
|
||||||
DummyDispatch u = { &DummyDispatch_VTable, 1, VT_UI1, FALSE };
|
DummyDispatch u = { { &DummyDispatch_VTable }, 1, VT_UI1, FALSE };
|
||||||
IUnknown* pu = (IUnknown*)&u;
|
IUnknown* pu = (IUnknown*)&u.IDispatch_iface;
|
||||||
|
|
||||||
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
|
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
|
||||||
|
|
||||||
|
@ -5720,8 +5731,8 @@ static void test_IDispatchClear(void)
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
VARIANTARG v;
|
VARIANTARG v;
|
||||||
DummyDispatch d = { &DummyDispatch_VTable, 1, VT_UI1, FALSE };
|
DummyDispatch d = { { &DummyDispatch_VTable }, 1, VT_UI1, FALSE };
|
||||||
IDispatch* pd = (IDispatch*)&d;
|
IDispatch* pd = &d.IDispatch_iface;
|
||||||
|
|
||||||
/* As per IUnknown */
|
/* As per IUnknown */
|
||||||
|
|
||||||
|
@ -5745,8 +5756,8 @@ static void test_IDispatchCopy(void)
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
VARIANTARG vSrc, vDst;
|
VARIANTARG vSrc, vDst;
|
||||||
DummyDispatch d = { &DummyDispatch_VTable, 1, VT_UI1, FALSE };
|
DummyDispatch d = { { &DummyDispatch_VTable }, 1, VT_UI1, FALSE };
|
||||||
IDispatch* pd = (IDispatch*)&d;
|
IDispatch* pd = &d.IDispatch_iface;
|
||||||
|
|
||||||
/* As per IUnknown */
|
/* As per IUnknown */
|
||||||
|
|
||||||
|
@ -5790,8 +5801,8 @@ static void test_IDispatchChangeTypeEx(void)
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
VARIANTARG vSrc, vDst;
|
VARIANTARG vSrc, vDst;
|
||||||
LCID lcid;
|
LCID lcid;
|
||||||
DummyDispatch d = { &DummyDispatch_VTable, 1, VT_UI1, FALSE };
|
DummyDispatch d = { { &DummyDispatch_VTable }, 1, VT_UI1, FALSE };
|
||||||
IDispatch* pd = (IDispatch*)&d;
|
IDispatch* pd = &d.IDispatch_iface;
|
||||||
|
|
||||||
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
|
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue