https://git.reactos.org/?p=reactos.git;a=commitdiff;h=357f69997d01bb8c7d26a8...
commit 357f69997d01bb8c7d26a8ab86af9644b0556a3b Author: Amine Khaldi amine.khaldi@reactos.org AuthorDate: Tue Jan 29 13:19:12 2019 +0100 Commit: Amine Khaldi amine.khaldi@reactos.org CommitDate: Tue Jan 29 13:19:12 2019 +0100
[OLEAUT32_WINETEST] Sync with Wine Staging 4.0. CORE-15682 --- modules/rostests/winetests/oleaut32/CMakeLists.txt | 7 +- modules/rostests/winetests/oleaut32/olefont.c | 2 +- modules/rostests/winetests/oleaut32/olepicture.c | 115 +- modules/rostests/winetests/oleaut32/safearray.c | 55 +- modules/rostests/winetests/oleaut32/tmarshal.c | 1832 +++++++++++++++++--- modules/rostests/winetests/oleaut32/tmarshal.idl | 196 ++- modules/rostests/winetests/oleaut32/typelib.c | 180 +- modules/rostests/winetests/oleaut32/usrmarshal.c | 61 +- modules/rostests/winetests/oleaut32/varformat.c | 16 +- modules/rostests/winetests/oleaut32/vartest.c | 66 +- modules/rostests/winetests/oleaut32/vartype.c | 59 +- 11 files changed, 2182 insertions(+), 407 deletions(-)
diff --git a/modules/rostests/winetests/oleaut32/CMakeLists.txt b/modules/rostests/winetests/oleaut32/CMakeLists.txt index bd9c0f47b6..8605c4189d 100644 --- a/modules/rostests/winetests/oleaut32/CMakeLists.txt +++ b/modules/rostests/winetests/oleaut32/CMakeLists.txt @@ -1,5 +1,10 @@
-add_definitions(-DUSE_WINE_TODOS) +add_definitions( + -D__WINESRC__ + -DUSE_WINE_TODOS + -DWINETEST_USE_DBGSTR_LONGLONG + -D_USE_MATH_DEFINES) + include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) add_typelib(test_reg.idl test_tlb.idl tmarshal.idl) add_idl_Headers(oleaut32_idlheaders test_reg.idl test_tlb.idl tmarshal.idl) diff --git a/modules/rostests/winetests/oleaut32/olefont.c b/modules/rostests/winetests/oleaut32/olefont.c index f9c5625701..10e2a4cf2f 100644 --- a/modules/rostests/winetests/oleaut32/olefont.c +++ b/modules/rostests/winetests/oleaut32/olefont.c @@ -420,7 +420,7 @@ static void test_font_events_disp(void) hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp); EXPECT_HR(hr, S_OK);
- for (i = 0; i < sizeof(font_dispids)/sizeof(font_dispids[0]); i++) + for (i = 0; i < ARRAY_SIZE(font_dispids); i++) { switch (font_dispids[i].dispid) { diff --git a/modules/rostests/winetests/oleaut32/olepicture.c b/modules/rostests/winetests/oleaut32/olepicture.c index 80a49d7416..99a39e455d 100644 --- a/modules/rostests/winetests/oleaut32/olepicture.c +++ b/modules/rostests/winetests/oleaut32/olepicture.c @@ -512,7 +512,7 @@ static void test_Invoke(void) /* DISPID_PICT_RENDER */ hdc = create_render_dc();
- for (i = 0; i < sizeof(args)/sizeof(args[0]); i++) + for (i = 0; i < ARRAY_SIZE(args); i++) V_VT(&args[i]) = VT_I4;
V_I4(&args[0]) = 0; @@ -550,12 +550,61 @@ static void test_Invoke(void) IPictureDisp_Release(picdisp); }
+static HRESULT create_picture(short type, IPicture **pict) +{ + PICTDESC desc; + + desc.cbSizeofstruct = sizeof(desc); + desc.picType = type; + + switch (type) + { + case PICTYPE_UNINITIALIZED: + return OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (void **)pict); + + case PICTYPE_NONE: + break; + + case PICTYPE_BITMAP: + desc.bmp.hbitmap = CreateBitmap(1, 1, 1, 1, NULL); + desc.bmp.hpal = (HPALETTE)0xbeefdead; + break; + + case PICTYPE_ICON: + desc.icon.hicon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION); + break; + + case PICTYPE_METAFILE: + { + HDC hdc = CreateMetaFileA(NULL); + desc.wmf.hmeta = CloseMetaFile(hdc); + desc.wmf.xExt = 1; + desc.wmf.yExt = 1; + break; + } + + case PICTYPE_ENHMETAFILE: + { + HDC hdc = CreateEnhMetaFileA(0, NULL, NULL, NULL); + desc.emf.hemf = CloseEnhMetaFile(hdc); + break; + } + + default: + ok(0, "picture type %d is not supported\n", type); + return E_NOTIMPL; + } + + return OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)pict); +} + static void test_OleCreatePictureIndirect(void) { + PICTDESC desc; OLE_HANDLE handle; IPicture *pict; HRESULT hr; - short type; + short type, i;
if (0) { @@ -563,20 +612,52 @@ if (0) OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, NULL); }
- hr = OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (void**)&pict); - ok(hr == S_OK, "hr %08x\n", hr); + desc.cbSizeofstruct = sizeof(desc); + desc.picType = PICTYPE_UNINITIALIZED; + pict = (void *)0xdeadbeef; + hr = OleCreatePictureIndirect(&desc, &IID_IPicture, TRUE, (void **)&pict); + ok(hr == E_UNEXPECTED, "got %#x\n", hr); + ok(pict == NULL, "got %p\n", pict);
- type = PICTYPE_NONE; - hr = IPicture_get_Type(pict, &type); - ok(hr == S_OK, "hr %08x\n", hr); - ok(type == PICTYPE_UNINITIALIZED, "type %d\n", type); + for (i = PICTYPE_UNINITIALIZED; i <= PICTYPE_ENHMETAFILE; i++) + { + hr = create_picture(i, &pict); + ok(hr == S_OK, "%d: got %#x\n", i, hr); + + type = 0xdead; + hr = IPicture_get_Type(pict, &type); + ok(hr == S_OK, "%d: got %#x\n", i, hr); + ok(type == i, "%d: got %d\n", i, type); + + handle = 0xdeadbeef; + hr = IPicture_get_Handle(pict, &handle); + ok(hr == S_OK, "%d: got %#x\n", i, hr); + if (type == PICTYPE_UNINITIALIZED || type == PICTYPE_NONE) + ok(handle == 0, "%d: got %#x\n", i, handle); + else + ok(handle != 0 && handle != 0xdeadbeef, "%d: got %#x\n", i, handle); + + handle = 0xdeadbeef; + hr = IPicture_get_hPal(pict, &handle); + if (type == PICTYPE_BITMAP) + { + ok(hr == S_OK, "%d: got %#x\n", i, hr); + ok(handle == 0xbeefdead, "%d: got %#x\n", i, handle); + } + else + { + ok(hr == E_FAIL, "%d: got %#x\n", i, hr); + ok(handle == 0xdeadbeef || handle == 0 /* win64 */, "%d: got %#x\n", i, handle); + }
- handle = 0xdeadbeef; - hr = IPicture_get_Handle(pict, &handle); - ok(hr == S_OK, "hr %08x\n", hr); - ok(handle == 0, "handle %08x\n", handle); + hr = IPicture_set_hPal(pict, HandleToUlong(GetStockObject(DEFAULT_PALETTE))); + if (type == PICTYPE_BITMAP) + ok(hr == S_OK, "%d: got %#x\n", i, hr); + else + ok(hr == E_FAIL, "%d: got %#x\n", i, hr);
- IPicture_Release(pict); + IPicture_Release(pict); + } }
static void test_apm(void) @@ -690,7 +771,7 @@ static HRESULT picture_render(IPicture *iface, HDC hdc, LONG x, LONG y, LONG cx, IPicture_QueryInterface(iface, &IID_IDispatch, (void**)&disp);
/* This is broken on 64 bits - accepted pointer argument type is still VT_I4 */ - for (i = 0; i < sizeof(args)/sizeof(args[0]); i++) + for (i = 0; i < ARRAY_SIZE(args); i++) V_VT(&args[i]) = VT_I4;
/* pack arguments and call */ @@ -794,7 +875,7 @@ static void test_Render(void) SetPixelV(hdc, 10, 10, 0x00223344); expected = GetPixel(hdc, 0, 0);
- hres = picture_render(pic, hdc, 1, 1, 9, 9, 0, 0, pWidth, -pHeight, NULL); + hres = picture_render(pic, hdc, 1, 1, 9, 9, 0, pHeight, pWidth, -pHeight, NULL); ole_expect(hres, S_OK);
if(hres != S_OK) goto done; @@ -896,7 +977,7 @@ static void test_OleLoadPicturePath(void) {emptyW, &IID_IPicture, NULL}, };
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++) + for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++) { pic = (IPicture *)0xdeadbeef; hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0, @@ -936,7 +1017,7 @@ static void test_OleLoadPicturePath(void) WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL); CloseHandle(file);
- MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, sizeof(temp_fileW)/sizeof(WCHAR) - 8); + MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, ARRAY_SIZE(temp_fileW) - 8);
/* Try a normal DOS path. */ hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic); diff --git a/modules/rostests/winetests/oleaut32/safearray.c b/modules/rostests/winetests/oleaut32/safearray.c index 5ff29b3c3e..9cc3793bc7 100644 --- a/modules/rostests/winetests/oleaut32/safearray.c +++ b/modules/rostests/winetests/oleaut32/safearray.c @@ -567,7 +567,7 @@ static void test_safearray(void) hres = SafeArrayDestroy(a); ok(hres == S_OK,"SAD failed with hres %x\n", hres);
- for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) { + for (i = 0; i < ARRAY_SIZE(vttypes); i++) { if ((i == VT_I8 || i == VT_UI8) && has_i8) { vttypes[i].elemsize = sizeof(LONG64); @@ -704,7 +704,7 @@ static void test_safearray(void) if (!pSafeArrayAllocDescriptorEx) return;
- for (i = 0; i < sizeof(vttypes)/sizeof(vttypes[0]); i++) { + for (i = 0; i < ARRAY_SIZE(vttypes); i++) { a = NULL; hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a); ok(hres == S_OK, "SafeArrayAllocDescriptorEx gave hres 0x%x\n", hres); @@ -765,7 +765,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void) { SAFEARRAY *sa; HRESULT hres; - int i; + UINT i;
/* Failure cases */ hres = SafeArrayAllocDescriptor(0, &sa); @@ -789,7 +789,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
if (hres == S_OK) { - ok(SafeArrayGetDim(sa) == (UINT)i, "Dimension is %d; should be %d\n", + ok(SafeArrayGetDim(sa) == i, "Dimension is %d; should be %d\n", SafeArrayGetDim(sa), i);
hres = SafeArrayDestroyDescriptor(sa); @@ -828,11 +828,9 @@ static void test_SafeArrayCreateLockDestroy(void) SAFEARRAY *sa; HRESULT hres; VARTYPE vt; - int dimension; - -#define NUM_DIMENSIONS (int)(sizeof(sab) / sizeof(sab[0])) + UINT dimension;
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) + for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++) { sab[dimension].lLbound = 0; sab[dimension].cElements = 8; @@ -850,7 +848,7 @@ static void test_SafeArrayCreateLockDestroy(void)
/* Don't test 0 sized dimensions, as Windows has a bug which allows this */
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) + for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++) sab[dimension].cElements = 8;
/* Test all VARTYPES in 1-4 dimensions */ @@ -870,7 +868,7 @@ static void test_SafeArrayCreateLockDestroy(void)
if (sa) { - ok(SafeArrayGetDim(sa) == (UINT)dimension, + ok(SafeArrayGetDim(sa) == dimension, "VARTYPE %d (@%d dimensions) cDims is %d, expected %d\n", vt, dimension, SafeArrayGetDim(sa), dimension); ok(SafeArrayGetElemsize(sa) == dwLen || vt == VT_R8, @@ -1007,13 +1005,13 @@ static void test_LockUnlock(void) hres = SafeArrayUnlock(NULL); ok(hres == E_INVALIDARG, "Lock NULL array hres 0x%x\n", hres);
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) + for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++) { sab[dimension].lLbound = 0; sab[dimension].cElements = 8; }
- sa = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab); + sa = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
/* Test maximum locks */ test_LockUnlock_Vector: @@ -1054,27 +1052,27 @@ test_LockUnlock_Vector: static void test_SafeArrayGetPutElement(void) { SAFEARRAYBOUND sab[4]; - LONG indices[NUM_DIMENSIONS], index; + LONG indices[ARRAY_SIZE(sab)], index; SAFEARRAY *sa; HRESULT hres; int value = 0, gotvalue, dimension; IRecordInfoImpl *irec; unsigned int x,y,z,a;
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) + for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++) { sab[dimension].lLbound = dimension * 2 + 1; sab[dimension].cElements = dimension * 3 + 1; }
- sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab); + sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab); if (!sa) return; /* Some early versions can't handle > 3 dims */
ok(sa->cbElements == sizeof(value), "int size mismatch\n");
/* Failure cases */ - for (x = 0; x < NUM_DIMENSIONS; x++) + for (x = 0; x < ARRAY_SIZE(sab); x++) { indices[0] = sab[0].lLbound; indices[1] = sab[1].lLbound; @@ -1384,16 +1382,16 @@ static void test_SafeArrayCopyData(void) return; }
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) + for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++) { sab[dimension].lLbound = dimension * 2 + 2; sab[dimension].cElements = dimension * 3 + 1; size *= sab[dimension].cElements; }
- sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab); + sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab); ok(sa != NULL, "Copy test couldn't create array\n"); - sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab); + sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab); ok(sacopy != NULL, "Copy test couldn't create copy array\n");
if (!sa || !sacopy) @@ -1453,11 +1451,11 @@ static void test_SafeArrayCopyData(void) hres = SafeArrayDestroy(sacopy); ok(hres == S_OK, "got 0x%08x\n", hres);
- sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab); + sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab); ok(sacopy != NULL, "Copy test couldn't create copy array\n"); ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
- for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++) + for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++) { USHORT feature = ignored_copy_features[i]; USHORT orig = sacopy->fFeatures; @@ -1491,7 +1489,7 @@ static void test_SafeArrayCopyData(void) "got 0x%04x\n", sacopy->fFeatures); SafeArrayDestroy(sacopy);
- sacopy = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab); + sacopy = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab); ok(sacopy != NULL, "Copy test couldn't create copy array\n"); ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures); hres = SafeArrayCopyData(sa, sacopy); @@ -1507,7 +1505,7 @@ static void test_SafeArrayCreateEx(void) SAFEARRAYBOUND sab[4]; SAFEARRAY *sa; HRESULT hres; - int dimension; + UINT dimension;
if (!pSafeArrayCreateEx) { @@ -1515,7 +1513,7 @@ static void test_SafeArrayCreateEx(void) return; }
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) + for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++) { sab[dimension].lLbound = 0; sab[dimension].cElements = 8; @@ -1765,7 +1763,7 @@ static void test_SafeArrayCopy(void) ok(sa->fFeatures == 0, "got src features 0x%04x\n", sa->fFeatures); sa->cbElements = 16;
- for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++) + for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++) { USHORT feature = ignored_copy_features[i];
@@ -2020,9 +2018,10 @@ static void test_SafeArrayDestroyData (void) ok(hres == S_OK, "got 0x%08x\n", hres); todo_wine ok(sa->fFeatures == FADF_HAVEVARTYPE, "got 0x%x\n", sa->fFeatures); - ok(sa->pvData != NULL, "got %p\n", sa->pvData); - /* There seems to be a bug on windows, especially visible on 64bit systems, - probably double-free of similar issue. */ +todo_wine + ok(sa->pvData == NULL || broken(sa->pvData != NULL), "got %p\n", sa->pvData); + /* There was a bug on windows, especially visible on 64bit systems, + probably double-free or similar issue. */ sa->pvData = NULL; SafeArrayDestroy(sa); } diff --git a/modules/rostests/winetests/oleaut32/tmarshal.c b/modules/rostests/winetests/oleaut32/tmarshal.c index 4bd172e796..4b03d5a890 100644 --- a/modules/rostests/winetests/oleaut32/tmarshal.c +++ b/modules/rostests/winetests/oleaut32/tmarshal.c @@ -17,6 +17,8 @@ * */
+#include <math.h> + #define COBJMACROS #define CONST_VTABLE
@@ -27,32 +29,51 @@ #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
@@ -375,6 +396,270 @@ static ItestDualVtbl TestDualVtbl = { 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; @@ -620,14 +905,6 @@ static HRESULT WINAPI Widget_Value( 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) @@ -636,57 +913,6 @@ static HRESULT WINAPI Widget_VariantArrayPtr( 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, @@ -721,41 +947,6 @@ static HRESULT WINAPI Widget_VarArg( 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) { @@ -915,11 +1106,445 @@ static HRESULT WINAPI Widget_VarArg_Ref_Run( 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; }
@@ -944,12 +1569,8 @@ static const struct IWidgetVtbl Widget_VTable = 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, @@ -963,7 +1584,27 @@ static const struct IWidgetVtbl Widget_VTable = 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) @@ -1277,6 +1918,859 @@ static ITypeInfo *NonOleAutomation_GetTypeInfo(void) 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 }; @@ -1298,8 +2792,6 @@ static void test_typelibmarshal(void) DWORD tid; BSTR bstr; ITypeInfo *pTypeInfo; - MYSTRUCT mystruct; - MYSTRUCT mystructArray[5]; UINT uval;
ok(pKEW != NULL, "Widget creation failed\n"); @@ -1311,9 +2803,13 @@ static void test_typelibmarshal(void)
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); @@ -1338,7 +2834,6 @@ static void test_typelibmarshal(void) 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); @@ -1358,7 +2853,6 @@ static void test_typelibmarshal(void) 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); @@ -1488,12 +2982,6 @@ static void test_typelibmarshal(void) 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; @@ -1527,7 +3015,6 @@ static void test_typelibmarshal(void) 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); @@ -1545,7 +3032,6 @@ static void test_typelibmarshal(void) 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); @@ -1553,26 +3039,6 @@ static void test_typelibmarshal(void) 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]; @@ -1586,7 +3052,6 @@ static void test_typelibmarshal(void) 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); @@ -1595,22 +3060,6 @@ static void test_typelibmarshal(void) 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; @@ -1635,18 +3084,6 @@ static void test_typelibmarshal(void) 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; @@ -1715,7 +3152,6 @@ static void test_typelibmarshal(void) 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); @@ -1742,7 +3178,6 @@ static void test_typelibmarshal(void) 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); @@ -1928,6 +3363,16 @@ static void test_typelibmarshal(void) 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);
@@ -2054,8 +3499,13 @@ static void test_external_connection(void)
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); @@ -2063,19 +3513,16 @@ static void test_external_connection(void)
/* 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); @@ -2087,14 +3534,12 @@ static void test_external_connection(void) 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. */ @@ -2105,25 +3550,21 @@ static void test_external_connection(void) 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); @@ -2135,20 +3576,17 @@ static void test_external_connection(void)
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); diff --git a/modules/rostests/winetests/oleaut32/tmarshal.idl b/modules/rostests/winetests/oleaut32/tmarshal.idl index 12c0bd5b5c..cdc7dc14d3 100644 --- a/modules/rostests/winetests/oleaut32/tmarshal.idl +++ b/modules/rostests/winetests/oleaut32/tmarshal.idl @@ -20,9 +20,67 @@ #pragma makedep ident #pragma makedep typelib
-#include "tmarshal_dispids.h" import "ocidl.idl";
+enum IWidget_dispids +{ + DISPID_TM_NAME = 1, + DISPID_TM_DOSOMETHING, + DISPID_TM_STATE, + DISPID_TM_MAP, + DISPID_TM_SETOLECOLOR, + DISPID_TM_GETOLECOLOR, + DISPID_TM_CLONE, + DISPID_TM_CLONEDISPATCH, + DISPID_TM_CLONECOCLASS, + DISPID_TM_VALUE, + DISPID_TM_VARARRAYPTR, + DISPID_TM_VARARG, + DISPID_TM_ERROR, + DISPID_TM_CLONEINTERFACE, + DISPID_TM_TESTDUAL, + DISPID_TM_PROP_WITH_LCID, + DISPID_TM_PROP_INT, + DISPID_TM_PROP_UINT, + DISPID_TM_BYREF_UINT, + DISPID_TM_PROP_OPT_ARG, + DISPID_TM_PROP_REQ_ARG, + DISPID_TM_RESTRICTED, + DISPID_TM_TESTSECONDIFACE, + DISPID_TM_VARARG_RUN, + DISPID_TM_VARARG_REF_RUN, + + DISPID_TM_BASETYPES_IN, + DISPID_TM_BASETYPES_OUT, + DISPID_TM_FLOAT_ABI, + DISPID_TM_INT_PTR, + DISPID_TM_INT_PTR_PTR, + DISPID_TM_IFACE_IN, + DISPID_TM_IFACE_OUT, + DISPID_TM_IFACE_PTR, + DISPID_TM_BSTR, + DISPID_TM_VARIANT, + DISPID_TM_SAFEARRAY, + DISPID_TM_STRUCT, + DISPID_TM_STRUCT_PTR_PTR, + DISPID_TM_THIN_STRUCT, + DISPID_TM_RECT, + DISPID_TM_ARRAY, + DISPID_TM_VARIANT_ARRAY, + DISPID_TM_STRUCT_ARRAY, + DISPID_TM_TYPEDEF, + DISPID_TM_COCLASS, + DISPID_TM_COCLASS_PTR, +}; + +static const int DISPID_TM_NEG_RESTRICTED = -26; + +enum INonOleAutomation_dispids +{ + DISPID_NOA_BSTRRET = 1, + DISPID_NOA_ERROR +}; + [ uuid(d96d8a3e-78b6-4c8d-8f27-059db959be8a), version(2.5), @@ -45,10 +103,13 @@ library TestTypelib UINT uarr[8]; } MYSTRUCT;
+ typedef [public] int myint_t; + coclass ApplicationObject2;
[ odl, + oleautomation, uuid(12345678-1234-4321-1234-121212121212) ] interface ISomethingFromDispatch : IDispatch @@ -87,6 +148,51 @@ library TestTypelib HRESULT test(); }
+ [ + oleautomation, + uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796a) + ] + interface ICoclass1 : IDispatch + { + HRESULT test(); + } + + [ + oleautomation, + uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796b) + ] + interface ICoclass2 : IDispatch + { + HRESULT test(); + } + + [ + uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796c) + ] + coclass Coclass1 + { + [default] interface ICoclass1; + interface ICoclass2; + } + + [ + uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796d) + ] + coclass Coclass2 + { + interface ICoclass1; + [default] interface ICoclass2; + } + + [ + uuid(3f7e06fe-0bce-46f0-8b7d-3a68393c796e) + ] + coclass Coclass3 + { + interface ICoclass1; + interface ICoclass2; + } + [ odl, uuid(a1f8cae3-c947-4c5f-b57d-c87b9b5f3586), @@ -129,24 +235,12 @@ library TestTypelib [propget, id(DISPID_VALUE)] HRESULT Value([in] VARIANT *value, [out, retval] VARIANT *retval);
- [id(DISPID_TM_ARRAY)] - HRESULT Array([in] SAFEARRAY(BSTR) values); - [id(DISPID_TM_VARARRAYPTR)] HRESULT VariantArrayPtr([in] SAFEARRAY(VARIANT) *values);
- [id(DISPID_TM_VARCARRAY)] - HRESULT VariantCArray([in] ULONG count, [in, out] VARIANT values[2]); - - [id(DISPID_TM_VARIANT)] - HRESULT Variant([in] VARIANT var); - [vararg, id(DISPID_TM_VARARG)] HRESULT VarArg([in] int numexpect, [in] SAFEARRAY(VARIANT) values);
- [id(DISPID_TM_STRUCTARGS)] - HRESULT StructArgs([in] MYSTRUCT byval, [in] MYSTRUCT *byptr, [in] MYSTRUCT arr[5]); - [id(DISPID_TM_ERROR)] HRESULT Error();
@@ -186,8 +280,80 @@ library TestTypelib [id(DISPID_TM_VARARG_REF_RUN), vararg] HRESULT VarArg_Ref_Run([in] BSTR name, [in] SAFEARRAY(VARIANT) *params, [out, retval] VARIANT *result);
+ [id(DISPID_TM_BASETYPES_IN)] + HRESULT basetypes_in([in] signed char c, [in] short s, [in] int i, [in] hyper h, + [in] unsigned char uc, [in] unsigned short us, [in] unsigned int ui, + [in] unsigned hyper uh, [in] float f, [in] double d, [in] STATE st); + + [id(DISPID_TM_BASETYPES_OUT)] + HRESULT basetypes_out([out] signed char *c, [out] short *s, [out] int *i, [out] hyper *h, + [out] unsigned char *uc, [out] unsigned short *us, [out] unsigned int *ui, + [out] unsigned hyper *uh, [out] float *f, [out] double *d, [out] STATE *st); + + [id(DISPID_TM_FLOAT_ABI)] + HRESULT float_abi([in] float f, [in] double d, [in] int i, [in] float f2, [in] double d2); + + [id(DISPID_TM_INT_PTR)] + HRESULT int_ptr([in] int *in, [out] int *out, [in, out] int *in_out); + + [id(DISPID_TM_INT_PTR_PTR)] + HRESULT int_ptr_ptr([in] int **in, [out] int **out, [in, out] int **in_out); + + [id(DISPID_TM_IFACE_IN)] + HRESULT iface_in([in] IUnknown *unk, [in] IDispatch *disp, [in] ISomethingFromDispatch *sfd); + + [id(DISPID_TM_IFACE_OUT)] + HRESULT iface_out([out] IUnknown **unk, [out] IDispatch **disp, [out] ISomethingFromDispatch **sfd); + + [id(DISPID_TM_IFACE_PTR)] + HRESULT iface_ptr([in] ISomethingFromDispatch **in, [out] ISomethingFromDispatch **out, [in, out] ISomethingFromDispatch **in_out); + + [id(DISPID_TM_BSTR)] + HRESULT bstr([in] BSTR in, [out] BSTR *out, [in] BSTR *in_ptr, [in, out] BSTR *in_out); + + [id(DISPID_TM_VARIANT)] + HRESULT variant([in] VARIANT in, [out] VARIANT *out, [in] VARIANT *in_ptr, [in, out] VARIANT *in_out); + + [id(DISPID_TM_SAFEARRAY)] + HRESULT safearray([in] SAFEARRAY(int) in, [out] SAFEARRAY(int) *out, [in] SAFEARRAY(int) *in_ptr, [in, out] SAFEARRAY(int) *in_out); + + [id(DISPID_TM_STRUCT)] + HRESULT mystruct([in] MYSTRUCT in, [out] MYSTRUCT *out, [in] MYSTRUCT *in_ptr, [in, out] MYSTRUCT *in_out); + + [id(DISPID_TM_STRUCT_PTR_PTR)] + HRESULT mystruct_ptr_ptr([in] MYSTRUCT **in); + + struct thin + { + short a; + char b; + }; + + [id(DISPID_TM_THIN_STRUCT)] + HRESULT thin_struct([in] struct thin in); + + [id(DISPID_TM_RECT)] + HRESULT rect([in] RECT in, [out] RECT *out, [in] RECT *in_ptr, [in, out] RECT *in_out); + + typedef int array_t[4]; + + [id(DISPID_TM_ARRAY)] + HRESULT array([in] array_t in, [out] array_t out, [in, out] array_t in_out); + + [id(DISPID_TM_VARIANT_ARRAY)] + HRESULT variant_array([in] VARIANT in[2], [out] VARIANT out[2], [in, out] VARIANT in_out[2]); + + [id(DISPID_TM_STRUCT_ARRAY)] + HRESULT mystruct_array([in] MYSTRUCT in[2]); + + [id(DISPID_TM_TYPEDEF)] + HRESULT myint([in] myint_t val, [in] myint_t *ptr, [in] myint_t **ptr_ptr); + [id(DISPID_TM_COCLASS)] - HRESULT Coclass([in] ApplicationObject2 *param); + HRESULT Coclass([in] Coclass1 *class1, [in] Coclass2 *class2, [in] Coclass3 *class3); + + [id(DISPID_TM_COCLASS_PTR)] + HRESULT Coclass_ptr([in] Coclass1 **in, [out] Coclass1 **out, [in, out] Coclass1 **in_out); }
[ @@ -208,9 +374,7 @@ library TestTypelib [ odl, uuid(a028db05-30f0-4b93-b17a-41c72f831d84), -#if 0 /* FIXME: commented out as causes widl to generate incorrect typelib */ dual, -#endif oleautomation ] interface IKindaEnumWidget : IUnknown diff --git a/modules/rostests/winetests/oleaut32/typelib.c b/modules/rostests/winetests/oleaut32/typelib.c index 354b4b017c..90f0cb256e 100644 --- a/modules/rostests/winetests/oleaut32/typelib.c +++ b/modules/rostests/winetests/oleaut32/typelib.c @@ -627,7 +627,7 @@ static void test_CreateDispTypeInfo(void) 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; @@ -1405,7 +1405,7 @@ static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM view) 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)))) @@ -1538,7 +1538,7 @@ static void test_QueryPathOfRegTypeLib(DWORD arch) 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); @@ -1562,16 +1562,10 @@ static void test_inheritance(void) 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;
@@ -1585,13 +1579,10 @@ static void test_inheritance(void) 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); @@ -1610,7 +1601,6 @@ if(use_midl_tlb) { 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);
@@ -1651,17 +1641,13 @@ if(use_midl_tlb) {
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); @@ -1671,12 +1657,10 @@ if(use_midl_tlb) { 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 */ @@ -1717,13 +1701,10 @@ if(use_midl_tlb) { 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); @@ -1744,7 +1725,6 @@ if(use_midl_tlb) { 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 */ @@ -1756,13 +1736,10 @@ if(use_midl_tlb) { 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); @@ -1791,7 +1768,6 @@ if(use_midl_tlb) { ok(hr == S_OK, "hr %08x\n", hr); if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p); ITypeInfo_ReleaseFuncDesc(pTI, pFD); -} ITypeInfo_Release(pTI);
@@ -1804,13 +1780,10 @@ if(use_midl_tlb) { 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); @@ -1819,7 +1792,6 @@ if(use_midl_tlb) { 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); @@ -2392,7 +2364,7 @@ static void test_CreateTypeLib(SYSKIND sys) { 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); @@ -3124,7 +3096,7 @@ static void test_CreateTypeLib(SYSKIND sys) { 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])); @@ -3228,7 +3200,7 @@ static void test_CreateTypeLib(SYSKIND sys) { 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])); @@ -3458,7 +3430,7 @@ static void test_CreateTypeLib(SYSKIND sys) { 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])); @@ -3557,7 +3529,7 @@ static void test_CreateTypeLib(SYSKIND sys) { 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])); @@ -4034,8 +4006,46 @@ static char *print_size(BSTR name, TYPEATTR *attr) 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;
@@ -4155,10 +4165,10 @@ static void test_dump_typelib(const char *name)
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);
@@ -4258,13 +4268,13 @@ static const type_info info[] = { { "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, { { @@ -4286,7 +4296,7 @@ static const type_info info[] = { { "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, { { @@ -4308,7 +4318,7 @@ static const type_info info[] = { { "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, { { @@ -4328,43 +4338,43 @@ static const type_info info[] = { { "_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, { { @@ -4506,7 +4516,7 @@ static const type_info info[] = { { "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, { { @@ -4526,25 +4536,25 @@ static const type_info info[] = { { "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 }, { @@ -4574,7 +4584,7 @@ static const type_info info[] = { { "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 }, { @@ -4592,7 +4602,7 @@ static const type_info info[] = { { "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 }, { @@ -4610,43 +4620,43 @@ static const type_info info[] = { { "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, { { @@ -4746,7 +4756,7 @@ static void test_dump_typelib(const char *name) { 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); @@ -4769,21 +4779,8 @@ static void test_dump_typelib(const char *name) 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*)); @@ -4797,7 +4794,7 @@ todo_wine /* widl generates broken typelib and typeattr just reflects that */ 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);
@@ -4976,8 +4973,8 @@ static void test_register_typelib(BOOL system_registration) { 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 }, @@ -5052,14 +5049,15 @@ static void test_register_typelib(BOOL system_registration) 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);
@@ -5107,7 +5105,7 @@ static void test_register_typelib(BOOL system_registration) 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);
@@ -6261,7 +6259,7 @@ static void test_stub(void) 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); diff --git a/modules/rostests/winetests/oleaut32/usrmarshal.c b/modules/rostests/winetests/oleaut32/usrmarshal.c index b9478d1b69..97c05024e5 100644 --- a/modules/rostests/winetests/oleaut32/usrmarshal.c +++ b/modules/rostests/winetests/oleaut32/usrmarshal.c @@ -416,7 +416,7 @@ static void test_marshal_LPSAFEARRAY(void)
/* Test an array of VT_BSTR */ sab[0].lLbound = 3; - sab[0].cElements = sizeof(values) / sizeof(values[0]); + sab[0].cElements = ARRAY_SIZE(values);
lpsa = SafeArrayCreate(VT_BSTR, 1, sab); expected_bstr_size = 0; @@ -463,7 +463,7 @@ static void test_marshal_LPSAFEARRAY(void) ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected); ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal, result %p\n", next);
- for (i = 0; i < sizeof(values) / sizeof(values[0]); i++) + for (i = 0; i < ARRAY_SIZE(values); i++) { BSTR gotvalue = NULL;
@@ -777,6 +777,7 @@ static void test_marshal_VARIANT(void) HRESULT hr; LONG bound, bound2; VARTYPE vt, vt2; + IUnknown *unk;
stubMsg.RpcMsg = &rpcMsg;
@@ -964,6 +965,36 @@ static void test_marshal_VARIANT(void) VARIANT_UserFree(&umcb.Flags, &v2); HeapFree(GetProcessHeap(), 0, oldbuffer);
+ /*** I8 ***/ + VariantInit(&v); + V_VT(&v) = VT_I8; + V_I8(&v) = (LONGLONG)1000000 * 1000000; + + rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v); + ok(stubMsg.BufferLength == 32, "size %d\n", stubMsg.BufferLength); + + buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer); + stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength; + memset(buffer, 0xcc, stubMsg.BufferLength); + next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v); + ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength); + wirev = (DWORD*)buffer; + + wirev = check_variant_header(wirev, &v, stubMsg.BufferLength); + ok(*wirev == 0xcccccccc, "wv[5] %08x\n", *wirev); /* pad */ + wirev++; + ok(*(LONGLONG *)wirev == V_I8(&v), "wv[6] %s\n", wine_dbgstr_longlong(*(LONGLONG *)wirev)); + VariantInit(&v2); + stubMsg.Buffer = buffer; + next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2); + ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength); + ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v), V_VT(&v2)); + ok(V_I8(&v) == V_I8(&v2), "got i8 %s expect %s\n", + wine_dbgstr_longlong(V_I8(&v)), wine_dbgstr_longlong(V_I8(&v2))); + + VARIANT_UserFree(&umcb.Flags, &v2); + HeapFree(GetProcessHeap(), 0, oldbuffer); + /*** R4 ***/ VariantInit(&v); V_VT(&v) = VT_R4; @@ -1549,6 +1580,32 @@ todo_wine ok(heap_unknown->refs == 1, "%d refcounts of IUnknown leaked\n", heap_unknown->refs - 1); IUnknown_Release(&heap_unknown->IUnknown_iface); HeapFree(GetProcessHeap(), 0, oldbuffer); + + unk = NULL; + VariantInit(&v); + V_VT(&v) = VT_UNKNOWN | VT_BYREF; + V_UNKNOWNREF(&v) = &unk; + + rpcMsg.BufferLength = stubMsg.BufferLength = VARIANT_UserSize(&umcb.Flags, 0, &v); + ok(stubMsg.BufferLength >= 28, "size %d\n", stubMsg.BufferLength); + buffer = rpcMsg.Buffer = stubMsg.Buffer = stubMsg.BufferStart = alloc_aligned(stubMsg.BufferLength, &oldbuffer); + stubMsg.BufferEnd = stubMsg.Buffer + stubMsg.BufferLength; + memset(buffer, 0xcc, stubMsg.BufferLength); + next = VARIANT_UserMarshal(&umcb.Flags, buffer, &v); + ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength); + wirev = (DWORD*)buffer; + wirev = check_variant_header(wirev, &v, stubMsg.BufferLength); + + ok(*wirev == 4, "wv[5] %08x\n", *wirev); + + VariantInit(&v2); + stubMsg.Buffer = buffer; + next = VARIANT_UserUnmarshal(&umcb.Flags, buffer, &v2); + ok(next == buffer + stubMsg.BufferLength, "got %p expect %p\n", next, buffer + stubMsg.BufferLength); + ok(V_VT(&v) == V_VT(&v2), "got vt %d expect %d\n", V_VT(&v2), V_VT(&v)); + ok(!*V_UNKNOWNREF(&v2), "got %p expect NULL\n", *V_UNKNOWNREF(&v2)); + VARIANT_UserFree(&umcb.Flags, &v2); + HeapFree(GetProcessHeap(), 0, oldbuffer); }
diff --git a/modules/rostests/winetests/oleaut32/varformat.c b/modules/rostests/winetests/oleaut32/varformat.c index 69476aa5d3..d713894870 100644 --- a/modules/rostests/winetests/oleaut32/varformat.c +++ b/modules/rostests/winetests/oleaut32/varformat.c @@ -80,7 +80,7 @@ static void test_VarFormatNumber(void)
CHECKPTR(VarFormatNumber);
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char)); + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff)); if (buff[0] != '.' || buff[1]) { skip("Skipping VarFormatNumber tests as decimal separator is '%s'\n", buff); @@ -127,7 +127,7 @@ static const char *szVarFmtFail = "VT %d|0x%04x Format %s: expected 0x%08x, '%s' #define VARFMT(vt,v,val,fmt,ret,str) do { \ out = NULL; \ V_VT(&in) = (vt); v(&in) = val; \ - if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, sizeof(buffW)/sizeof(WCHAR)); \ + if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, ARRAY_SIZE(buffW)); \ hres = pVarFormat(&in,fmt ? buffW : NULL,fd,fw,flags,&out); \ if (SUCCEEDED(hres)) WideCharToMultiByte(CP_ACP, 0, out, -1, buff, sizeof(buff),0,0); \ else buff[0] = '\0'; \ @@ -224,7 +224,7 @@ static const FMTDATERES VarFormat_namedtime_results[] = };
#define VNUMFMT(vt,v) \ - for (i = 0; i < sizeof(VarFormat_results)/sizeof(FMTRES); i++) \ + for (i = 0; i < ARRAY_SIZE(VarFormat_results); i++) \ { \ VARFMT(vt,v,1,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].one_res); \ VARFMT(vt,v,0,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].zero_res); \ @@ -256,13 +256,13 @@ static void test_VarFormat(void) skip("Skipping VarFormat tests for non English language\n"); return; } - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char)); + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff)); if (buff[0] != '.' || buff[1]) { skip("Skipping VarFormat tests as decimal separator is '%s'\n", buff); return; } - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, sizeof(buff)/sizeof(char)); + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, ARRAY_SIZE(buff)); if (buff[0] != '2' || buff[1]) { skip("Skipping VarFormat tests as decimal places is '%s'\n", buff); @@ -296,7 +296,7 @@ static void test_VarFormat(void) VARFMT(VT_BOOL|VT_BYREF,V_BOOLREF,&bFalse,"True/False",S_OK,"False");
/* Dates */ - for (i = 0; i < sizeof(VarFormat_date_results)/sizeof(FMTDATERES); i++) + for (i = 0; i < ARRAY_SIZE(VarFormat_date_results); i++) { if (i < 7) fd = i + 1; /* Test first day */ @@ -308,14 +308,14 @@ static void test_VarFormat(void) }
/* Named time formats */ - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, sizeof(buff)/sizeof(char)); + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, ARRAY_SIZE(buff)); if (strcmp(buff, "h:mm:ss tt")) { skip("Skipping named time tests as time format is '%s'\n", buff); } else { - for (i = 0; i < sizeof(VarFormat_namedtime_results)/sizeof(FMTDATERES); i++) + for (i = 0; i < ARRAY_SIZE(VarFormat_namedtime_results); i++) { fd = 0; VARFMT(VT_DATE,V_DATE,VarFormat_namedtime_results[i].val, diff --git a/modules/rostests/winetests/oleaut32/vartest.c b/modules/rostests/winetests/oleaut32/vartest.c index 429ffbbb2e..92e044bcd3 100644 --- a/modules/rostests/winetests/oleaut32/vartest.c +++ b/modules/rostests/winetests/oleaut32/vartest.c @@ -537,7 +537,7 @@ static const char *vtstr(int x) return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
default: - vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer); + vtstr_current %= ARRAY_SIZE(vtstr_buffer); sprintf(vtstr_buffer[vtstr_current], "unknown variant type %d", x); return vtstr_buffer[vtstr_current++]; } @@ -545,7 +545,7 @@ static const char *vtstr(int x)
static const char *variantstr( const VARIANT *var ) { - vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer); + vtstr_current %= ARRAY_SIZE(vtstr_buffer); switch(V_VT(var)) { case VT_I1: @@ -664,7 +664,7 @@ static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT static int strcmp_wa(const WCHAR *strw, const char *stra) { WCHAR buf[512]; - MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(buf[0])); + MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf)); return lstrcmpW(strw, buf); }
@@ -792,7 +792,7 @@ static void test_VariantClear(void) * Also demonstrates that null pointers in 'v' are not dereferenced. * Individual variant tests should test VariantClear() with non-NULL values. */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE vt;
@@ -921,7 +921,7 @@ static void test_VariantCopy(void) */
/* vSrc == vDst */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { for (vt = 0; vt <= VT_BSTR_BLOB; vt++) { @@ -949,7 +949,7 @@ static void test_VariantCopy(void) memset(&vSrc, 0, sizeof(vSrc)); V_VT(&vSrc) = VT_UI1;
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { for (vt = 0; vt <= VT_BSTR_BLOB; vt++) { @@ -975,7 +975,7 @@ static void test_VariantCopy(void) }
/* Test that VariantClear() checks vSrc for validity before copying */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { for (vt = 0; vt <= VT_BSTR_BLOB; vt++) { @@ -1079,7 +1079,7 @@ static void test_VariantCopyInd(void) memset(buffer, 0, sizeof(buffer));
/* vSrc == vDst */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { if (ExtraFlags[i] & VT_ARRAY) continue; /* Native crashes on NULL safearray */ @@ -1130,7 +1130,7 @@ static void test_VariantCopyInd(void) V_VT(&vSrc) = VT_UI1|VT_BYREF; V_BYREF(&vSrc) = &buffer;
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { for (vt = 0; vt <= VT_BSTR_BLOB; vt++) { @@ -1156,7 +1156,7 @@ static void test_VariantCopyInd(void) }
/* bad src */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { if (ExtraFlags[i] & VT_ARRAY) continue; /* Native crashes on NULL safearray */ @@ -1276,7 +1276,7 @@ static HRESULT convert_str( const char *str, INT dig, ULONG flags, NUMPARSE *np, BYTE rgb[128], LCID lcid ) { OLECHAR buff[128]; - MultiByteToWideChar( CP_ACP,0, str, -1, buff, sizeof(buff)/sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP,0, str, -1, buff, ARRAY_SIZE( buff )); memset( rgb, FAILDIG, 128 ); memset( np, 255, sizeof(*np) ); np->cDig = dig; @@ -2291,7 +2291,7 @@ static void test_VarAbs(void)
/* Test all possible V_VT values. */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE vt;
@@ -2354,7 +2354,7 @@ static void test_VarAbs(void) hres = pVarAbs(&v,&vDst); ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000, "VarAbs(CY): expected 0x0 got 0x%X\n", hres); - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char)); + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff)); if (buff[1]) { trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff); @@ -2392,7 +2392,7 @@ static void test_VarNot(void) CHECKPTR(VarNot);
/* Test all possible V_VT values */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE vt;
@@ -2523,7 +2523,7 @@ static void test_VarSub(void) VariantInit(&result);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) {
VARTYPE leftvt, rightvt, resvt; @@ -3254,7 +3254,7 @@ static void test_VarFix(void) CHECKPTR(VarFix);
/* Test all possible V_VT values */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE vt;
@@ -3369,7 +3369,7 @@ static void test_VarInt(void) CHECKPTR(VarInt);
/* Test all possible V_VT values */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE vt;
@@ -3490,7 +3490,7 @@ static void test_VarNeg(void) * native version. This at least ensures (as with all tests here) that * we will notice if/when new vtypes/flags are added in native. */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE vt;
@@ -3632,7 +3632,8 @@ static const struct decimal_round_t decimal_round_data[] = { {{ 2, 0, 0, 0, 199 }, { 2, 0, 0, 0, 199 }, 2}, {{ 2, DECIMAL_NEG, 0, 0, 199 }, { 2, DECIMAL_NEG, 0, 0, 199 }, 2}, {{ 2, DECIMAL_NEG, 0, 0, 55 }, { 2, DECIMAL_NEG, 0, 0, 6 }, 1}, - {{ 2, 0, 0, 0, 55 }, { 2, 0, 0, 0, 6 }, 1} + {{ 2, 0, 0, 0, 55 }, { 2, 0, 0, 0, 6 }, 1}, + {{ 2, 0, 0, 0, 1999 }, { 1, 0, 0, 0, 200 }, 1}, };
static void test_VarRound(void) @@ -3677,7 +3678,7 @@ static void test_VarRound(void) VARROUND(DATE,-1.449,1,DATE,-1.4);
/* replace the decimal separator */ - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char)); + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff)); if (!buff[1]) { szNumMin[2] = buff[0]; szNum[1] = buff[0]; @@ -3721,7 +3722,7 @@ static void test_VarRound(void) "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
/* VT_DECIMAL */ - for (i = 0; i < sizeof(decimal_round_data)/sizeof(struct decimal_round_t); i++) + for (i = 0; i < ARRAY_SIZE(decimal_round_data); i++) { const struct decimal_round_t *ptr = &decimal_round_data[i]; DECIMAL *pdec; @@ -3735,7 +3736,6 @@ static void test_VarRound(void) S1(U1(*pdec)).Lo32 = ptr->source.Lo32; VariantInit(&vDst); hres = pVarRound(&v, ptr->dec, &vDst); - todo_wine ok(hres == S_OK, "%d: got 0x%08x\n", i, hres); if (hres == S_OK) { @@ -3786,7 +3786,7 @@ static void test_VarXor(void) CHECKPTR(VarXor);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -4520,7 +4520,7 @@ static void test_VarOr(void) CHECKPTR(VarOr);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -5252,7 +5252,7 @@ static void test_VarEqv(void) CHECKPTR(VarEqv);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -5396,7 +5396,7 @@ static void test_VarMul(void) rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -5567,7 +5567,7 @@ static void test_VarAdd(void) rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -6231,7 +6231,7 @@ static void test_VarAnd(void) false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -6947,7 +6947,7 @@ static void test_VarCmp(void) bstr1few = SysAllocString(sz1few);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt;
@@ -7183,7 +7183,7 @@ static void test_VarPow(void) num3_str = SysAllocString(str3);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -7709,7 +7709,7 @@ static void test_VarDiv(void) num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -8082,7 +8082,7 @@ static void test_VarIdiv(void) num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
@@ -8648,7 +8648,7 @@ static void test_VarImp(void) false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */ - for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++) + for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++) { VARTYPE leftvt, rightvt, resvt;
diff --git a/modules/rostests/winetests/oleaut32/vartype.c b/modules/rostests/winetests/oleaut32/vartype.c index 9be2eb2901..8d8ccf7198 100644 --- a/modules/rostests/winetests/oleaut32/vartype.c +++ b/modules/rostests/winetests/oleaut32/vartype.c @@ -112,7 +112,7 @@ static BOOL has_locales;
#define CONVERT_STR(func,str,flags) \ SetLastError(0); \ - if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \ + if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \ hres = func(str ? buff : NULL,in,flags,&out)
#define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \ @@ -2944,7 +2944,7 @@ static void test_VarDateFromDec(void)
#define DFS(str) \ buff[0] = '\0'; out = 0.0; \ - if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \ + if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \ hres = VarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out)
#define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \ @@ -3091,7 +3091,7 @@ static void test_VarDateFromStr(void) DFS("1.2.3 4 5 6"); EXPECT_DBL(38812.04309027778); DFS("1 2 3 4.5.6"); EXPECT_DBL(37623.17020833334);
- for (i = 0; i < sizeof(BadDateStrings)/sizeof(char*); i++) + for (i = 0; i < ARRAY_SIZE(BadDateStrings); i++) { DFS(BadDateStrings[i]); EXPECT_MISMATCH; } @@ -4540,6 +4540,40 @@ static void test_VarBoolChangeTypeEx(void) * BSTR */
+static void test_VarBstrFromI4(void) +{ + static const WCHAR int_min[] = { '-','2','1','4','7','4','8','3','6','4','8','\0' }; + static const WCHAR minus_42[] = { '-','4','2','\0' }; + BSTR bstr = NULL; + HRESULT hres; + LONG value; + LCID lcid; + + lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); + +#ifdef __REACTOS__ + value = (-2147483647 - 1); +#else + value = -2147483648; +#endif + hres = VarBstrFromI4(value, lcid, LOCALE_NOUSEROVERRIDE, &bstr); + ok(hres == S_OK, "got hres 0x%08x\n", hres); + if (bstr) + { + ok(memcmp(bstr, int_min, sizeof(int_min)) == 0, "string different\n"); + SysFreeString(bstr); + } + + value = -42; + hres = VarBstrFromI4(value, lcid, LOCALE_NOUSEROVERRIDE, &bstr); + ok(hres == S_OK, "got hres 0x%08x\n", hres); + if (bstr) + { + ok(memcmp(bstr, minus_42, sizeof(minus_42)) == 0, "string different\n"); + SysFreeString(bstr); + } +} + static void test_VarBstrFromR4(void) { static const WCHAR szNative[] = { '6','5','4','3','2','2','.','3','\0' }; @@ -4816,12 +4850,12 @@ static void test_VarBstrCmp(void) /* These two strings are considered equal even though one is * NULL-terminated and the other not. */ - bstr2 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR)); + bstr2 = SysAllocStringLen(s1, ARRAY_SIZE(s1)); VARBSTRCMP(bstr,bstr2,0,VARCMP_EQ); SysFreeString(bstr2);
/* These two strings are not equal */ - bstr2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR)); + bstr2 = SysAllocStringLen(s2, ARRAY_SIZE(s2)); VARBSTRCMP(bstr,bstr2,0,VARCMP_LT); SysFreeString(bstr2);
@@ -5235,8 +5269,7 @@ if (0) ret = VarBstrCat(str1, str2, &res); ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret); ok(res != NULL, "Expected a string\n"); - ok(SysStringLen(res) == sizeof(sz1sz2) / sizeof(WCHAR) - 1, - "Unexpected length\n"); + ok(SysStringLen(res) == ARRAY_SIZE(sz1sz2) - 1, "Unexpected length\n"); ok(!memcmp(res, sz1sz2, sizeof(sz1sz2)), "Unexpected value\n"); SysFreeString(res);
@@ -5244,14 +5277,13 @@ if (0) SysFreeString(str1);
/* Concatenation of two strings with embedded NULLs */ - str1 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR)); - str2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR)); + str1 = SysAllocStringLen(s1, ARRAY_SIZE(s1)); + str2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
ret = VarBstrCat(str1, str2, &res); ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret); ok(res != NULL, "Expected a string\n"); - ok(SysStringLen(res) == sizeof(s1s2) / sizeof(WCHAR), - "Unexpected length\n"); + ok(SysStringLen(res) == ARRAY_SIZE(s1s2), "Unexpected length\n"); ok(!memcmp(res, s1s2, sizeof(s1s2)), "Unexpected value\n"); SysFreeString(res);
@@ -5893,13 +5925,13 @@ static void test_bstr_cache(void) /* Fill the bucket with cached entries. We roll our own, to show that the cache doesn't use the bstr length field to determine bucket allocation. */ - for(i=0; i < sizeof(strs)/sizeof(*strs); i++) + for(i=0; i < ARRAY_SIZE(strs); i++) { DWORD_PTR *ptr = CoTaskMemAlloc(64); ptr[0] = 0; strs[i] = (BSTR)(ptr + 1); } - for(i=0; i < sizeof(strs)/sizeof(*strs); i++) + for(i=0; i < ARRAY_SIZE(strs); i++) SysFreeString(strs[i]);
/* Following allocation will be made from cache */ @@ -6349,6 +6381,7 @@ START_TEST(vartype) test_VarBoolCopy(); test_VarBoolChangeTypeEx();
+ test_VarBstrFromI4(); test_VarBstrFromR4(); test_VarBstrFromDate(); test_VarBstrFromCy();