*
*/
+#include <math.h>
+
#define COBJMACROS
#define CONST_VTABLE
#include "wine/test.h"
#include "tmarshal.h"
-#include "tmarshal_dispids.h"
static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT);
#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
-
-#ifdef __i386__
-static const int tmarshal_todo = 0;
-#else
-static const int tmarshal_todo = 1;
-#endif
+static inline void release_iface_(unsigned int line, void *iface)
+{
+ ULONG ref = IUnknown_Release((IUnknown *)iface);
+ ok_(__FILE__, line)(!ref, "Got outstanding refcount %d.\n", ref);
+ if (ref == 1) IUnknown_Release((IUnknown *)iface);
+}
+#define release_iface(a) release_iface_(__LINE__, a)
/* ULL suffix is not portable */
#define ULL_CONST(dw1, dw2) ((((ULONGLONG)dw1) << 32) | (ULONGLONG)dw2)
-const MYSTRUCT MYSTRUCT_BYVAL = {0x12345678, ULL_CONST(0xdeadbeef, 0x98765432), {0,1,2,3,4,5,6,7}};
-const MYSTRUCT MYSTRUCT_BYPTR = {0x91827364, ULL_CONST(0x88776655, 0x44332211), {0,1,2,3,4,5,6,7}};
-const MYSTRUCT MYSTRUCT_ARRAY[5] = {
- {0x1a1b1c1d, ULL_CONST(0x1e1f1011, 0x12131415), {0,1,2,3,4,5,6,7}},
- {0x2a2b2c2d, ULL_CONST(0x2e2f2021, 0x22232425), {0,1,2,3,4,5,6,7}},
- {0x3a3b3c3d, ULL_CONST(0x3e3f3031, 0x32333435), {0,1,2,3,4,5,6,7}},
- {0x4a4b4c4d, ULL_CONST(0x4e4f4041, 0x42434445), {0,1,2,3,4,5,6,7}},
- {0x5a5b5c5d, ULL_CONST(0x5e5f5051, 0x52535455), {0,1,2,3,4,5,6,7}},
-};
-
+static const WCHAR test_bstr1[] = {'f','o','o',0,'b','a','r'};
+static const WCHAR test_bstr2[] = {'t','e','s','t',0};
+static const WCHAR test_bstr3[] = {'q','u','x',0};
+static const WCHAR test_bstr4[] = {'a','b','c',0};
+
+static const MYSTRUCT test_mystruct1 = {0x12345678, ULL_CONST(0xdeadbeef, 0x98765432), {0,1,2,3,4,5,6,7}};
+static const MYSTRUCT test_mystruct2 = {0x91827364, ULL_CONST(0x88776655, 0x44332211), {3,6,1,4,0,1,3,0}};
+static const MYSTRUCT test_mystruct3 = {0x1a1b1c1d, ULL_CONST(0x1e1f1011, 0x12131415), {9,2,4,5,6,5,1,3}};
+static const MYSTRUCT test_mystruct4 = {0x2a2b2c2d, ULL_CONST(0x2e2f2021, 0x22232425), {0,4,6,7,3,6,7,4}};
+static const MYSTRUCT test_mystruct5 = {0x3a3b3c3d, ULL_CONST(0x3e3f3031, 0x32333435), {1,6,7,3,8,4,6,5}};
+static const MYSTRUCT test_mystruct6 = {0x4a4b4c4d, ULL_CONST(0x4e4f4041, 0x42434445), {3,6,5,3,4,8,0,9}};
+static const MYSTRUCT test_mystruct7 = {0x5a5b5c5d, ULL_CONST(0x5e5f5051, 0x52535455), {1,8,4,4,4,2,3,1}};
+
+static const struct thin test_thin_struct = {-456, 78};
+
+static const RECT test_rect1 = {1,2,3,4};
+static const RECT test_rect2 = {5,6,7,8};
+static const RECT test_rect3 = {9,10,11,12};
+static const RECT test_rect4 = {13,14,15,16};
+static const RECT test_rect5 = {17,18,19,20};
+static const RECT test_rect6 = {21,22,23,24};
+static const RECT test_rect7 = {25,26,27,28};
+
+static const array_t test_array1 = {1,2,3,4};
+static const array_t test_array2 = {5,6,7,8};
+static const array_t test_array3 = {9,10,11,12};
+static const array_t test_array4 = {13,14,15,16};
+static const array_t test_array5 = {17,18,19,20};
+static const array_t test_array6 = {21,22,23,24};
#define RELEASEMARSHALDATA WM_USER
static ItestDual TestDual = { &TestDualVtbl };
static ItestDual TestDualDisp = { &TestDualVtbl };
+struct disp_obj
+{
+ ISomethingFromDispatch ISomethingFromDispatch_iface;
+ LONG ref;
+};
+
+static inline struct disp_obj *impl_from_ISomethingFromDispatch(ISomethingFromDispatch *iface)
+{
+ return CONTAINING_RECORD(iface, struct disp_obj, ISomethingFromDispatch_iface);
+}
+
+static HRESULT WINAPI disp_obj_QueryInterface(ISomethingFromDispatch *iface, REFIID iid, void **out)
+{
+ if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IDispatch)
+ || IsEqualGUID(iid, &IID_ISomethingFromDispatch))
+ {
+ *out = iface;
+ ISomethingFromDispatch_AddRef(iface);
+ return S_OK;
+ }
+
+ *out = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI disp_obj_AddRef(ISomethingFromDispatch *iface)
+{
+ struct disp_obj *obj = impl_from_ISomethingFromDispatch(iface);
+ return ++obj->ref;
+}
+
+static ULONG WINAPI disp_obj_Release(ISomethingFromDispatch *iface)
+{
+ struct disp_obj *obj = impl_from_ISomethingFromDispatch(iface);
+ LONG ref = --obj->ref;
+ if (!ref)
+ CoTaskMemFree(obj);
+ return ref;
+}
+
+static HRESULT WINAPI disp_obj_GetTypeInfoCount(ISomethingFromDispatch *iface, UINT *count)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI disp_obj_GetTypeInfo(ISomethingFromDispatch *iface,
+ UINT index, LCID lcid, ITypeInfo **typeinfo)
+{
+ ok(index == 0xdeadbeef, "Got unexpected index %#x.\n", index);
+ return 0xbeefdead;
+}
+
+static HRESULT WINAPI disp_obj_GetIDsOfNames(ISomethingFromDispatch *iface,
+ REFIID iid, LPOLESTR *names, UINT count, LCID lcid, DISPID *ids)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI disp_obj_Invoke(ISomethingFromDispatch *iface, DISPID id, REFIID iid, LCID lcid,
+ WORD flags, DISPPARAMS *dispparams, VARIANT *result, EXCEPINFO *excepinfo, UINT *errarg)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI disp_obj_anotherfn(ISomethingFromDispatch *iface)
+{
+ return 0x01234567;
+}
+
+static const ISomethingFromDispatchVtbl disp_obj_vtbl =
+{
+ disp_obj_QueryInterface,
+ disp_obj_AddRef,
+ disp_obj_Release,
+ disp_obj_GetTypeInfoCount,
+ disp_obj_GetTypeInfo,
+ disp_obj_GetIDsOfNames,
+ disp_obj_Invoke,
+ disp_obj_anotherfn,
+};
+
+static ISomethingFromDispatch *create_disp_obj(void)
+{
+ struct disp_obj *obj = CoTaskMemAlloc(sizeof(*obj));
+ obj->ISomethingFromDispatch_iface.lpVtbl = &disp_obj_vtbl;
+ obj->ref = 1;
+ return &obj->ISomethingFromDispatch_iface;
+}
+
+struct coclass_obj
+{
+ ICoclass1 ICoclass1_iface;
+ ICoclass2 ICoclass2_iface;
+ LONG ref;
+};
+
+static inline struct coclass_obj *impl_from_ICoclass1(ICoclass1 *iface)
+{
+ return CONTAINING_RECORD(iface, struct coclass_obj, ICoclass1_iface);
+}
+
+static inline struct coclass_obj *impl_from_ICoclass2(ICoclass2 *iface)
+{
+ return CONTAINING_RECORD(iface, struct coclass_obj, ICoclass2_iface);
+}
+
+static HRESULT WINAPI coclass1_QueryInterface(ICoclass1 *iface, REFIID iid, void **out)
+{
+ struct coclass_obj *obj = impl_from_ICoclass1(iface);
+
+ if (IsEqualGUID(iid, &IID_IUnknown)
+ || IsEqualGUID(iid, &IID_IDispatch)
+ || IsEqualGUID(iid, &IID_ICoclass1))
+ {
+ *out = iface;
+ ICoclass1_AddRef(iface);
+ return S_OK;
+ }
+ else if (IsEqualGUID(iid, &IID_ICoclass2))
+ {
+ *out = &obj->ICoclass2_iface;
+ ICoclass2_AddRef(*out);
+ return S_OK;
+ }
+
+ *out = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI coclass1_AddRef(ICoclass1 *iface)
+{
+ struct coclass_obj *obj = impl_from_ICoclass1(iface);
+ return ++obj->ref;
+}
+
+static ULONG WINAPI coclass1_Release(ICoclass1 *iface)
+{
+ struct coclass_obj *obj = impl_from_ICoclass1(iface);
+ LONG ref = --obj->ref;
+ if (!ref)
+ CoTaskMemFree(obj);
+ return ref;
+}
+
+static HRESULT WINAPI coclass1_GetTypeInfoCount(ICoclass1 *iface, UINT *count)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI coclass1_GetTypeInfo(ICoclass1 *iface, UINT index,
+ LCID lcid, ITypeInfo **typeinfo)
+{
+ ok(index == 0xdeadbeef, "Got unexpected index %#x.\n", index);
+ return 0xbeefdead;
+}
+
+static HRESULT WINAPI coclass1_GetIDsOfNames(ICoclass1 *iface, REFIID iid,
+ LPOLESTR *names, UINT count, LCID lcid, DISPID *ids)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI coclass1_Invoke(ICoclass1 *iface, DISPID id, REFIID iid, LCID lcid,
+ WORD flags, DISPPARAMS *dispparams, VARIANT *result, EXCEPINFO *excepinfo, UINT *errarg)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI coclass1_test(ICoclass1 *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI coclass2_QueryInterface(ICoclass2 *iface, REFIID iid, void **out)
+{
+ struct coclass_obj *obj = impl_from_ICoclass2(iface);
+ return ICoclass1_QueryInterface(&obj->ICoclass1_iface, iid, out);
+}
+
+static ULONG WINAPI coclass2_AddRef(ICoclass2 *iface)
+{
+ struct coclass_obj *obj = impl_from_ICoclass2(iface);
+ return ICoclass1_AddRef(&obj->ICoclass1_iface);
+}
+
+static ULONG WINAPI coclass2_Release(ICoclass2 *iface)
+{
+ struct coclass_obj *obj = impl_from_ICoclass2(iface);
+ return ICoclass1_Release(&obj->ICoclass1_iface);
+}
+
+static HRESULT WINAPI coclass2_GetTypeInfoCount(ICoclass2 *iface, UINT *count)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI coclass2_GetTypeInfo(ICoclass2 *iface, UINT index,
+ LCID lcid, ITypeInfo **typeinfo)
+{
+ ok(index == 0xdeadbeef, "Got unexpected index %#x.\n", index);
+ return 0xbeefdead;
+}
+
+static HRESULT WINAPI coclass2_GetIDsOfNames(ICoclass2 *iface, REFIID iid,
+ LPOLESTR *names, UINT count, LCID lcid, DISPID *ids)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI coclass2_Invoke(ICoclass2 *iface, DISPID id, REFIID iid, LCID lcid,
+ WORD flags, DISPPARAMS *dispparams, VARIANT *result, EXCEPINFO *excepinfo, UINT *errarg)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI coclass2_test(ICoclass2 *iface)
+{
+ return 2;
+}
+
+static const ICoclass1Vtbl coclass1_vtbl =
+{
+ coclass1_QueryInterface,
+ coclass1_AddRef,
+ coclass1_Release,
+ coclass1_GetTypeInfoCount,
+ coclass1_GetTypeInfo,
+ coclass1_GetIDsOfNames,
+ coclass1_Invoke,
+ coclass1_test,
+};
+
+static const ICoclass2Vtbl coclass2_vtbl =
+{
+ coclass2_QueryInterface,
+ coclass2_AddRef,
+ coclass2_Release,
+ coclass2_GetTypeInfoCount,
+ coclass2_GetTypeInfo,
+ coclass2_GetIDsOfNames,
+ coclass2_Invoke,
+ coclass2_test,
+};
+
+static struct coclass_obj *create_coclass_obj(void)
+{
+ struct coclass_obj *obj = CoTaskMemAlloc(sizeof(*obj));
+ obj->ICoclass1_iface.lpVtbl = &coclass1_vtbl;
+ obj->ICoclass2_iface.lpVtbl = &coclass2_vtbl;
+ obj->ref = 1;
+ return obj;
+};
+
+static int testmode;
+
typedef struct Widget
{
IWidget IWidget_iface;
return S_OK;
}
-static HRESULT WINAPI Widget_Array(
- IWidget * iface,
- SAFEARRAY * values)
-{
- trace("Array(%p)\n", values);
- return S_OK;
-}
-
static HRESULT WINAPI Widget_VariantArrayPtr(
IWidget * iface,
SAFEARRAY ** values)
return S_OK;
}
-static HRESULT WINAPI Widget_VariantCArray(
- IWidget * iface,
- ULONG count,
- VARIANT values[])
-{
- ULONG i;
-
- trace("VariantCArray(%u,%p)\n", count, values);
-
- ok(count == 2, "count is %d\n", count);
- for (i = 0; i < count; i++)
- ok(V_VT(&values[i]) == VT_I4, "values[%d] is not VT_I4\n", i);
-
- if (pVarAdd)
- {
- VARIANT inc, res;
- HRESULT hr;
-
- V_VT(&inc) = VT_I4;
- V_I4(&inc) = 1;
- for (i = 0; i < count; i++) {
- VariantInit(&res);
- hr = pVarAdd(&values[i], &inc, &res);
- if (FAILED(hr)) {
- ok(0, "VarAdd failed at %u with error 0x%x\n", i, hr);
- return hr;
- }
- hr = VariantCopy(&values[i], &res);
- if (FAILED(hr)) {
- ok(0, "VariantCopy failed at %u with error 0x%x\n", i, hr);
- return hr;
- }
- }
- }
- else
- win_skip("VarAdd is not available\n");
-
- return S_OK;
-}
-
-static HRESULT WINAPI Widget_Variant(
- IWidget __RPC_FAR * iface,
- VARIANT var)
-{
- trace("Variant()\n");
- ok(V_VT(&var) == VT_CY, "V_VT(&var) was %d\n", V_VT(&var));
- ok(S(V_CY(&var)).Hi == 0xdababe, "V_CY(&var).Hi was 0x%x\n", S(V_CY(&var)).Hi);
- ok(S(V_CY(&var)).Lo == 0xdeadbeef, "V_CY(&var).Lo was 0x%x\n", S(V_CY(&var)).Lo);
- return S_OK;
-}
-
static HRESULT WINAPI Widget_VarArg(
IWidget * iface,
int numexpect,
return S_OK;
}
-
-static BOOL mystruct_uint_ordered(MYSTRUCT *mystruct)
-{
- int i;
- for (i = 0; i < sizeof(mystruct->uarr)/sizeof(mystruct->uarr[0]); i++)
- if (mystruct->uarr[i] != i)
- return FALSE;
- return TRUE;
-}
-
-static HRESULT WINAPI Widget_StructArgs(
- IWidget * iface,
- MYSTRUCT byval,
- MYSTRUCT *byptr,
- MYSTRUCT arr[5])
-{
- int i, diff = 0;
- ok(byval.field1 == MYSTRUCT_BYVAL.field1 &&
- byval.field2 == MYSTRUCT_BYVAL.field2 &&
- mystruct_uint_ordered(&byval),
- "Struct parameter passed by value corrupted\n");
- ok(byptr->field1 == MYSTRUCT_BYPTR.field1 &&
- byptr->field2 == MYSTRUCT_BYPTR.field2 &&
- mystruct_uint_ordered(byptr),
- "Struct parameter passed by pointer corrupted\n");
- for (i = 0; i < 5; i++)
- if (arr[i].field1 != MYSTRUCT_ARRAY[i].field1 ||
- arr[i].field2 != MYSTRUCT_ARRAY[i].field2 ||
- ! mystruct_uint_ordered(&arr[i]))
- diff++;
- ok(diff == 0, "Array of structs corrupted\n");
- return S_OK;
-}
-
-
static HRESULT WINAPI Widget_Error(
IWidget __RPC_FAR * iface)
{
return S_OK;
}
-static HRESULT WINAPI Widget_Coclass(
- IWidget *iface, ApplicationObject2 *param)
+static HRESULT WINAPI Widget_basetypes_in(IWidget *iface, signed char c, short s, int i, hyper h,
+ unsigned char uc, unsigned short us, unsigned int ui, MIDL_uhyper uh,
+ float f, double d, STATE st)
{
- trace("Coclass(%p)\n", param);
- ok(param == (ApplicationObject2 *)iface, "expected param == %p, got %p\n", iface, param);
+ ok(c == 5, "Got char %d.\n", c);
+ ok(s == -123, "Got short %d.\n", s);
+ ok(i == -100000, "Got int %d.\n", i);
+ ok(h == (LONGLONG)-100000 * 1000000, "Got hyper %s.\n", wine_dbgstr_longlong(h));
+ ok(uc == 0, "Got unsigned char %u.\n", uc);
+ ok(us == 456, "Got unsigned short %u.\n", us);
+ ok(ui == 0xdeadbeef, "Got unsigned int %i.\n", ui);
+ ok(uh == (ULONGLONG)1234567890 * 9876543210, "Got unsigned hyper %s.\n", wine_dbgstr_longlong(uh));
+ ok(f == (float)M_PI, "Got float %f.\n", f);
+ ok(d == M_E, "Got double %f.\n", d);
+ ok(st == STATE_WIDGETIFIED, "Got state %u.\n", st);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_basetypes_out(IWidget *iface, signed char *c, short *s, int *i, hyper *h,
+ unsigned char *uc, unsigned short *us, unsigned int *ui, MIDL_uhyper *uh,
+ float *f, double *d, STATE *st)
+{
+ *c = 10;
+ *s = -321;
+ *i = -200000;
+ *h = (LONGLONG)-200000 * 1000000;
+ *uc = 254;
+ *us = 256;
+ *ui = 0xf00dfade;
+ *uh = (((ULONGLONG)0xabcdef01) << 32) | (ULONGLONG)0x23456789;
+ *f = M_LN2;
+ *d = M_LN10;
+ *st = STATE_UNWIDGETIFIED;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_float_abi(IWidget *iface, float f, double d, int i, float f2, double d2)
+{
+ ok(f == 1.0f, "Got float %f.\n", f);
+ ok(d == 2.0, "Got double %f.\n", d);
+ ok(i == 3, "Got int %d.\n", i);
+ ok(f2 == 4.0f, "Got float %f.\n", f2);
+ ok(d2 == 5.0, "Got double %f.\n", d2);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_int_ptr(IWidget *iface, int *in, int *out, int *in_out)
+{
+ ok(*in == 123, "Got [in] %d.\n", *in);
+ if (testmode == 0) /* Invoke() */
+ ok(*out == 456, "Got [out] %d.\n", *out);
+ else if (testmode == 1)
+ ok(!*out, "Got [out] %d.\n", *out);
+ ok(*in_out == 789, "Got [in, out] %d.\n", *in_out);
+
+ *in = 987;
+ *out = 654;
+ *in_out = 321;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_int_ptr_ptr(IWidget *iface, int **in, int **out, int **in_out)
+{
+ ok(!*out, "Got [out] %p.\n", *out);
+ if (testmode == 0)
+ {
+ ok(!*in, "Got [in] %p.\n", *in);
+ ok(!*in_out, "Got [in, out] %p.\n", *in_out);
+ }
+ else if (testmode == 1)
+ {
+ ok(!*in, "Got [in] %p.\n", *in);
+ ok(!*in_out, "Got [in, out] %p.\n", *in_out);
+
+ *out = CoTaskMemAlloc(sizeof(int));
+ **out = 654;
+ *in_out = CoTaskMemAlloc(sizeof(int));
+ **in_out = 321;
+ }
+ else if (testmode == 2)
+ {
+ ok(**in == 123, "Got [in] %d.\n", **in);
+ ok(**in_out == 789, "Got [in, out] %d.\n", **in_out);
+
+ *out = CoTaskMemAlloc(sizeof(int));
+ **out = 654;
+ **in_out = 321;
+ }
+ else if (testmode == 3)
+ {
+ ok(**in_out == 789, "Got [in, out] %d.\n", **in_out);
+ *in_out = NULL;
+ }
+
+ return S_OK;
+}
+
+/* Call methods to check that we have valid proxies to each interface. */
+static void check_iface_marshal(IUnknown *unk, IDispatch *disp, ISomethingFromDispatch *sfd)
+{
+ ISomethingFromDispatch *sfd2;
+ ITypeInfo *typeinfo;
+ HRESULT hr;
+
+ hr = IUnknown_QueryInterface(unk, &IID_ISomethingFromDispatch, (void **)&sfd2);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ISomethingFromDispatch_Release(sfd2);
+
+ hr = IDispatch_GetTypeInfo(disp, 0xdeadbeef, 0, &typeinfo);
+ ok(hr == 0xbeefdead, "Got hr %#x.\n", hr);
+
+ hr = ISomethingFromDispatch_anotherfn(sfd);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+}
+
+static HRESULT WINAPI Widget_iface_in(IWidget *iface, IUnknown *unk, IDispatch *disp, ISomethingFromDispatch *sfd)
+{
+ if (testmode == 0)
+ check_iface_marshal(unk, disp, sfd);
+ else if (testmode == 1)
+ {
+ ok(!unk, "Got iface %p.\n", unk);
+ ok(!disp, "Got iface %p.\n", disp);
+ ok(!sfd, "Got iface %p.\n", sfd);
+ }
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_iface_out(IWidget *iface, IUnknown **unk, IDispatch **disp, ISomethingFromDispatch **sfd)
+{
+ ok(!*unk, "Got iface %p.\n", *unk);
+ ok(!*disp, "Got iface %p.\n", *disp);
+ ok(!*sfd, "Got iface %p.\n", *sfd);
+
+ if (testmode == 0)
+ {
+ *unk = (IUnknown *)create_disp_obj();
+ *disp = (IDispatch *)create_disp_obj();
+ *sfd = create_disp_obj();
+ }
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_iface_ptr(IWidget *iface, ISomethingFromDispatch **in,
+ ISomethingFromDispatch **out, ISomethingFromDispatch **in_out)
+{
+ HRESULT hr;
+
+ ok(!*out, "Got [out] %p.\n", *out);
+ if (testmode == 0 || testmode == 1)
+ {
+ hr = ISomethingFromDispatch_anotherfn(*in);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ hr = ISomethingFromDispatch_anotherfn(*in_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ }
+
+ if (testmode == 1)
+ {
+ *out = create_disp_obj();
+ ISomethingFromDispatch_Release(*in_out);
+ *in_out = create_disp_obj();
+ }
+ else if (testmode == 2)
+ {
+ ok(!*in, "Got [in] %p.\n", *in);
+ ok(!*in_out, "Got [in, out] %p.\n", *in_out);
+ *in_out = create_disp_obj();
+ }
+ else if (testmode == 3)
+ {
+ hr = ISomethingFromDispatch_anotherfn(*in_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ ISomethingFromDispatch_Release(*in_out);
+ *in_out = NULL;
+ }
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_bstr(IWidget *iface, BSTR in, BSTR *out, BSTR *in_ptr, BSTR *in_out)
+{
+ UINT len;
+
+ if (testmode == 0)
+ {
+ len = SysStringByteLen(in);
+ ok(len == sizeof(test_bstr1), "Got wrong length %u.\n", len);
+ ok(!memcmp(in, test_bstr1, len), "Got string %s.\n", wine_dbgstr_wn(in, len / sizeof(WCHAR)));
+ ok(!*out, "Got unexpected output %p.\n", *out);
+ len = SysStringLen(*in_ptr);
+ ok(len == lstrlenW(test_bstr2), "Got wrong length %u.\n", len);
+ ok(!memcmp(*in_ptr, test_bstr2, len), "Got string %s.\n", wine_dbgstr_w(*in_ptr));
+ len = SysStringLen(*in_out);
+ ok(len == lstrlenW(test_bstr3), "Got wrong length %u.\n", len);
+ ok(!memcmp(*in_out, test_bstr3, len), "Got string %s.\n", wine_dbgstr_w(*in_out));
+
+ *out = SysAllocString(test_bstr4);
+ in[1] = (*in_ptr)[1] = (*in_out)[1] = 'X';
+ }
+ else if (testmode == 1)
+ {
+ ok(!in, "Got string %s.\n", wine_dbgstr_w(in));
+ ok(!*out, "Got string %s.\n", wine_dbgstr_w(*out));
+ ok(!*in_ptr, "Got string %s.\n", wine_dbgstr_w(*in_ptr));
+ ok(!*in_out, "Got string %s.\n", wine_dbgstr_w(*in_out));
+ }
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_variant(IWidget *iface, VARIANT in, VARIANT *out, VARIANT *in_ptr, VARIANT *in_out)
+{
+ ok(V_VT(&in) == VT_CY, "Got wrong type %#x.\n", V_VT(&in));
+ ok(V_CY(&in).Hi == 0xdababe && V_CY(&in).Lo == 0xdeadbeef,
+ "Got wrong value %s.\n", wine_dbgstr_longlong(V_CY(&in).int64));
+ if (testmode == 0)
+ {
+ ok(V_VT(out) == VT_I4, "Got wrong type %u.\n", V_VT(out));
+ ok(V_I4(out) == 1, "Got wrong value %d.\n", V_I4(out));
+ }
+ else
+ ok(V_VT(out) == VT_EMPTY, "Got wrong type %u.\n", V_VT(out));
+ ok(V_VT(in_ptr) == VT_I4, "Got wrong type %u.\n", V_VT(in_ptr));
+ ok(V_I4(in_ptr) == -1, "Got wrong value %d.\n", V_I4(in_ptr));
+ ok(V_VT(in_out) == VT_BSTR, "Got wrong type %u.\n", V_VT(in_out));
+ ok(!lstrcmpW(V_BSTR(in_out), test_bstr2), "Got wrong value %s.\n",
+ wine_dbgstr_w(V_BSTR(in_out)));
+
+ V_VT(&in) = VT_I4;
+ V_I4(&in) = 2;
+ V_VT(out) = VT_UI1;
+ V_UI1(out) = 3;
+ V_VT(in_ptr) = VT_I2;
+ V_I2(in_ptr) = 4;
+ VariantClear(in_out);
+ V_VT(in_out) = VT_I1;
+ V_I1(in_out) = 5;
+ return S_OK;
+}
+
+static SAFEARRAY *make_safearray(ULONG len)
+{
+ SAFEARRAY *sa = SafeArrayCreateVector(VT_I4, 0, len);
+ int i, *data;
+
+ SafeArrayAccessData(sa, (void **)&data);
+ for (i = 0; i < len; ++i)
+ data[i] = len + i;
+ SafeArrayUnaccessData(sa);
+
+ return sa;
+}
+
+static void check_safearray(SAFEARRAY *sa, LONG expect)
+{
+ LONG len, i, *data;
+ HRESULT hr;
+
+ hr = SafeArrayGetUBound(sa, 1, &len);
+ len++;
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(len == expect, "Expected len %d, got %d.\n", expect, len);
+
+ hr = SafeArrayAccessData(sa, (void **)&data);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ for (i = 0; i < len; ++i)
+ ok(data[i] == len + i, "Expected data %d at %d, got %d.\n", len + i, i, data[i]);
+
+ SafeArrayUnaccessData(sa);
+}
+
+static HRESULT WINAPI Widget_safearray(IWidget *iface, SAFEARRAY *in, SAFEARRAY **out, SAFEARRAY **in_ptr, SAFEARRAY **in_out)
+{
+ HRESULT hr;
+
+ check_safearray(in, 3);
+ ok(!*out, "Got array %p.\n", *out);
+ check_safearray(*in_ptr, 7);
+ check_safearray(*in_out, 9);
+
+ hr = SafeArrayDestroy(*in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ *out = make_safearray(4);
+ *in_out = make_safearray(6);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_mystruct(IWidget *iface, MYSTRUCT in, MYSTRUCT *out, MYSTRUCT *in_ptr, MYSTRUCT *in_out)
+{
+ static const MYSTRUCT empty = {0};
+ ok(!memcmp(&in, &test_mystruct1, sizeof(in)), "Structs didn't match.\n");
+ ok(!memcmp(out, &empty, sizeof(*out)), "Structs didn't match.\n");
+ ok(!memcmp(in_ptr, &test_mystruct3, sizeof(*in_ptr)), "Structs didn't match.\n");
+ ok(!memcmp(in_out, &test_mystruct4, sizeof(*in_out)), "Structs didn't match.\n");
+
+ memcpy(out, &test_mystruct5, sizeof(*out));
+ memcpy(in_ptr, &test_mystruct6, sizeof(*in_ptr));
+ memcpy(in_out, &test_mystruct7, sizeof(*in_out));
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_mystruct_ptr_ptr(IWidget *iface, MYSTRUCT **in)
+{
+ ok(!memcmp(*in, &test_mystruct1, sizeof(**in)), "Structs didn't match.\n");
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_thin_struct(IWidget *iface, struct thin in)
+{
+ ok(!memcmp(&in, &test_thin_struct, sizeof(in)), "Structs didn't match.\n");
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_rect(IWidget *iface, RECT in, RECT *out, RECT *in_ptr, RECT *in_out)
+{
+ static const RECT empty = {0};
+ ok(EqualRect(&in, &test_rect1), "Rects didn't match.\n");
+ ok(EqualRect(out, &empty), "Rects didn't match.\n");
+ ok(EqualRect(in_ptr, &test_rect3), "Rects didn't match.\n");
+ ok(EqualRect(in_out, &test_rect4), "Rects didn't match.\n");
+
+ *out = test_rect5;
+ *in_ptr = test_rect6;
+ *in_out = test_rect7;
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_array(IWidget *iface, array_t in, array_t out, array_t in_out)
+{
+ static const array_t empty = {0};
+ ok(!memcmp(in, test_array1, sizeof(array_t)), "Arrays didn't match.\n");
+ ok(!memcmp(out, empty, sizeof(array_t)), "Arrays didn't match.\n");
+ ok(!memcmp(in_out, test_array3, sizeof(array_t)), "Arrays didn't match.\n");
+
+ memcpy(in, test_array4, sizeof(array_t));
+ memcpy(out, test_array5, sizeof(array_t));
+ memcpy(in_out, test_array6, sizeof(array_t));
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_variant_array(IWidget *iface, VARIANT in[2], VARIANT out[2], VARIANT in_out[2])
+{
+ ok(V_VT(&in[0]) == VT_I4, "Got wrong type %u.\n", V_VT(&in[0]));
+ ok(V_I4(&in[0]) == 1, "Got wrong value %d.\n", V_I4(&in[0]));
+ ok(V_VT(&in[1]) == VT_I4, "Got wrong type %u.\n", V_VT(&in[1]));
+ ok(V_I4(&in[1]) == 2, "Got wrong value %d.\n", V_I4(&in[1]));
+ ok(V_VT(&out[0]) == VT_EMPTY, "Got wrong type %u.\n", V_VT(&out[0]));
+ ok(V_VT(&out[1]) == VT_EMPTY, "Got wrong type %u.\n", V_VT(&out[1]));
+ ok(V_VT(&in_out[0]) == VT_I4, "Got wrong type %u.\n", V_VT(&in_out[0]));
+ ok(V_I4(&in_out[0]) == 5, "Got wrong type %u.\n", V_VT(&in_out[0]));
+ ok(V_VT(&in_out[1]) == VT_I4, "Got wrong type %u.\n", V_VT(&in_out[1]));
+ ok(V_I4(&in_out[1]) == 6, "Got wrong type %u.\n", V_VT(&in_out[1]));
+
+ V_VT(&in[0]) = VT_I1; V_I1(&in[0]) = 7;
+ V_VT(&in[1]) = VT_I1; V_I1(&in[1]) = 8;
+ V_VT(&out[0]) = VT_I1; V_I1(&out[0]) = 9;
+ V_VT(&out[1]) = VT_I1; V_I1(&out[1]) = 10;
+ V_VT(&in_out[0]) = VT_I1; V_I1(&in_out[0]) = 11;
+ V_VT(&in_out[1]) = VT_I1; V_I1(&in_out[1]) = 12;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_mystruct_array(IWidget *iface, MYSTRUCT in[2])
+{
+ ok(!memcmp(&in[0], &test_mystruct1, sizeof(MYSTRUCT)), "Structs didn't match.\n");
+ ok(!memcmp(&in[1], &test_mystruct2, sizeof(MYSTRUCT)), "Structs didn't match.\n");
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_myint(IWidget *iface, myint_t val, myint_t *ptr, myint_t **ptr_ptr)
+{
+ ok(val == 123, "Got value %d.\n", val);
+ ok(*ptr == 456, "Got single ptr ref %d.\n", *ptr);
+ ok(**ptr_ptr == 789, "Got double ptr ref %d.\n", **ptr_ptr);
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_Coclass(IWidget *iface, Coclass1 *class1, Coclass2 *class2, Coclass3 *class3)
+{
+ HRESULT hr;
+
+ hr = ICoclass1_test((ICoclass1 *)class1);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+
+ hr = ICoclass2_test((ICoclass2 *)class2);
+ ok(hr == 2, "Got hr %#x.\n", hr);
+
+ hr = ICoclass1_test((ICoclass1 *)class3);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+
+ return S_OK;
+}
+
+static HRESULT WINAPI Widget_Coclass_ptr(IWidget *iface, Coclass1 **in, Coclass1 **out, Coclass1 **in_out)
+{
+ struct coclass_obj *obj;
+ HRESULT hr;
+
+ ok(!*out, "Got [out] %p.\n", *out);
+ if (testmode == 0 || testmode == 1)
+ {
+ hr = ICoclass1_test((ICoclass1 *)*in);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ hr = ICoclass1_test((ICoclass1 *)*in_out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ }
+
+ if (testmode == 1)
+ {
+ obj = create_coclass_obj();
+ *out = (Coclass1 *)&obj->ICoclass1_iface;
+
+ ICoclass1_Release((ICoclass1 *)*in_out);
+ obj = create_coclass_obj();
+ *in_out = (Coclass1 *)&obj->ICoclass1_iface;
+ }
+ else if (testmode == 2)
+ {
+ ok(!*in_out, "Got [in, out] %p.\n", *in_out);
+ obj = create_coclass_obj();
+ *in_out = (Coclass1 *)&obj->ICoclass1_iface;
+ }
+ else if (testmode == 3)
+ {
+ hr = ICoclass1_test((ICoclass1 *)*in_out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ ICoclass1_Release((ICoclass1 *)*in_out);
+ *in_out = NULL;
+ }
+
return S_OK;
}
Widget_CloneDispatch,
Widget_CloneCoclass,
Widget_Value,
- Widget_Array,
Widget_VariantArrayPtr,
- Widget_VariantCArray,
- Widget_Variant,
Widget_VarArg,
- Widget_StructArgs,
Widget_Error,
Widget_CloneInterface,
Widget_put_prop_with_lcid,
Widget_neg_restrict,
Widget_VarArg_Run,
Widget_VarArg_Ref_Run,
+ Widget_basetypes_in,
+ Widget_basetypes_out,
+ Widget_float_abi,
+ Widget_int_ptr,
+ Widget_int_ptr_ptr,
+ Widget_iface_in,
+ Widget_iface_out,
+ Widget_iface_ptr,
+ Widget_bstr,
+ Widget_variant,
+ Widget_safearray,
+ Widget_mystruct,
+ Widget_mystruct_ptr_ptr,
+ Widget_thin_struct,
+ Widget_rect,
+ Widget_array,
+ Widget_variant_array,
+ Widget_mystruct_array,
+ Widget_myint,
Widget_Coclass,
+ Widget_Coclass_ptr,
};
static HRESULT WINAPI StaticWidget_QueryInterface(IStaticWidget *iface, REFIID riid, void **ppvObject)
return NULL;
}
+static void test_marshal_basetypes(IWidget *widget, IDispatch *disp)
+{
+ VARIANTARG arg[11];
+ DISPPARAMS dispparams = {arg, NULL, ARRAY_SIZE(arg), 0};
+ HRESULT hr;
+
+ signed char c;
+ short s;
+ int i, i2, *pi;
+ hyper h;
+ unsigned char uc;
+ unsigned short us;
+ unsigned int ui;
+ MIDL_uhyper uh;
+ float f;
+ double d;
+ STATE st;
+
+ V_VT(&arg[10]) = VT_I1; V_I1(&arg[10]) = 5;
+ V_VT(&arg[9]) = VT_I2; V_I2(&arg[9]) = -123;
+ V_VT(&arg[8]) = VT_I4; V_I4(&arg[8]) = -100000;
+ V_VT(&arg[7]) = VT_I8; V_I8(&arg[7]) = (LONGLONG)-100000 * 1000000;
+ V_VT(&arg[6]) = VT_UI1; V_UI1(&arg[6]) = 0;
+ V_VT(&arg[5]) = VT_UI2; V_UI2(&arg[5]) = 456;
+ V_VT(&arg[4]) = VT_UI4; V_UI4(&arg[4]) = 0xdeadbeef;
+ V_VT(&arg[3]) = VT_UI8; V_UI8(&arg[3]) = (ULONGLONG)1234567890 * 9876543210;
+ V_VT(&arg[2]) = VT_R4; V_R4(&arg[2]) = M_PI;
+ V_VT(&arg[1]) = VT_R8; V_R8(&arg[1]) = M_E;
+ V_VT(&arg[0]) = VT_I4; V_I4(&arg[0]) = STATE_WIDGETIFIED;
+ hr = IDispatch_Invoke(disp, DISPID_TM_BASETYPES_IN, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IWidget_basetypes_in(widget, 5, -123, -100000, (LONGLONG)-100000 * 1000000, 0, 456,
+ 0xdeadbeef, (ULONGLONG)1234567890 * 9876543210, M_PI, M_E, STATE_WIDGETIFIED);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ c = s = i = h = uc = us = ui = uh = f = d = st = 0;
+
+ V_VT(&arg[10]) = VT_BYREF|VT_I1; V_I1REF(&arg[10]) = &c;
+ V_VT(&arg[9]) = VT_BYREF|VT_I2; V_I2REF(&arg[9]) = &s;
+ V_VT(&arg[8]) = VT_BYREF|VT_I4; V_I4REF(&arg[8]) = &i;
+ V_VT(&arg[7]) = VT_BYREF|VT_I8; V_I8REF(&arg[7]) = &h;
+ V_VT(&arg[6]) = VT_BYREF|VT_UI1; V_UI1REF(&arg[6]) = &uc;
+ V_VT(&arg[5]) = VT_BYREF|VT_UI2; V_UI2REF(&arg[5]) = &us;
+ V_VT(&arg[4]) = VT_BYREF|VT_UI4; V_UI4REF(&arg[4]) = &ui;
+ V_VT(&arg[3]) = VT_BYREF|VT_UI8; V_UI8REF(&arg[3]) = &uh;
+ V_VT(&arg[2]) = VT_BYREF|VT_R4; V_R4REF(&arg[2]) = &f;
+ V_VT(&arg[1]) = VT_BYREF|VT_R8; V_R8REF(&arg[1]) = &d;
+ V_VT(&arg[0]) = VT_BYREF|VT_I4; V_I4REF(&arg[0]) = (int *)&st;
+ hr = IDispatch_Invoke(disp, DISPID_TM_BASETYPES_OUT, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(c == 10, "Got char %d.\n", c);
+ ok(s == -321, "Got short %d.\n", s);
+ ok(i == -200000, "Got int %d.\n", i);
+ ok(h == (LONGLONG)-200000 * 1000000L, "Got hyper %s.\n", wine_dbgstr_longlong(h));
+ ok(uc == 254, "Got unsigned char %u.\n", uc);
+ ok(us == 256, "Got unsigned short %u.\n", us);
+ ok(ui == 0xf00dfade, "Got unsigned int %i.\n", ui);
+ ok(uh == ((((ULONGLONG)0xabcdef01) << 32) | (ULONGLONG)0x23456789),
+ "Got unsigned hyper %s.\n", wine_dbgstr_longlong(uh));
+ ok(f == (float)M_LN2, "Got float %f.\n", f);
+ ok(d == M_LN10, "Got double %f.\n", d);
+ ok(st == STATE_UNWIDGETIFIED, "Got state %u.\n", st);
+
+ c = s = i = h = uc = us = ui = uh = f = d = st = 0;
+
+ hr = IWidget_basetypes_out(widget, &c, &s, &i, &h, &uc, &us, &ui, &uh, &f, &d, &st);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(c == 10, "Got char %d.\n", c);
+ ok(s == -321, "Got short %d.\n", s);
+ ok(i == -200000, "Got int %d.\n", i);
+ ok(h == (LONGLONG)-200000 * 1000000L, "Got hyper %s.\n", wine_dbgstr_longlong(h));
+ ok(uc == 254, "Got unsigned char %u.\n", uc);
+ ok(us == 256, "Got unsigned short %u.\n", us);
+ ok(ui == 0xf00dfade, "Got unsigned int %i.\n", ui);
+ ok(uh == ((((ULONGLONG)0xabcdef01) << 32) | (ULONGLONG)0x23456789),
+ "Got unsigned hyper %s.\n", wine_dbgstr_longlong(uh));
+ ok(f == (float)M_LN2, "Got float %f.\n", f);
+ ok(d == M_LN10, "Got double %f.\n", d);
+ ok(st == STATE_UNWIDGETIFIED, "Got state %u.\n", st);
+
+ /* Test marshalling of public typedefs. */
+
+ i = 456;
+ i2 = 789;
+ pi = &i2;
+ hr = IWidget_myint(widget, 123, &i, &pi);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ /* Test that different float ABIs are correctly handled. */
+
+ hr = IWidget_float_abi(widget, 1.0f, 2.0, 3, 4.0f, 5.0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+}
+
+static void test_marshal_pointer(IWidget *widget, IDispatch *disp)
+{
+ VARIANTARG arg[3];
+ DISPPARAMS dispparams = {arg, NULL, ARRAY_SIZE(arg), 0};
+ int in, out, in_out, *in_ptr, *out_ptr, *in_out_ptr;
+ HRESULT hr;
+
+ testmode = 0;
+
+ in = 123;
+ out = 456;
+ in_out = 789;
+ V_VT(&arg[2]) = VT_BYREF|VT_I4; V_I4REF(&arg[2]) = ∈
+ V_VT(&arg[1]) = VT_BYREF|VT_I4; V_I4REF(&arg[1]) = &out;
+ V_VT(&arg[0]) = VT_BYREF|VT_I4; V_I4REF(&arg[0]) = &in_out;
+ hr = IDispatch_Invoke(disp, DISPID_TM_INT_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(in == 987, "Got [in] %d.\n", in);
+ ok(out == 654, "Got [out] %d.\n", out);
+ ok(in_out == 321, "Got [in, out] %d.\n", in_out);
+
+ testmode = 1;
+
+ in = 123;
+ out = 456;
+ in_out = 789;
+ hr = IWidget_int_ptr(widget, &in, &out, &in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(in == 123, "Got [in] %d.\n", in);
+ ok(out == 654, "Got [out] %d.\n", out);
+ ok(in_out == 321, "Got [in, out] %d.\n", in_out);
+
+ out = in_out = -1;
+ hr = IWidget_int_ptr(widget, NULL, &out, &in_out);
+ ok(hr == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER), "Got hr %#x.\n", hr);
+ ok(!out, "[out] parameter should have been cleared.\n");
+ ok(in_out == -1, "[in, out] parameter should not have been cleared.\n");
+
+ in = in_out = -1;
+ hr = IWidget_int_ptr(widget, &in, NULL, &in_out);
+ ok(hr == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER), "Got hr %#x.\n", hr);
+ ok(in == -1, "[in] parameter should not have been cleared.\n");
+ ok(in_out == -1, "[in, out] parameter should not have been cleared.\n");
+
+ in = out = -1;
+ hr = IWidget_int_ptr(widget, &in, &out, NULL);
+ ok(hr == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER), "Got hr %#x.\n", hr);
+ ok(in == -1, "[in] parameter should not have been cleared.\n");
+ ok(!out, "[out] parameter should have been cleared.\n");
+
+ /* We can't test Invoke() with double pointers, as it is not possible to fit
+ * more than one level of indirection into a VARIANTARG. */
+
+ testmode = 0;
+ in_ptr = out_ptr = in_out_ptr = NULL;
+ hr = IWidget_int_ptr_ptr(widget, &in_ptr, &out_ptr, &in_out_ptr);
+ ok(hr == S_OK, "Got hr %#x\n", hr);
+ ok(!in_ptr, "Got [in] %p.\n", in_ptr);
+ ok(!out_ptr, "Got [out] %p.\n", out_ptr);
+ ok(!in_out_ptr, "Got [in, out] %p.\n", in_out_ptr);
+
+ testmode = 1;
+ hr = IWidget_int_ptr_ptr(widget, &in_ptr, &out_ptr, &in_out_ptr);
+ ok(hr == S_OK, "Got hr %#x\n", hr);
+ ok(*out_ptr == 654, "Got [out] %d.\n", *out_ptr);
+ ok(*in_out_ptr == 321, "Got [in, out] %d.\n", *in_out_ptr);
+ CoTaskMemFree(out_ptr);
+ CoTaskMemFree(in_out_ptr);
+
+ testmode = 2;
+ in = 123;
+ out = 456;
+ in_out = 789;
+ in_ptr = ∈
+ out_ptr = &out;
+ in_out_ptr = &in_out;
+ hr = IWidget_int_ptr_ptr(widget, &in_ptr, &out_ptr, &in_out_ptr);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(out_ptr != &out, "[out] ptr should have changed.\n");
+ ok(in_out_ptr == &in_out, "[in, out] ptr should not have changed.\n");
+ ok(*out_ptr == 654, "Got [out] %d.\n", *out_ptr);
+ ok(*in_out_ptr == 321, "Got [in, out] %d.\n", *in_out_ptr);
+
+ testmode = 3;
+ in_ptr = out_ptr = NULL;
+ in_out = 789;
+ in_out_ptr = &in_out;
+ hr = IWidget_int_ptr_ptr(widget, &in_ptr, &out_ptr, &in_out_ptr);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!in_out_ptr, "Got [in, out] %p.\n", in_out_ptr);
+
+ out_ptr = &out;
+ in_out_ptr = &in_out;
+ hr = IWidget_int_ptr_ptr(widget, NULL, &out_ptr, &in_out_ptr);
+ ok(hr == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER), "Got hr %#x.\n", hr);
+ ok(!out_ptr, "[out] parameter should have been cleared.\n");
+ ok(in_out_ptr == &in_out, "[in, out] parameter should not have been cleared.\n");
+
+ in_ptr = ∈
+ in_out_ptr = &in_out;
+ hr = IWidget_int_ptr_ptr(widget, &in_ptr, NULL, &in_out_ptr);
+ ok(hr == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER), "Got hr %#x.\n", hr);
+ ok(in_ptr == &in, "[in] parameter should not have been cleared.\n");
+ ok(in_out_ptr == &in_out, "[in, out] parameter should not have been cleared.\n");
+
+ in_ptr = ∈
+ out_ptr = &out;
+ hr = IWidget_int_ptr_ptr(widget, &in_ptr, &out_ptr, NULL);
+ ok(hr == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER), "Got hr %#x.\n", hr);
+ ok(in_ptr == &in, "[in] parameter should not have been cleared.\n");
+ ok(!out_ptr, "[out] parameter should have been cleared.\n");
+}
+
+static void test_marshal_iface(IWidget *widget, IDispatch *disp)
+{
+ VARIANTARG arg[3];
+ DISPPARAMS dispparams = {arg, NULL, ARRAY_SIZE(arg), 0};
+ ISomethingFromDispatch *sfd1, *sfd2, *sfd3, *proxy_sfd, *sfd_in, *sfd_out, *sfd_in_out;
+ IUnknown *proxy_unk, *proxy_unk2, *unk_in, *unk_out, *unk_in_out;
+ IDispatch *proxy_disp;
+ HRESULT hr;
+
+ testmode = 0;
+ sfd1 = create_disp_obj();
+ sfd2 = create_disp_obj();
+ sfd3 = create_disp_obj();
+ hr = IWidget_iface_in(widget, (IUnknown *)sfd1,
+ (IDispatch *)sfd2, sfd3);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ release_iface(sfd1);
+ release_iface(sfd2);
+ release_iface(sfd3);
+
+ testmode = 1;
+ hr = IWidget_iface_in(widget, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ testmode = 0;
+ proxy_unk = (IUnknown *)0xdeadbeef;
+ proxy_disp = (IDispatch *)0xdeadbeef;
+ proxy_sfd = (ISomethingFromDispatch *)0xdeadbeef;
+ hr = IWidget_iface_out(widget, &proxy_unk, &proxy_disp, &proxy_sfd);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ check_iface_marshal(proxy_unk, proxy_disp, proxy_sfd);
+ release_iface(proxy_unk);
+ release_iface(proxy_disp);
+ release_iface(proxy_sfd);
+
+ testmode = 1;
+ hr = IWidget_iface_out(widget, &proxy_unk, &proxy_disp, &proxy_sfd);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!proxy_unk, "Got unexpected proxy %p.\n", proxy_unk);
+ ok(!proxy_disp, "Got unexpected proxy %p.\n", proxy_disp);
+ ok(!proxy_sfd, "Got unexpected proxy %p.\n", proxy_sfd);
+
+ testmode = 0;
+ sfd_in = sfd1 = create_disp_obj();
+ sfd_out = sfd2 = create_disp_obj();
+ sfd_in_out = sfd3 = create_disp_obj();
+ hr = IWidget_iface_ptr(widget, &sfd_in, &sfd_out, &sfd_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(sfd_in == sfd1, "[in] parameter should not have changed.\n");
+ ok(!sfd_out, "[out] parameter should have been cleared.\n");
+ ok(sfd_in_out == sfd3, "[in, out] parameter should not have changed.\n");
+ release_iface(sfd1);
+ release_iface(sfd2);
+ release_iface(sfd3);
+
+ testmode = 1;
+ sfd_in = sfd1 = create_disp_obj();
+ sfd_in_out = sfd3 = create_disp_obj();
+ ISomethingFromDispatch_AddRef(sfd_in_out);
+ hr = IWidget_iface_ptr(widget, &sfd_in, &sfd_out, &sfd_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ISomethingFromDispatch_anotherfn(sfd_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ ok(sfd_in_out != sfd3, "[in, out] parameter should have changed.\n");
+ hr = ISomethingFromDispatch_anotherfn(sfd_in_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ release_iface(sfd_out);
+ release_iface(sfd_in_out);
+ release_iface(sfd1);
+ release_iface(sfd3);
+
+ testmode = 2;
+ sfd_in = sfd_out = sfd_in_out = NULL;
+ hr = IWidget_iface_ptr(widget, &sfd_in, &sfd_out, &sfd_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!sfd_out, "[out] parameter should not have been set.\n");
+ hr = ISomethingFromDispatch_anotherfn(sfd_in_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ release_iface(sfd_in_out);
+
+ testmode = 3;
+ sfd_in = sfd_out = NULL;
+ sfd_in_out = sfd3 = create_disp_obj();
+ ISomethingFromDispatch_AddRef(sfd_in_out);
+ hr = IWidget_iface_ptr(widget, &sfd_in, &sfd_out, &sfd_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!sfd_in_out, "Got [in, out] %p.\n", sfd_in_out);
+ release_iface(sfd3);
+
+ /* Test with Invoke(). Note that since we pass VT_UNKNOWN, we don't get our
+ * interface back, but rather an IUnknown. */
+
+ testmode = 0;
+ sfd1 = create_disp_obj();
+ sfd2 = create_disp_obj();
+ sfd3 = create_disp_obj();
+
+ V_VT(&arg[2]) = VT_UNKNOWN; V_UNKNOWN(&arg[2]) = (IUnknown *)sfd1;
+ V_VT(&arg[1]) = VT_UNKNOWN; V_UNKNOWN(&arg[1]) = (IUnknown *)sfd2;
+ V_VT(&arg[0]) = VT_UNKNOWN; V_UNKNOWN(&arg[0]) = (IUnknown *)sfd3;
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_IN, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ V_VT(&arg[2]) = VT_DISPATCH; V_DISPATCH(&arg[2]) = (IDispatch *)sfd1;
+ V_VT(&arg[1]) = VT_DISPATCH; V_DISPATCH(&arg[1]) = (IDispatch *)sfd2;
+ V_VT(&arg[0]) = VT_DISPATCH; V_DISPATCH(&arg[0]) = (IDispatch *)sfd3;
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_IN, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ release_iface(sfd1);
+ release_iface(sfd2);
+ release_iface(sfd3);
+
+ testmode = 1;
+ V_VT(&arg[2]) = VT_UNKNOWN; V_UNKNOWN(&arg[2]) = NULL;
+ V_VT(&arg[1]) = VT_UNKNOWN; V_UNKNOWN(&arg[1]) = NULL;
+ V_VT(&arg[0]) = VT_UNKNOWN; V_UNKNOWN(&arg[0]) = NULL;
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_IN, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ testmode = 0;
+ proxy_unk = proxy_unk2 = NULL;
+ proxy_disp = NULL;
+ V_VT(&arg[2]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[2]) = &proxy_unk;
+ V_VT(&arg[1]) = VT_DISPATCH|VT_BYREF; V_DISPATCHREF(&arg[1]) = &proxy_disp;
+ V_VT(&arg[0]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[0]) = &proxy_unk2;
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_OUT, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+if (hr == S_OK) {
+ hr = IUnknown_QueryInterface(proxy_unk2, &IID_ISomethingFromDispatch, (void **)&proxy_sfd);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ check_iface_marshal(proxy_unk, proxy_disp, proxy_sfd);
+ ISomethingFromDispatch_Release(proxy_sfd);
+ release_iface(proxy_unk);
+ release_iface(proxy_disp);
+ release_iface(proxy_unk2);
+}
+
+ testmode = 1;
+ proxy_unk = proxy_unk2 = NULL;
+ proxy_disp = NULL;
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_OUT, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!proxy_unk, "Got unexpected proxy %p.\n", proxy_unk);
+ ok(!proxy_disp, "Got unexpected proxy %p.\n", proxy_disp);
+ ok(!proxy_unk2, "Got unexpected proxy %p.\n", proxy_unk2);
+
+ testmode = 0;
+ sfd1 = create_disp_obj();
+ sfd3 = create_disp_obj();
+ unk_in = (IUnknown *)sfd1;
+ unk_out = NULL;
+ unk_in_out = (IUnknown *)sfd3;
+ V_VT(&arg[2]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[2]) = &unk_in;
+ V_VT(&arg[1]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[1]) = &unk_out;
+ V_VT(&arg[0]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[0]) = &unk_in_out;
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(unk_in == (IUnknown *)sfd1, "[in] parameter should not have changed.\n");
+ ok(!unk_out, "[out] parameter should have been cleared.\n");
+ ok(unk_in_out == (IUnknown *)sfd3, "[in, out] parameter should not have changed.\n");
+ release_iface(sfd1);
+ release_iface(sfd3);
+
+ testmode = 1;
+ sfd1 = create_disp_obj();
+ sfd3 = create_disp_obj();
+ unk_in = (IUnknown *)sfd1;
+ unk_out = NULL;
+ unk_in_out = (IUnknown *)sfd3;
+ IUnknown_AddRef(unk_in_out);
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+if (hr == S_OK) {
+ hr = IUnknown_QueryInterface(unk_out, &IID_ISomethingFromDispatch, (void **)&sfd_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ISomethingFromDispatch_anotherfn(sfd_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ ISomethingFromDispatch_Release(sfd_out);
+
+ ok(unk_in_out != (IUnknown *)sfd3, "[in, out] parameter should have changed.\n");
+ hr = IUnknown_QueryInterface(unk_in_out, &IID_ISomethingFromDispatch, (void **)&sfd_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ISomethingFromDispatch_anotherfn(sfd_in_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ ISomethingFromDispatch_Release(sfd_in_out);
+
+ release_iface(unk_out);
+ release_iface(unk_in_out);
+}
+ release_iface(sfd1);
+todo_wine
+ release_iface(sfd3);
+
+ testmode = 2;
+ unk_in = unk_out = unk_in_out = NULL;
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ok(!unk_out, "[out] parameter should not have been set.\n");
+if (hr == S_OK) {
+ hr = IUnknown_QueryInterface(unk_in_out, &IID_ISomethingFromDispatch, (void **)&sfd_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ISomethingFromDispatch_anotherfn(sfd_in_out);
+ ok(hr == 0x01234567, "Got hr %#x.\n", hr);
+ ISomethingFromDispatch_Release(sfd_in_out);
+
+ release_iface(unk_in_out);
+}
+
+ testmode = 3;
+ unk_in = unk_out = NULL;
+ sfd3 = create_disp_obj();
+ unk_in_out = (IUnknown *)sfd3;
+ IUnknown_AddRef(unk_in_out);
+ hr = IDispatch_Invoke(disp, DISPID_TM_IFACE_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine {
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!unk_in_out, "[in, out] parameter should have been cleared.\n");
+ release_iface(sfd3);
+}
+}
+
+static void test_marshal_bstr(IWidget *widget, IDispatch *disp)
+{
+ VARIANTARG arg[4];
+ DISPPARAMS dispparams = {arg, NULL, ARRAY_SIZE(arg), 0};
+ BSTR in, out, in_ptr, in_out;
+ HRESULT hr;
+ UINT len;
+
+ testmode = 0;
+ in = SysAllocStringLen(test_bstr1, ARRAY_SIZE(test_bstr1));
+ out = NULL;
+ in_ptr = SysAllocString(test_bstr2);
+ in_out = SysAllocString(test_bstr3);
+
+ V_VT(&arg[3]) = VT_BSTR; V_BSTR(&arg[3]) = in;
+ V_VT(&arg[2]) = VT_BSTR|VT_BYREF; V_BSTRREF(&arg[2]) = &out;
+ V_VT(&arg[1]) = VT_BSTR|VT_BYREF; V_BSTRREF(&arg[1]) = &in_ptr;
+ V_VT(&arg[0]) = VT_BSTR|VT_BYREF; V_BSTRREF(&arg[0]) = &in_out;
+ hr = IDispatch_Invoke(disp, DISPID_TM_BSTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(in[1] == test_bstr1[1], "[in] parameter should not be changed.\n");
+ ok(in_ptr[1] == 'X', "[in] pointer should be changed.\n");
+ ok(in_out[1] == 'X', "[in, out] parameter should be changed.\n");
+ len = SysStringLen(out);
+ ok(len == lstrlenW(test_bstr4), "Got wrong length %d.\n", len);
+ ok(!memcmp(out, test_bstr4, len), "Got string %s.\n", wine_dbgstr_wn(out, len));
+
+ in[1] = test_bstr1[1];
+ in_ptr[1] = test_bstr2[1];
+ in_out[1] = test_bstr3[1];
+ SysFreeString(out);
+ out = (BSTR)0xdeadbeef;
+ hr = IWidget_bstr(widget, in, &out, &in_ptr, &in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(in[1] == test_bstr1[1], "[in] parameter should not be changed.\n");
+ ok(in_ptr[1] == test_bstr2[1], "[in] pointer should not be changed.\n");
+ ok(in_out[1] == 'X', "[in, out] parameter should be changed.\n");
+ len = SysStringLen(out);
+ ok(len == lstrlenW(test_bstr4), "Got wrong length %d.\n", len);
+ ok(!memcmp(out, test_bstr4, len), "Got string %s.\n", wine_dbgstr_wn(out, len));
+ SysFreeString(in);
+ SysFreeString(out);
+ SysFreeString(in_ptr);
+ SysFreeString(in_out);
+
+ testmode = 1;
+ out = in_ptr = in_out = NULL;
+ hr = IWidget_bstr(widget, NULL, &out, &in_ptr, &in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+}
+
+static void test_marshal_variant(IWidget *widget, IDispatch *disp)
+{
+ VARIANTARG arg[4];
+ DISPPARAMS dispparams = {arg, NULL, ARRAY_SIZE(arg), 0};
+ VARIANT out, in_ptr, in_out;
+ HRESULT hr;
+ BSTR bstr;
+
+ testmode = 0;
+ V_VT(&out) = VT_I4;
+ V_I4(&out) = 1;
+ V_VT(&in_ptr) = VT_I4;
+ V_I4(&in_ptr) = -1;
+ V_VT(&in_out) = VT_BSTR;
+ V_BSTR(&in_out) = bstr = SysAllocString(test_bstr2);
+
+ V_VT(&arg[3]) = VT_CY;
+ V_CY(&arg[3]).Hi = 0xdababe;
+ V_CY(&arg[3]).Lo = 0xdeadbeef;
+ V_VT(&arg[2]) = VT_VARIANT|VT_BYREF; V_VARIANTREF(&arg[2]) = &out;
+ V_VT(&arg[1]) = VT_VARIANT|VT_BYREF; V_VARIANTREF(&arg[1]) = &in_ptr;
+ V_VT(&arg[0]) = VT_VARIANT|VT_BYREF; V_VARIANTREF(&arg[0]) = &in_out;
+ hr = IDispatch_Invoke(disp, DISPID_TM_VARIANT, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(V_VT(&arg[3]) == VT_CY, "Got wrong type %u.\n", V_VT(&arg[3]));
+ ok(V_VT(&out) == VT_UI1, "Got wrong type %u.\n", V_VT(&out));
+ ok(V_UI1(&out) == 3, "Got wrong value %d.\n", V_UI1(&out));
+ VariantClear(&out);
+ ok(V_VT(&in_ptr) == VT_I2, "Got wrong type %u.\n", V_VT(&in_ptr));
+ ok(V_I2(&in_ptr) == 4, "Got wrong value %d.\n", V_I1(&in_ptr));
+ ok(V_VT(&in_out) == VT_I1, "Got wrong type %u.\n", V_VT(&in_out));
+ ok(V_I1(&in_out) == 5, "Got wrong value %d.\n", V_I1(&in_out));
+
+ testmode = 1;
+ V_VT(&out) = VT_I4;
+ V_I4(&out) = 1;
+ V_VT(&in_ptr) = VT_I4;
+ V_I4(&in_ptr) = -1;
+ V_VT(&in_out) = VT_BSTR;
+ V_BSTR(&in_out) = bstr = SysAllocString(test_bstr2);
+ hr = IWidget_variant(widget, arg[3], &out, &in_ptr, &in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(V_VT(&arg[3]) == VT_CY, "Got wrong type %u.\n", V_VT(&arg[3]));
+ ok(V_VT(&out) == VT_UI1, "Got wrong type %u.\n", V_VT(&out));
+ ok(V_UI1(&out) == 3, "Got wrong value %d.\n", V_UI1(&out));
+ ok(V_VT(&in_ptr) == VT_I4, "Got wrong type %u.\n", V_VT(&in_ptr));
+ ok(V_I2(&in_ptr) == -1, "Got wrong value %d.\n", V_I1(&in_ptr));
+ ok(V_VT(&in_out) == VT_I1, "Got wrong type %u.\n", V_VT(&in_out));
+ ok(V_I1(&in_out) == 5, "Got wrong value %d.\n", V_I1(&in_out));
+}
+
+static void test_marshal_safearray(IWidget *widget, IDispatch *disp)
+{
+ SAFEARRAY *in, *out, *out2, *in_ptr, *in_out;
+ HRESULT hr;
+
+ in = make_safearray(3);
+ out = out2 = make_safearray(5);
+ in_ptr = make_safearray(7);
+ in_out = make_safearray(9);
+ hr = IWidget_safearray(widget, in, &out, &in_ptr, &in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ check_safearray(in, 3);
+ check_safearray(out, 4);
+ check_safearray(out2, 5);
+ check_safearray(in_ptr, 7);
+ check_safearray(in_out, 6);
+
+ SafeArrayDestroy(in);
+ SafeArrayDestroy(out);
+ SafeArrayDestroy(out2);
+ SafeArrayDestroy(in_ptr);
+ SafeArrayDestroy(in_out);
+}
+
+static void test_marshal_struct(IWidget *widget, IDispatch *disp)
+{
+ MYSTRUCT out, in_ptr, in_out, *in_ptr_ptr;
+ RECT rect_out, rect_in_ptr, rect_in_out;
+ HRESULT hr;
+
+ memcpy(&out, &test_mystruct2, sizeof(MYSTRUCT));
+ memcpy(&in_ptr, &test_mystruct3, sizeof(MYSTRUCT));
+ memcpy(&in_out, &test_mystruct4, sizeof(MYSTRUCT));
+ hr = IWidget_mystruct(widget, test_mystruct1, &out, &in_ptr, &in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!memcmp(&out, &test_mystruct5, sizeof(MYSTRUCT)), "Structs didn't match.\n");
+ ok(!memcmp(&in_ptr, &test_mystruct3, sizeof(MYSTRUCT)), "Structs didn't match.\n");
+ ok(!memcmp(&in_out, &test_mystruct7, sizeof(MYSTRUCT)), "Structs didn't match.\n");
+
+ memcpy(&in_ptr, &test_mystruct1, sizeof(MYSTRUCT));
+ in_ptr_ptr = &in_ptr;
+ hr = IWidget_mystruct_ptr_ptr(widget, &in_ptr_ptr);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ /* Make sure that "thin" structs (<=8 bytes) are handled correctly in x86-64. */
+
+ hr = IWidget_thin_struct(widget, test_thin_struct);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ /* Make sure we can handle an imported type. */
+
+ rect_out = test_rect2;
+ rect_in_ptr = test_rect3;
+ rect_in_out = test_rect4;
+ hr = IWidget_rect(widget, test_rect1, &rect_out, &rect_in_ptr, &rect_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(EqualRect(&rect_out, &test_rect5), "Rects didn't match.\n");
+ ok(EqualRect(&rect_in_ptr, &test_rect3), "Rects didn't match.\n");
+ ok(EqualRect(&rect_in_out, &test_rect7), "Rects didn't match.\n");
+}
+
+static void test_marshal_array(IWidget *widget, IDispatch *disp)
+{
+ VARIANT var_in[2], var_out[2], var_in_out[2];
+ array_t in, out, in_out;
+ MYSTRUCT struct_in[2];
+ HRESULT hr;
+
+ memcpy(in, test_array1, sizeof(array_t));
+ memcpy(out, test_array2, sizeof(array_t));
+ memcpy(in_out, test_array3, sizeof(array_t));
+ hr = IWidget_array(widget, in, out, in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!memcmp(&in, &test_array1, sizeof(array_t)), "Arrays didn't match.\n");
+ ok(!memcmp(&out, &test_array5, sizeof(array_t)), "Arrays didn't match.\n");
+ ok(!memcmp(&in_out, &test_array6, sizeof(array_t)), "Arrays didn't match.\n");
+
+ V_VT(&var_in[0]) = VT_I4; V_I4(&var_in[0]) = 1;
+ V_VT(&var_in[1]) = VT_I4; V_I4(&var_in[1]) = 2;
+ V_VT(&var_out[0]) = VT_I4; V_I4(&var_out[0]) = 3;
+ V_VT(&var_out[1]) = VT_I4; V_I4(&var_out[1]) = 4;
+ V_VT(&var_in_out[0]) = VT_I4; V_I4(&var_in_out[0]) = 5;
+ V_VT(&var_in_out[1]) = VT_I4; V_I4(&var_in_out[1]) = 6;
+ hr = IWidget_variant_array(widget, var_in, var_out, var_in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(V_VT(&var_in[0]) == VT_I4, "Got wrong type %u.\n", V_VT(&var_in[0]));
+ ok(V_I4(&var_in[0]) == 1, "Got wrong value %d.\n", V_I4(&var_in[0]));
+ ok(V_VT(&var_in[1]) == VT_I4, "Got wrong type %u.\n", V_VT(&var_in[1]));
+ ok(V_I4(&var_in[1]) == 2, "Got wrong value %d.\n", V_I4(&var_in[1]));
+ ok(V_VT(&var_out[0]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_out[0]));
+ ok(V_I1(&var_out[0]) == 9, "Got wrong value %u.\n", V_VT(&var_out[0]));
+ ok(V_VT(&var_out[1]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_out[1]));
+ ok(V_I1(&var_out[1]) == 10, "Got wrong value %u.\n", V_VT(&var_out[1]));
+ ok(V_VT(&var_in_out[0]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_in_out[0]));
+ ok(V_I1(&var_in_out[0]) == 11, "Got wrong value %u.\n", V_VT(&var_in_out[0]));
+ ok(V_VT(&var_in_out[1]) == VT_I1, "Got wrong type %u.\n", V_VT(&var_in_out[1]));
+ ok(V_I1(&var_in_out[1]) == 12, "Got wrong value %u.\n", V_VT(&var_in_out[1]));
+
+ memcpy(&struct_in[0], &test_mystruct1, sizeof(MYSTRUCT));
+ memcpy(&struct_in[1], &test_mystruct2, sizeof(MYSTRUCT));
+ hr = IWidget_mystruct_array(widget, struct_in);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+}
+
+static void test_marshal_coclass(IWidget *widget, IDispatch *disp)
+{
+ VARIANTARG arg[3];
+ DISPPARAMS dispparams = {arg, NULL, ARRAY_SIZE(arg), 0};
+ struct coclass_obj *class1, *class2, *class3;
+ IUnknown *unk_in, *unk_out, *unk_in_out;
+ ICoclass1 *in, *out, *in_out;
+ HRESULT hr;
+
+ class1 = create_coclass_obj();
+ class2 = create_coclass_obj();
+ class3 = create_coclass_obj();
+
+ hr = IWidget_Coclass(widget, (Coclass1 *)&class1->ICoclass1_iface,
+ (Coclass2 *)&class2->ICoclass1_iface, (Coclass3 *)&class3->ICoclass1_iface);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IWidget_Coclass(widget, (Coclass1 *)&class1->ICoclass2_iface,
+ (Coclass2 *)&class2->ICoclass2_iface, (Coclass3 *)&class3->ICoclass2_iface);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ release_iface(&class1->ICoclass1_iface);
+ release_iface(&class2->ICoclass1_iface);
+ release_iface(&class3->ICoclass1_iface);
+
+ testmode = 0;
+ class1 = create_coclass_obj();
+ class2 = create_coclass_obj();
+ class3 = create_coclass_obj();
+ in = &class1->ICoclass1_iface;
+ out = &class2->ICoclass1_iface;
+ in_out = &class3->ICoclass1_iface;
+ hr = IWidget_Coclass_ptr(widget, (Coclass1 **)&in, (Coclass1 **)&out, (Coclass1 **)&in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(in == &class1->ICoclass1_iface, "[in] parameter should not have changed.\n");
+ ok(!out, "[out] parameter should have been cleared.\n");
+ ok(in_out == &class3->ICoclass1_iface, "[in, out] parameter should not have changed.\n");
+ release_iface(&class1->ICoclass1_iface);
+ release_iface(&class2->ICoclass1_iface);
+ release_iface(&class3->ICoclass1_iface);
+
+ testmode = 1;
+ class1 = create_coclass_obj();
+ class3 = create_coclass_obj();
+ in = &class1->ICoclass1_iface;
+ in_out = &class3->ICoclass1_iface;
+ ICoclass1_AddRef(in_out);
+ hr = IWidget_Coclass_ptr(widget, (Coclass1 **)&in,
+ (Coclass1 **)&out, (Coclass1 **)&in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ICoclass1_test(out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ ok(in_out != &class3->ICoclass1_iface, "[in, out] parameter should have changed.\n");
+ hr = ICoclass1_test(in_out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ release_iface(out);
+ release_iface(in_out);
+ release_iface(&class1->ICoclass1_iface);
+ release_iface(&class3->ICoclass1_iface);
+
+ testmode = 2;
+ in = out = in_out = NULL;
+ hr = IWidget_Coclass_ptr(widget, (Coclass1 **)&in,
+ (Coclass1 **)&out, (Coclass1 **)&in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ICoclass1_test(in_out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ release_iface(in_out);
+
+ testmode = 3;
+ in = out = NULL;
+ class3 = create_coclass_obj();
+ in_out = &class3->ICoclass1_iface;
+ hr = IWidget_Coclass_ptr(widget, (Coclass1 **)&in,
+ (Coclass1 **)&out, (Coclass1 **)&in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!in_out, "Got [in, out] %p.\n", in_out);
+
+ /* Test with Invoke(). Note that since we pass VT_UNKNOWN, we don't get our
+ * interface back, but rather an IUnknown. */
+
+ class1 = create_coclass_obj();
+ class2 = create_coclass_obj();
+ class3 = create_coclass_obj();
+
+ V_VT(&arg[2]) = VT_UNKNOWN; V_UNKNOWN(&arg[2]) = (IUnknown *)&class1->ICoclass1_iface;
+ V_VT(&arg[1]) = VT_UNKNOWN; V_UNKNOWN(&arg[1]) = (IUnknown *)&class2->ICoclass1_iface;
+ V_VT(&arg[0]) = VT_UNKNOWN; V_UNKNOWN(&arg[0]) = (IUnknown *)&class3->ICoclass1_iface;
+ hr = IDispatch_Invoke(disp, DISPID_TM_COCLASS, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ V_VT(&arg[2]) = VT_UNKNOWN; V_UNKNOWN(&arg[2]) = (IUnknown *)&class1->ICoclass2_iface;
+ V_VT(&arg[1]) = VT_UNKNOWN; V_UNKNOWN(&arg[1]) = (IUnknown *)&class2->ICoclass2_iface;
+ V_VT(&arg[0]) = VT_UNKNOWN; V_UNKNOWN(&arg[0]) = (IUnknown *)&class3->ICoclass2_iface;
+ hr = IDispatch_Invoke(disp, DISPID_TM_COCLASS, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ V_VT(&arg[2]) = VT_DISPATCH; V_DISPATCH(&arg[2]) = (IDispatch *)&class1->ICoclass1_iface;
+ V_VT(&arg[1]) = VT_DISPATCH; V_DISPATCH(&arg[1]) = (IDispatch *)&class2->ICoclass1_iface;
+ V_VT(&arg[0]) = VT_DISPATCH; V_DISPATCH(&arg[0]) = (IDispatch *)&class3->ICoclass1_iface;
+ hr = IDispatch_Invoke(disp, DISPID_TM_COCLASS, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ release_iface(&class1->ICoclass1_iface);
+ release_iface(&class2->ICoclass1_iface);
+ release_iface(&class3->ICoclass1_iface);
+
+ testmode = 0;
+ class1 = create_coclass_obj();
+ class3 = create_coclass_obj();
+ unk_in = (IUnknown *)&class1->ICoclass1_iface;
+ unk_out = NULL;
+ unk_in_out = (IUnknown *)&class3->ICoclass1_iface;
+ V_VT(&arg[2]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[2]) = &unk_in;
+ V_VT(&arg[1]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[1]) = &unk_out;
+ V_VT(&arg[0]) = VT_UNKNOWN|VT_BYREF; V_UNKNOWNREF(&arg[0]) = &unk_in_out;
+ hr = IDispatch_Invoke(disp, DISPID_TM_COCLASS_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(unk_in == (IUnknown *)&class1->ICoclass1_iface, "[in] parameter should not have changed.\n");
+ ok(!unk_out, "[out] parameter should have been cleared.\n");
+ ok(unk_in_out == (IUnknown *)&class3->ICoclass1_iface, "[in, out] parameter should not have changed.\n");
+ release_iface(&class1->ICoclass1_iface);
+ release_iface(&class3->ICoclass1_iface);
+
+ testmode = 1;
+ class1 = create_coclass_obj();
+ class3 = create_coclass_obj();
+ unk_in = (IUnknown *)&class1->ICoclass1_iface;
+ unk_out = NULL;
+ unk_in_out = (IUnknown *)&class3->ICoclass1_iface;
+ IUnknown_AddRef(unk_in_out);
+ hr = IDispatch_Invoke(disp, DISPID_TM_COCLASS_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+if (hr == S_OK) {
+ hr = IUnknown_QueryInterface(unk_out, &IID_ICoclass1, (void **)&out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ICoclass1_test(out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ ICoclass1_Release(out);
+
+ ok(unk_in_out != (IUnknown *)&class3->ICoclass1_iface, "[in, out] parameter should have changed.\n");
+ hr = IUnknown_QueryInterface(unk_in_out, &IID_ICoclass1, (void **)&in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ICoclass1_test(in_out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ ICoclass1_Release(in_out);
+
+ release_iface(unk_out);
+ release_iface(unk_in_out);
+}
+ release_iface(&class1->ICoclass1_iface);
+todo_wine
+ release_iface(&class3->ICoclass1_iface);
+
+ testmode = 2;
+ unk_in = unk_out = unk_in_out = NULL;
+ hr = IDispatch_Invoke(disp, DISPID_TM_COCLASS_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ok(!unk_out, "[out] parameter should not have been set.\n");
+if (hr == S_OK) {
+ hr = IUnknown_QueryInterface(unk_in_out, &IID_ICoclass1, (void **)&in_out);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = ICoclass1_test(in_out);
+ ok(hr == 1, "Got hr %#x.\n", hr);
+ ICoclass1_Release(in_out);
+
+ release_iface(unk_in_out);
+}
+
+ testmode = 3;
+ unk_in = unk_out = NULL;
+ class3 = create_coclass_obj();
+ unk_in_out = (IUnknown *)&class3->ICoclass1_iface;
+ IUnknown_AddRef(unk_in_out);
+ hr = IDispatch_Invoke(disp, DISPID_TM_COCLASS_PTR, &IID_NULL, LOCALE_NEUTRAL,
+ DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
+todo_wine
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+todo_wine
+ ok(!unk_in_out, "[in, out] parameter should have been cleared.\n");
+
+todo_wine
+ release_iface(&class3->ICoclass1_iface);
+}
+
static void test_typelibmarshal(void)
{
static const WCHAR szCat[] = { 'C','a','t',0 };
DWORD tid;
BSTR bstr;
ITypeInfo *pTypeInfo;
- MYSTRUCT mystruct;
- MYSTRUCT mystructArray[5];
UINT uval;
ok(pKEW != NULL, "Widget creation failed\n");
IStream_Seek(pStream, ullZero, STREAM_SEEK_SET, NULL);
hr = CoUnmarshalInterface(pStream, &IID_IKindaEnumWidget, (void **)&pKEW);
- todo_wine_if(tmarshal_todo)
ok_ole_success(hr, CoUnmarshalInterface);
IStream_Release(pStream);
+ if (FAILED(hr))
+ {
+ end_host_object(tid, thread);
+ return;
+ }
hr = IKindaEnumWidget_Next(pKEW, &pWidget);
ok_ole_success(hr, IKindaEnumWidget_Next);
VariantInit(&varresult);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYPUT, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
- todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
VariantInit(&varresult);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_NAME, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
- todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
ok_ole_success(hr, IDispatch_Invoke);
VariantClear(&varresult);
- /* call StructArgs (direct) */
- mystruct = MYSTRUCT_BYPTR;
- memcpy(mystructArray, MYSTRUCT_ARRAY, sizeof(mystructArray));
- hr = IWidget_StructArgs(pWidget, MYSTRUCT_BYVAL, &mystruct, mystructArray);
- ok_ole_success(hr, IWidget_StructArgs);
-
/* call Clone */
dispparams.cNamedArgs = 0;
dispparams.cArgs = 0;
hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONEDISPATCH, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
- todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_CLONECOCLASS, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
- todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
ok(V_VT(&varresult) == VT_DISPATCH, "V_VT(&varresult) was %d instead of VT_DISPATCH\n", V_VT(&varresult));
ok(V_DISPATCH(&varresult) != NULL, "expected V_DISPATCH(&varresult) != NULL\n");
- /* call Coclass with VT_DISPATCH type */
- vararg[0] = varresult;
- dispparams.cNamedArgs = 0;
- dispparams.rgdispidNamedArgs = NULL;
- dispparams.cArgs = 1;
- dispparams.rgvarg = vararg;
- VariantInit(&varresult);
- hr = IDispatch_Invoke(pDispatch, DISPID_TM_COCLASS, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
- ok_ole_success(hr, IDispatch_Invoke);
- todo_wine_if(tmarshal_todo)
- ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
- "EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
- excepinfo.wCode, excepinfo.scode);
- VariantClear(&varresult);
-
- /* call CoClass (direct) */
- hr = IWidget_Coclass(pWidget, (void *)V_DISPATCH(&vararg[0]));
- ok_ole_success(hr, IWidget_Coclass);
- VariantClear(&vararg[0]);
-
/* call Value with a VT_VARIANT|VT_BYREF type */
V_VT(&vararg[0]) = VT_VARIANT|VT_BYREF;
V_VARIANTREF(&vararg[0]) = &vararg[1];
hr = IDispatch_Invoke(pDispatch, DISPID_VALUE, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult, &excepinfo, NULL);
ok_ole_success(hr, IDispatch_Invoke);
- todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == S_OK,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
ok(V_I2(&varresult) == 1234, "V_I2(&varresult) was %d instead of 1234\n", V_I2(&varresult));
VariantClear(&varresult);
- /* call Variant - exercises variant copying in ITypeInfo::Invoke and
- * handling of void return types */
- /* use a big type to ensure that the variant was properly copied into the
- * destination function's args */
- V_VT(&vararg[0]) = VT_CY;
- S(V_CY(&vararg[0])).Hi = 0xdababe;
- S(V_CY(&vararg[0])).Lo = 0xdeadbeef;
- dispparams.cNamedArgs = 0;
- dispparams.cArgs = 1;
- dispparams.rgdispidNamedArgs = NULL;
- dispparams.rgvarg = vararg;
- VariantInit(&varresult);
- hr = IDispatch_Invoke(pDispatch, DISPID_TM_VARIANT, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
- ok_ole_success(hr, IDispatch_Invoke);
- VariantClear(&varresult);
-
/* call Array with BSTR argument - type mismatch */
VariantInit(&vararg[0]);
V_VT(&vararg[0]) = VT_BSTR;
ok(hr == DISP_E_TYPEMISMATCH || hr == DISP_E_BADVARTYPE, "expected DISP_E_TYPEMISMATCH, got %#x\n", hr);
SysFreeString(V_BSTR(&vararg[0]));
- /* call VariantCArray - test marshaling of variant arrays */
- V_VT(&vararg[0]) = VT_I4;
- V_I4(&vararg[0]) = 1;
- V_VT(&vararg[1]) = VT_I4;
- V_I4(&vararg[1]) = 2;
- hr = IWidget_VariantCArray(pWidget, 2, vararg);
- ok_ole_success(hr, IWidget_VariantCArray);
- todo_wine_if(!tmarshal_todo)
- ok(V_VT(&vararg[0]) == VT_I4 && V_I4(&vararg[0]) == 2, "vararg[0] = %d[%d]\n", V_VT(&vararg[0]), V_I4(&vararg[0]));
- todo_wine_if(!tmarshal_todo)
- ok(V_VT(&vararg[1]) == VT_I4 && V_I4(&vararg[1]) == 3, "vararg[1] = %d[%d]\n", V_VT(&vararg[1]), V_I4(&vararg[1]));
-
/* call VarArg */
VariantInit(&vararg[3]);
V_VT(&vararg[3]) = VT_I4;
VariantInit(&varresult);
hr = IDispatch_Invoke(pDispatch, DISPID_TM_ERROR, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, NULL, &excepinfo, NULL);
ok(hr == DISP_E_EXCEPTION, "IDispatch_Invoke should have returned DISP_E_EXCEPTION instead of 0x%08x\n", hr);
- todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == E_NOTIMPL,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
hr = ITypeInfo_Invoke(pTypeInfo, &NonOleAutomation, DISPID_NOA_ERROR, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
ok(hr == DISP_E_EXCEPTION, "ITypeInfo_Invoke should have returned DISP_E_EXCEPTION instead of 0x%08x\n", hr);
ok(V_VT(&varresult) == VT_EMPTY, "V_VT(&varresult) should be VT_EMPTY instead of %d\n", V_VT(&varresult));
- todo_wine_if(tmarshal_todo)
ok(excepinfo.wCode == 0x0 && excepinfo.scode == E_NOTIMPL,
"EXCEPINFO differs from expected: wCode = 0x%x, scode = 0x%08x\n",
excepinfo.wCode, excepinfo.scode);
ok(V_I4(&varresult) == DISPID_TM_NEG_RESTRICTED, "got %x\n", V_I4(&varresult));
VariantClear(&varresult);
+ test_marshal_basetypes(pWidget, pDispatch);
+ test_marshal_pointer(pWidget, pDispatch);
+ test_marshal_iface(pWidget, pDispatch);
+ test_marshal_bstr(pWidget, pDispatch);
+ test_marshal_variant(pWidget, pDispatch);
+ test_marshal_safearray(pWidget, pDispatch);
+ test_marshal_struct(pWidget, pDispatch);
+ test_marshal_array(pWidget, pDispatch);
+ test_marshal_coclass(pWidget, pDispatch);
+
IDispatch_Release(pDispatch);
IWidget_Release(pWidget);
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoUnmarshalInterface(stream, &IID_ItestDual, (void**)&iface);
- todo_wine_if(tmarshal_todo)
ok(hres == S_OK, "CoUnmarshalInterface failed: %08x\n", hres);
+ if (FAILED(hres))
+ {
+ end_host_object(tid, thread);
+ IStream_Release(stream);
+ return;
+ }
ok(external_connections == 1, "external_connections = %d\n", external_connections);
IStream_Release(stream);
/* Creating a stub for new iface causes new external connection. */
hres = ItestDual_QueryInterface(iface, &IID_ITestSecondDisp, (void**)&second);
- todo_wine_if(tmarshal_todo)
ok(hres == S_OK, "Could not get ITestSecondDisp iface: %08x\n", hres);
todo_wine
ok(external_connections == 2, "external_connections = %d\n", external_connections);
- if (hres == S_OK)
- ITestSecondDisp_Release(second);
+ ITestSecondDisp_Release(second);
todo_wine
ok(external_connections == 2, "external_connections = %d\n", external_connections);
expect_last_release_closes = TRUE;
ItestDual_Release(iface);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
end_host_object(tid, thread);
expect_last_release_closes = FALSE;
hres = CoMarshalInterface(stream, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
expect_last_release_closes = TRUE;
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
/* Two separated marshal data are still one external connection. */
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoMarshalInterface(stream, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
hres = CoMarshalInterface(stream2, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 1, "external_connections = %d\n", external_connections);
expect_last_release_closes = TRUE;
IStream_Seek(stream2, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream2);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
IStream_Release(stream);
hres = CoMarshalInterface(stream, &IID_ItestDual, (IUnknown*)&TestDual, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLEWEAK);
ok(hres == S_OK, "CoMarshalInterface failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoUnmarshalInterface(stream, &IID_ItestDual, (void**)&iface);
ok(hres == S_OK, "CoUnmarshalInterface failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
ItestDual_Release(iface);
IStream_Seek(stream, zero, STREAM_SEEK_SET, NULL);
hres = CoReleaseMarshalData(stream);
ok(hres == S_OK, "CoReleaseMarshalData failed: %08x\n", hres);
- todo_wine_if(tmarshal_todo)
ok(external_connections == 0, "external_connections = %d\n", external_connections);
IStream_Release(stream);
OLECHAR *name = func1;
ifdata.pmethdata = methdata;
- ifdata.cMembers = sizeof(methdata) / sizeof(methdata[0]);
+ ifdata.cMembers = ARRAY_SIZE(methdata);
methdata[0].szName = SysAllocString(func1);
methdata[0].ppdata = parms1;
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
if (!do_typelib_reg_key(&uid, 5, 37, arch, base, FALSE)) return;
if (arch == 64 && !do_typelib_reg_key(&uid, 5, 37, 32, wrongW, FALSE)) return;
- for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(td); i++)
{
ret = QueryPathOfRegTypeLib(&uid, td[i].maj, td[i].min, LOCALE_NEUTRAL, &path);
ok(ret == td[i].ret, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td[i].maj, td[i].min, ret);
FUNCDESC *pFD;
WCHAR path[MAX_PATH];
CHAR pathA[MAX_PATH];
- static const WCHAR tl_path[] = {'.','\\','m','i','d','l','_','t','m','a','r','s','h','a','l','.','t','l','b',0};
-
- BOOL use_midl_tlb = FALSE;
GetModuleFileNameA(NULL, pathA, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
- if(use_midl_tlb)
- memcpy(path, tl_path, sizeof(tl_path));
-
hr = LoadTypeLib(path, &pTL);
if(FAILED(hr)) return;
ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
-if(use_midl_tlb) {
ok(pTA->cFuncs == 6, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
-}
ITypeInfo_ReleaseTypeAttr(pTI, pTA);
-if(use_midl_tlb) {
hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
ok(hr == S_OK, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
ITypeInfo_ReleaseFuncDesc(pTI, pFD);
-}
ITypeInfo_Release(pTI);
hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
ok(hr == S_OK, "hr %08x\n", hr);
- if (hr == S_OK)
- {
- ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
- ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
- if(use_midl_tlb) {
- ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags);
- }
- ok(pTA->cFuncs == 8, "cfuncs %d\n", pTA->cFuncs);
- ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
- ITypeInfo_ReleaseTypeAttr(pTI, pTA);
- }
+ ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
+ ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
+ ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags);
+ ok(pTA->cFuncs == 8, "cfuncs %d\n", pTA->cFuncs);
+ ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
+ ITypeInfo_ReleaseTypeAttr(pTI, pTA);
+
hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
ok(hr == S_OK, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
ITypeInfo_Release(pTI_p);
-if(use_midl_tlb) {
hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
ok(hr == S_OK, "hr %08x\n", hr);
ok(pFD->memid == 0x1234, "memid %08x\n", pFD->memid);
ITypeInfo_ReleaseFuncDesc(pTI, pFD);
-}
ITypeInfo_Release(pTI);
/* ItestIF7 is dual with inherited ifaces which derive from Dispatch */
ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
-if(use_midl_tlb) {
ok(pTA->cFuncs == 3, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
-}
ITypeInfo_ReleaseTypeAttr(pTI, pTA);
-if(use_midl_tlb) {
hr = ITypeInfo_GetRefTypeOfImplType(pTI, -1, &href);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
ok(pFD->memid == 0x60010000, "memid %08x\n", pFD->memid);
ok(pFD->oVft == 2 * sizeof(void *), "oVft %d\n", pFD->oVft);
ITypeInfo_ReleaseFuncDesc(pTI, pFD);
-}
ITypeInfo_Release(pTI);
/* ItestIF11 is a syntax 2 dispinterface which derives from IDispatch */
ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
-if(use_midl_tlb) {
ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
-}
ITypeInfo_ReleaseTypeAttr(pTI, pTA);
-if(use_midl_tlb) {
hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
ok(hr == S_OK, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
ok(hr == S_OK, "hr %08x\n", hr);
if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p);
ITypeInfo_ReleaseFuncDesc(pTI, pFD);
-}
ITypeInfo_Release(pTI);
ok(pTA->typekind == TKIND_INTERFACE, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 6 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == 0, "typeflags %x\n", pTA->wTypeFlags);
-if(use_midl_tlb) {
ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
-}
ITypeInfo_ReleaseTypeAttr(pTI, pTA);
-if(use_midl_tlb) {
/* Should have one method */
hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
ITypeInfo_ReleaseFuncDesc(pTI, pFD);
-}
ITypeInfo_Release(pTI);
ITypeLib_Release(pTL);
SysFreeString(V_BSTR(¶mdescex.varDefaultValue));
WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
- MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, sizeof(nameW)/sizeof(nameW[0]));
+ MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, ARRAY_SIZE(nameW));
hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
ok(hres == S_OK, "got %08x\n", hres);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 0, "got: %u\n", cnames);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 3, "got: %u\n", cnames);
ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
sprintf(buf, "sizeof(union %s)", dump_string(name));
break;
+ case TKIND_ALIAS:
+ sprintf(buf, "sizeof(%s)", dump_string(name));
+ break;
+
case TKIND_ENUM:
+ sprintf(buf, "4");
+ break;
+
+ default:
+ assert(0);
+ return NULL;
+ }
+
+ return buf;
+}
+
+static char *print_align(BSTR name, TYPEATTR *attr)
+{
+ static char buf[256];
+
+ switch (attr->typekind)
+ {
+ case TKIND_DISPATCH:
+ case TKIND_INTERFACE:
+ sprintf(buf, "TYPE_ALIGNMENT(%s*)", dump_string(name));
+ break;
+
+ case TKIND_RECORD:
+ sprintf(buf, "TYPE_ALIGNMENT(struct %s)", dump_string(name));
+ break;
+
+ case TKIND_UNION:
+ sprintf(buf, "TYPE_ALIGNMENT(union %s)", dump_string(name));
+ break;
+
case TKIND_ALIAS:
+ sprintf(buf, "TYPE_ALIGNMENT(%s)", dump_string(name));
+ break;
+
+ case TKIND_ENUM:
sprintf(buf, "4");
break;
printf(" \"%s\",\n", wine_dbgstr_guid(&attr->guid));
- printf(" /*kind*/ %s, /*flags*/ %s, /*align*/ %d, /*size*/ %s,\n"
+ printf(" /*kind*/ %s, /*flags*/ %s, /*align*/ %s, /*size*/ %s,\n"
" /*helpctx*/ 0x%04x, /*version*/ 0x%08x, /*#vtbl*/ %d, /*#func*/ %d",
map_value(attr->typekind, tkind_map), dump_type_flags(attr->wTypeFlags),
- attr->cbAlignment, print_size(name, attr),
+ print_align(name, attr), print_size(name, attr),
help_ctx, MAKELONG(attr->wMinorVerNum, attr->wMajorVerNum),
attr->cbSizeVft/sizeof(void*), attr->cFuncs);
{
"g",
"{b14b6bb5-904e-4ff9-b247-bd361f7a0001}",
- /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct g),
+ /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct g), /*size*/ sizeof(struct g),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"test_iface",
"{b14b6bb5-904e-4ff9-b247-bd361f7a0002}",
- /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(test_iface*),
+ /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(test_iface*), /*size*/ sizeof(test_iface*),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 4, /*#func*/ 1,
{
{
{
"parent_iface",
"{b14b6bb5-904e-4ff9-b247-bd361f7aa001}",
- /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(parent_iface*),
+ /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(parent_iface*), /*size*/ sizeof(parent_iface*),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 4, /*#func*/ 1,
{
{
{
"child_iface",
"{b14b6bb5-904e-4ff9-b247-bd361f7aa002}",
- /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(child_iface*),
+ /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(child_iface*), /*size*/ sizeof(child_iface*),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 5, /*#func*/ 1,
{
{
{
"_n",
"{016fe2ec-b2c8-45f8-b23b-39e53a753903}",
- /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct _n),
+ /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct _n), /*size*/ sizeof(struct _n),
/*helpctx*/ 0x0003, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
},
{
"n",
"{016fe2ec-b2c8-45f8-b23b-39e53a753902}",
- /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(n), /*size*/ sizeof(n),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"nn",
"{00000000-0000-0000-0000-000000000000}",
- /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(nn), /*size*/ sizeof(nn),
/*helpctx*/ 0x0003, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
},
{
"_m",
"{016fe2ec-b2c8-45f8-b23b-39e53a753906}",
- /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct _m),
+ /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct _m), /*size*/ sizeof(struct _m),
/*helpctx*/ 0x0003, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"m",
"{016fe2ec-b2c8-45f8-b23b-39e53a753905}",
- /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(m), /*size*/ sizeof(m),
/*helpctx*/ 0x0000, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
},
{
"mm",
"{00000000-0000-0000-0000-000000000000}",
- /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(mm), /*size*/ sizeof(mm),
/*helpctx*/ 0x0003, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"IDualIface",
"{b14b6bb5-904e-4ff9-b247-bd361f7aaedd}",
- /*kind*/ TKIND_DISPATCH, /*flags*/ TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL, /*align*/ 4, /*size*/ sizeof(IDualIface*),
+ /*kind*/ TKIND_DISPATCH, /*flags*/ TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL, /*align*/ TYPE_ALIGNMENT(IDualIface*), /*size*/ sizeof(IDualIface*),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 7, /*#func*/ 8,
{
{
{
"ISimpleIface",
"{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac009}",
- /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ 4, /*size*/ sizeof(ISimpleIface*),
+ /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ TYPE_ALIGNMENT(ISimpleIface*), /*size*/ sizeof(ISimpleIface*),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 8, /*#func*/ 1,
{
{
{
"test_struct",
"{4029f190-ca4a-4611-aeb9-673983cb96dd}",
- /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct test_struct),
+ /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct test_struct), /*size*/ sizeof(struct test_struct),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"test_struct2",
"{4029f190-ca4a-4611-aeb9-673983cb96de}",
- /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct test_struct2),
+ /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct test_struct2), /*size*/ sizeof(struct test_struct2),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"t_INT",
"{016fe2ec-b2c8-45f8-b23b-39e53a75396a}",
- /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED, /*align*/ TYPE_ALIGNMENT(t_INT), /*size*/ sizeof(t_INT),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"a",
"{00000000-0000-0000-0000-000000000000}",
- /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(a), /*size*/ sizeof(a),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
{
"c",
"{016fe2ec-b2c8-45f8-b23b-39e53a75396b}",
- /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(c), /*size*/ sizeof(c),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
{
"d",
"{016fe2ec-b2c8-45f8-b23b-39e53a75396d}",
- /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(d), /*size*/ sizeof(d),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
{
"e",
"{016fe2ec-b2c8-45f8-b23b-39e53a753970}",
- /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(e), /*size*/ sizeof(e),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"_e",
"{00000000-0000-0000-0000-000000000000}",
- /*kind*/ TKIND_RECORD, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ sizeof(struct _e),
+ /*kind*/ TKIND_RECORD, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(struct _e), /*size*/ sizeof(struct _e),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"ee",
"{016fe2ec-b2c8-45f8-b23b-39e53a753971}",
- /*kind*/ TKIND_RECORD, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ sizeof(struct ee),
+ /*kind*/ TKIND_RECORD, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(struct ee), /*size*/ sizeof(struct ee),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"f",
"{016fe2ec-b2c8-45f8-b23b-39e53a753972}",
- /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ 4,
+ /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(f), /*size*/ sizeof(f),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"_f",
"{00000000-0000-0000-0000-000000000000}",
- /*kind*/ TKIND_UNION, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ sizeof(union _f),
+ /*kind*/ TKIND_UNION, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(union _f), /*size*/ sizeof(union _f),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"ff",
"{016fe2ec-b2c8-45f8-b23b-39e53a753973}",
- /*kind*/ TKIND_UNION, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ sizeof(union ff),
+ /*kind*/ TKIND_UNION, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(union ff), /*size*/ sizeof(union ff),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
},
{
"ITestIface",
"{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac00a}",
- /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ 4, /*size*/ sizeof(ITestIface*),
+ /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ TYPE_ALIGNMENT(ITestIface*), /*size*/ sizeof(ITestIface*),
/*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 13, /*#func*/ 6,
{
{
{
WCHAR wszName[MAX_PATH];
ITypeLib *typelib;
- int ticount = sizeof(info)/sizeof(info[0]);
+ int ticount = ARRAY_SIZE(info);
int iface, func;
MultiByteToWideChar(CP_ACP, 0, name, -1, wszName, MAX_PATH);
ole_check(ITypeInfo_GetTypeAttr(typeinfo, &typeattr));
expect_int(typeattr->typekind, ti->type);
expect_hex(typeattr->wTypeFlags, ti->wTypeFlags);
- /* FIXME: remove once widl is fixed */
- if (typeattr->typekind == TKIND_ALIAS && typeattr->cbAlignment != ti->cbAlignment)
- {
-todo_wine /* widl generates broken typelib and typeattr just reflects that */
- ok(typeattr->cbAlignment == ti->cbAlignment || broken(typeattr->cbAlignment == 1),
- "expected %d, got %d\n", ti->cbAlignment, typeattr->cbAlignment);
-todo_wine /* widl generates broken typelib and typeattr just reflects that */
- ok(typeattr->cbSizeInstance == ti->cbSizeInstance || broken(typeattr->cbSizeInstance == 0),
- "expected %d, got %d\n", ti->cbSizeInstance, typeattr->cbSizeInstance);
- }
- else
- {
expect_int(typeattr->cbAlignment, ti->cbAlignment);
expect_int(typeattr->cbSizeInstance, ti->cbSizeInstance);
- }
expect_int(help_ctx, ti->help_ctx);
expect_int(MAKELONG(typeattr->wMinorVerNum, typeattr->wMajorVerNum), ti->version);
expect_int(typeattr->cbSizeVft, ti->cbSizeVft * sizeof(void*));
HRESULT hr;
GUID guid;
- MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, sizeof(guidW)/sizeof(guidW[0]));
+ MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, ARRAY_SIZE(guidW));
IIDFromString(guidW, &guid);
expect_guid(&guid, &typeattr->guid);
{ TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
{ TKIND_INTERFACE, TYPEFLAG_FOLEAUTOMATION },
{ TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FOLEAUTOMATION },
- { TKIND_DISPATCH, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ },
- { TKIND_DISPATCH, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ },
+ { TKIND_DISPATCH, TYPEFLAG_FDUAL },
+ { TKIND_DISPATCH, TYPEFLAG_FDUAL },
{ TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
{ TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
{ TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
ok(hr == S_OK, "got %08x\n", hr);
ok(dual_attr->typekind == TKIND_INTERFACE, "%d: got kind %d\n", i, dual_attr->typekind);
- ok(dual_attr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FOLEAUTOMATION | TYPEFLAG_FDUAL), "%d: got flags %04x\n", i, dual_attr->wTypeFlags);
+ ok(dual_attr->wTypeFlags == (attrs[i].flags | TYPEFLAG_FOLEAUTOMATION),
+ "%d: got flags %04x\n", i, dual_attr->wTypeFlags);
ITypeInfo_ReleaseTypeAttr(dual_info, dual_attr);
ITypeInfo_Release(dual_info);
}
- StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
+ StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
attr->typekind == TKIND_DISPATCH)
{
- StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
+ StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
WCHAR guidW[40];
REGSAM opposite = side ^ (KEY_WOW64_64KEY | KEY_WOW64_32KEY);
- StringFromGUID2(&interfaceguid, guidW, sizeof(guidW)/sizeof(guidW[0]));
+ StringFromGUID2(&interfaceguid, guidW, ARRAY_SIZE(guidW));
/* Delete the opposite interface key */
lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_READ | opposite, &hkey);