[OLEAUT32_WINETEST] Sync with Wine Staging 4.0. CORE-15682

This commit is contained in:
Amine Khaldi 2019-01-29 13:19:12 +01:00
parent 5db885cae7
commit 357f69997d
11 changed files with 2182 additions and 407 deletions

View file

@ -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) include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
add_typelib(test_reg.idl test_tlb.idl tmarshal.idl) add_typelib(test_reg.idl test_tlb.idl tmarshal.idl)
add_idl_Headers(oleaut32_idlheaders test_reg.idl test_tlb.idl tmarshal.idl) add_idl_Headers(oleaut32_idlheaders test_reg.idl test_tlb.idl tmarshal.idl)

View file

@ -420,7 +420,7 @@ static void test_font_events_disp(void)
hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp); hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp);
EXPECT_HR(hr, S_OK); 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) switch (font_dispids[i].dispid)
{ {

View file

@ -512,7 +512,7 @@ static void test_Invoke(void)
/* DISPID_PICT_RENDER */ /* DISPID_PICT_RENDER */
hdc = create_render_dc(); 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_VT(&args[i]) = VT_I4;
V_I4(&args[0]) = 0; V_I4(&args[0]) = 0;
@ -550,12 +550,61 @@ static void test_Invoke(void)
IPictureDisp_Release(picdisp); 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) static void test_OleCreatePictureIndirect(void)
{ {
PICTDESC desc;
OLE_HANDLE handle; OLE_HANDLE handle;
IPicture *pict; IPicture *pict;
HRESULT hr; HRESULT hr;
short type; short type, i;
if (0) if (0)
{ {
@ -563,20 +612,52 @@ if (0)
OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, NULL); OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, NULL);
} }
hr = OleCreatePictureIndirect(NULL, &IID_IPicture, TRUE, (void**)&pict); desc.cbSizeofstruct = sizeof(desc);
ok(hr == S_OK, "hr %08x\n", hr); 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; for (i = PICTYPE_UNINITIALIZED; i <= PICTYPE_ENHMETAFILE; i++)
hr = IPicture_get_Type(pict, &type); {
ok(hr == S_OK, "hr %08x\n", hr); hr = create_picture(i, &pict);
ok(type == PICTYPE_UNINITIALIZED, "type %d\n", type); ok(hr == S_OK, "%d: got %#x\n", i, hr);
handle = 0xdeadbeef; type = 0xdead;
hr = IPicture_get_Handle(pict, &handle); hr = IPicture_get_Type(pict, &type);
ok(hr == S_OK, "hr %08x\n", hr); ok(hr == S_OK, "%d: got %#x\n", i, hr);
ok(handle == 0, "handle %08x\n", handle); ok(type == i, "%d: got %d\n", i, type);
IPicture_Release(pict); 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);
}
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);
}
} }
static void test_apm(void) 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); IPicture_QueryInterface(iface, &IID_IDispatch, (void**)&disp);
/* This is broken on 64 bits - accepted pointer argument type is still VT_I4 */ /* 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; V_VT(&args[i]) = VT_I4;
/* pack arguments and call */ /* pack arguments and call */
@ -794,7 +875,7 @@ static void test_Render(void)
SetPixelV(hdc, 10, 10, 0x00223344); SetPixelV(hdc, 10, 10, 0x00223344);
expected = GetPixel(hdc, 0, 0); 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); ole_expect(hres, S_OK);
if(hres != S_OK) goto done; if(hres != S_OK) goto done;
@ -896,7 +977,7 @@ static void test_OleLoadPicturePath(void)
{emptyW, &IID_IPicture, NULL}, {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; pic = (IPicture *)0xdeadbeef;
hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0, 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); WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
CloseHandle(file); 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. */ /* Try a normal DOS path. */
hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic); hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);

View file

@ -567,7 +567,7 @@ static void test_safearray(void)
hres = SafeArrayDestroy(a); hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD failed with hres %x\n", hres); 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) if ((i == VT_I8 || i == VT_UI8) && has_i8)
{ {
vttypes[i].elemsize = sizeof(LONG64); vttypes[i].elemsize = sizeof(LONG64);
@ -704,7 +704,7 @@ static void test_safearray(void)
if (!pSafeArrayAllocDescriptorEx) if (!pSafeArrayAllocDescriptorEx)
return; return;
for (i = 0; i < sizeof(vttypes)/sizeof(vttypes[0]); i++) { for (i = 0; i < ARRAY_SIZE(vttypes); i++) {
a = NULL; a = NULL;
hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a); hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a);
ok(hres == S_OK, "SafeArrayAllocDescriptorEx gave hres 0x%x\n", hres); ok(hres == S_OK, "SafeArrayAllocDescriptorEx gave hres 0x%x\n", hres);
@ -765,7 +765,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
{ {
SAFEARRAY *sa; SAFEARRAY *sa;
HRESULT hres; HRESULT hres;
int i; UINT i;
/* Failure cases */ /* Failure cases */
hres = SafeArrayAllocDescriptor(0, &sa); hres = SafeArrayAllocDescriptor(0, &sa);
@ -789,7 +789,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
if (hres == S_OK) 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); SafeArrayGetDim(sa), i);
hres = SafeArrayDestroyDescriptor(sa); hres = SafeArrayDestroyDescriptor(sa);
@ -828,11 +828,9 @@ static void test_SafeArrayCreateLockDestroy(void)
SAFEARRAY *sa; SAFEARRAY *sa;
HRESULT hres; HRESULT hres;
VARTYPE vt; VARTYPE vt;
int dimension; UINT dimension;
#define NUM_DIMENSIONS (int)(sizeof(sab) / sizeof(sab[0])) for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
{ {
sab[dimension].lLbound = 0; sab[dimension].lLbound = 0;
sab[dimension].cElements = 8; 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 */ /* 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; sab[dimension].cElements = 8;
/* Test all VARTYPES in 1-4 dimensions */ /* Test all VARTYPES in 1-4 dimensions */
@ -870,7 +868,7 @@ static void test_SafeArrayCreateLockDestroy(void)
if (sa) if (sa)
{ {
ok(SafeArrayGetDim(sa) == (UINT)dimension, ok(SafeArrayGetDim(sa) == dimension,
"VARTYPE %d (@%d dimensions) cDims is %d, expected %d\n", "VARTYPE %d (@%d dimensions) cDims is %d, expected %d\n",
vt, dimension, SafeArrayGetDim(sa), dimension); vt, dimension, SafeArrayGetDim(sa), dimension);
ok(SafeArrayGetElemsize(sa) == dwLen || vt == VT_R8, ok(SafeArrayGetElemsize(sa) == dwLen || vt == VT_R8,
@ -1007,13 +1005,13 @@ static void test_LockUnlock(void)
hres = SafeArrayUnlock(NULL); hres = SafeArrayUnlock(NULL);
ok(hres == E_INVALIDARG, "Lock NULL array hres 0x%x\n", hres); 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].lLbound = 0;
sab[dimension].cElements = 8; sab[dimension].cElements = 8;
} }
sa = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab); sa = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
/* Test maximum locks */ /* Test maximum locks */
test_LockUnlock_Vector: test_LockUnlock_Vector:
@ -1054,27 +1052,27 @@ test_LockUnlock_Vector:
static void test_SafeArrayGetPutElement(void) static void test_SafeArrayGetPutElement(void)
{ {
SAFEARRAYBOUND sab[4]; SAFEARRAYBOUND sab[4];
LONG indices[NUM_DIMENSIONS], index; LONG indices[ARRAY_SIZE(sab)], index;
SAFEARRAY *sa; SAFEARRAY *sa;
HRESULT hres; HRESULT hres;
int value = 0, gotvalue, dimension; int value = 0, gotvalue, dimension;
IRecordInfoImpl *irec; IRecordInfoImpl *irec;
unsigned int x,y,z,a; 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].lLbound = dimension * 2 + 1;
sab[dimension].cElements = dimension * 3 + 1; sab[dimension].cElements = dimension * 3 + 1;
} }
sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab); sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
if (!sa) if (!sa)
return; /* Some early versions can't handle > 3 dims */ return; /* Some early versions can't handle > 3 dims */
ok(sa->cbElements == sizeof(value), "int size mismatch\n"); ok(sa->cbElements == sizeof(value), "int size mismatch\n");
/* Failure cases */ /* Failure cases */
for (x = 0; x < NUM_DIMENSIONS; x++) for (x = 0; x < ARRAY_SIZE(sab); x++)
{ {
indices[0] = sab[0].lLbound; indices[0] = sab[0].lLbound;
indices[1] = sab[1].lLbound; indices[1] = sab[1].lLbound;
@ -1384,16 +1382,16 @@ static void test_SafeArrayCopyData(void)
return; return;
} }
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{ {
sab[dimension].lLbound = dimension * 2 + 2; sab[dimension].lLbound = dimension * 2 + 2;
sab[dimension].cElements = dimension * 3 + 1; sab[dimension].cElements = dimension * 3 + 1;
size *= sab[dimension].cElements; 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"); 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"); ok(sacopy != NULL, "Copy test couldn't create copy array\n");
if (!sa || !sacopy) if (!sa || !sacopy)
@ -1453,11 +1451,11 @@ static void test_SafeArrayCopyData(void)
hres = SafeArrayDestroy(sacopy); hres = SafeArrayDestroy(sacopy);
ok(hres == S_OK, "got 0x%08x\n", hres); 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 != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures); 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 feature = ignored_copy_features[i];
USHORT orig = sacopy->fFeatures; USHORT orig = sacopy->fFeatures;
@ -1491,7 +1489,7 @@ static void test_SafeArrayCopyData(void)
"got 0x%04x\n", sacopy->fFeatures); "got 0x%04x\n", sacopy->fFeatures);
SafeArrayDestroy(sacopy); 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 != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures); ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
hres = SafeArrayCopyData(sa, sacopy); hres = SafeArrayCopyData(sa, sacopy);
@ -1507,7 +1505,7 @@ static void test_SafeArrayCreateEx(void)
SAFEARRAYBOUND sab[4]; SAFEARRAYBOUND sab[4];
SAFEARRAY *sa; SAFEARRAY *sa;
HRESULT hres; HRESULT hres;
int dimension; UINT dimension;
if (!pSafeArrayCreateEx) if (!pSafeArrayCreateEx)
{ {
@ -1515,7 +1513,7 @@ static void test_SafeArrayCreateEx(void)
return; return;
} }
for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++) for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{ {
sab[dimension].lLbound = 0; sab[dimension].lLbound = 0;
sab[dimension].cElements = 8; 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); ok(sa->fFeatures == 0, "got src features 0x%04x\n", sa->fFeatures);
sa->cbElements = 16; 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]; USHORT feature = ignored_copy_features[i];
@ -2020,9 +2018,10 @@ static void test_SafeArrayDestroyData (void)
ok(hres == S_OK, "got 0x%08x\n", hres); ok(hres == S_OK, "got 0x%08x\n", hres);
todo_wine todo_wine
ok(sa->fFeatures == FADF_HAVEVARTYPE, "got 0x%x\n", sa->fFeatures); ok(sa->fFeatures == FADF_HAVEVARTYPE, "got 0x%x\n", sa->fFeatures);
ok(sa->pvData != NULL, "got %p\n", sa->pvData); todo_wine
/* There seems to be a bug on windows, especially visible on 64bit systems, ok(sa->pvData == NULL || broken(sa->pvData != NULL), "got %p\n", sa->pvData);
probably double-free of similar issue. */ /* There was a bug on windows, especially visible on 64bit systems,
probably double-free or similar issue. */
sa->pvData = NULL; sa->pvData = NULL;
SafeArrayDestroy(sa); SafeArrayDestroy(sa);
} }

File diff suppressed because it is too large Load diff

View file

@ -20,9 +20,67 @@
#pragma makedep ident #pragma makedep ident
#pragma makedep typelib #pragma makedep typelib
#include "tmarshal_dispids.h"
import "ocidl.idl"; 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), uuid(d96d8a3e-78b6-4c8d-8f27-059db959be8a),
version(2.5), version(2.5),
@ -45,10 +103,13 @@ library TestTypelib
UINT uarr[8]; UINT uarr[8];
} MYSTRUCT; } MYSTRUCT;
typedef [public] int myint_t;
coclass ApplicationObject2; coclass ApplicationObject2;
[ [
odl, odl,
oleautomation,
uuid(12345678-1234-4321-1234-121212121212) uuid(12345678-1234-4321-1234-121212121212)
] ]
interface ISomethingFromDispatch : IDispatch interface ISomethingFromDispatch : IDispatch
@ -87,6 +148,51 @@ library TestTypelib
HRESULT test(); 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, odl,
uuid(a1f8cae3-c947-4c5f-b57d-c87b9b5f3586), uuid(a1f8cae3-c947-4c5f-b57d-c87b9b5f3586),
@ -129,24 +235,12 @@ library TestTypelib
[propget, id(DISPID_VALUE)] [propget, id(DISPID_VALUE)]
HRESULT Value([in] VARIANT *value, [out, retval] VARIANT *retval); HRESULT Value([in] VARIANT *value, [out, retval] VARIANT *retval);
[id(DISPID_TM_ARRAY)]
HRESULT Array([in] SAFEARRAY(BSTR) values);
[id(DISPID_TM_VARARRAYPTR)] [id(DISPID_TM_VARARRAYPTR)]
HRESULT VariantArrayPtr([in] SAFEARRAY(VARIANT) *values); 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)] [vararg, id(DISPID_TM_VARARG)]
HRESULT VarArg([in] int numexpect, [in] SAFEARRAY(VARIANT) values); 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)] [id(DISPID_TM_ERROR)]
HRESULT Error(); HRESULT Error();
@ -186,8 +280,80 @@ library TestTypelib
[id(DISPID_TM_VARARG_REF_RUN), vararg] [id(DISPID_TM_VARARG_REF_RUN), vararg]
HRESULT VarArg_Ref_Run([in] BSTR name, [in] SAFEARRAY(VARIANT) *params, [out, retval] VARIANT *result); 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)] [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, odl,
uuid(a028db05-30f0-4b93-b17a-41c72f831d84), uuid(a028db05-30f0-4b93-b17a-41c72f831d84),
#if 0 /* FIXME: commented out as causes widl to generate incorrect typelib */
dual, dual,
#endif
oleautomation oleautomation
] ]
interface IKindaEnumWidget : IUnknown interface IKindaEnumWidget : IUnknown

View file

@ -627,7 +627,7 @@ static void test_CreateDispTypeInfo(void)
OLECHAR *name = func1; OLECHAR *name = func1;
ifdata.pmethdata = methdata; ifdata.pmethdata = methdata;
ifdata.cMembers = sizeof(methdata) / sizeof(methdata[0]); ifdata.cMembers = ARRAY_SIZE(methdata);
methdata[0].szName = SysAllocString(func1); methdata[0].szName = SysAllocString(func1);
methdata[0].ppdata = parms1; methdata[0].ppdata = parms1;
@ -1405,7 +1405,7 @@ static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM view)
dwMaxSubkeyLen++; dwMaxSubkeyLen++;
dwMaxValueLen++; dwMaxValueLen++;
dwMaxLen = max(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 */ /* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR)))) 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 (!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; 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); 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); 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; FUNCDESC *pFD;
WCHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
CHAR pathA[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); GetModuleFileNameA(NULL, pathA, MAX_PATH);
MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, 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); hr = LoadTypeLib(path, &pTL);
if(FAILED(hr)) return; 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->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft); ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags); 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->cFuncs == 6, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes); ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
}
ITypeInfo_ReleaseTypeAttr(pTI, pTA); ITypeInfo_ReleaseTypeAttr(pTI, pTA);
if(use_midl_tlb) {
hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href); hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
ok(hr == S_OK, "hr %08x\n", hr); ok(hr == S_OK, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p); 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->memid == 0x60020000, "memid %08x\n", pFD->memid);
ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft); ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
ITypeInfo_ReleaseFuncDesc(pTI, pFD); ITypeInfo_ReleaseFuncDesc(pTI, pFD);
}
ITypeInfo_Release(pTI); ITypeInfo_Release(pTI);
@ -1651,17 +1641,13 @@ if(use_midl_tlb) {
hr = ITypeInfo_GetTypeAttr(pTI, &pTA); hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
ok(hr == S_OK, "hr %08x\n", hr); 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);
ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind); ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags);
ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft); ok(pTA->cFuncs == 8, "cfuncs %d\n", pTA->cFuncs);
if(use_midl_tlb) { ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags); ITypeInfo_ReleaseTypeAttr(pTI, pTA);
}
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); hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
ok(hr == S_OK, "hr %08x\n", hr); ok(hr == S_OK, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p); 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); ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
ITypeInfo_ReleaseTypeAttr(pTI_p, pTA); ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
ITypeInfo_Release(pTI_p); ITypeInfo_Release(pTI_p);
if(use_midl_tlb) {
hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD); hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
ok(hr == S_OK, "hr %08x\n", hr); ok(hr == S_OK, "hr %08x\n", hr);
ok(pFD->memid == 0x1234, "memid %08x\n", pFD->memid); ok(pFD->memid == 0x1234, "memid %08x\n", pFD->memid);
ITypeInfo_ReleaseFuncDesc(pTI, pFD); ITypeInfo_ReleaseFuncDesc(pTI, pFD);
}
ITypeInfo_Release(pTI); ITypeInfo_Release(pTI);
/* ItestIF7 is dual with inherited ifaces which derive from Dispatch */ /* 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->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft); ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags); 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->cFuncs == 3, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes); ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
}
ITypeInfo_ReleaseTypeAttr(pTI, pTA); ITypeInfo_ReleaseTypeAttr(pTI, pTA);
if(use_midl_tlb) {
hr = ITypeInfo_GetRefTypeOfImplType(pTI, -1, &href); hr = ITypeInfo_GetRefTypeOfImplType(pTI, -1, &href);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr); ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href); 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->memid == 0x60010000, "memid %08x\n", pFD->memid);
ok(pFD->oVft == 2 * sizeof(void *), "oVft %d\n", pFD->oVft); ok(pFD->oVft == 2 * sizeof(void *), "oVft %d\n", pFD->oVft);
ITypeInfo_ReleaseFuncDesc(pTI, pFD); ITypeInfo_ReleaseFuncDesc(pTI, pFD);
}
ITypeInfo_Release(pTI); ITypeInfo_Release(pTI);
/* ItestIF11 is a syntax 2 dispinterface which derives from IDispatch */ /* 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->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft); ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags); 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->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes); ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
}
ITypeInfo_ReleaseTypeAttr(pTI, pTA); ITypeInfo_ReleaseTypeAttr(pTI, pTA);
if(use_midl_tlb) {
hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href); hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
ok(hr == S_OK, "hr %08x\n", hr); ok(hr == S_OK, "hr %08x\n", hr);
hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p); hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
@ -1791,7 +1768,6 @@ if(use_midl_tlb) {
ok(hr == S_OK, "hr %08x\n", hr); ok(hr == S_OK, "hr %08x\n", hr);
if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p); if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p);
ITypeInfo_ReleaseFuncDesc(pTI, pFD); ITypeInfo_ReleaseFuncDesc(pTI, pFD);
}
ITypeInfo_Release(pTI); ITypeInfo_Release(pTI);
@ -1804,13 +1780,10 @@ if(use_midl_tlb) {
ok(pTA->typekind == TKIND_INTERFACE, "kind %04x\n", pTA->typekind); ok(pTA->typekind == TKIND_INTERFACE, "kind %04x\n", pTA->typekind);
ok(pTA->cbSizeVft == 6 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft); ok(pTA->cbSizeVft == 6 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
ok(pTA->wTypeFlags == 0, "typeflags %x\n", pTA->wTypeFlags); ok(pTA->wTypeFlags == 0, "typeflags %x\n", pTA->wTypeFlags);
if(use_midl_tlb) {
ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs); ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes); ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
}
ITypeInfo_ReleaseTypeAttr(pTI, pTA); ITypeInfo_ReleaseTypeAttr(pTI, pTA);
if(use_midl_tlb) {
/* Should have one method */ /* Should have one method */
hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD); hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr); 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->memid == 0x60020000, "memid %08x\n", pFD->memid);
ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft); ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
ITypeInfo_ReleaseFuncDesc(pTI, pFD); ITypeInfo_ReleaseFuncDesc(pTI, pFD);
}
ITypeInfo_Release(pTI); ITypeInfo_Release(pTI);
ITypeLib_Release(pTL); ITypeLib_Release(pTL);
@ -2392,7 +2364,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(V_BSTR(&paramdescex.varDefaultValue)); SysFreeString(V_BSTR(&paramdescex.varDefaultValue));
WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL); 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); hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
ok(hres == S_OK, "got %08x\n", hres); 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(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 0, "got: %u\n", cnames); 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(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames); ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0])); 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(name);
SysFreeString(helpfile); 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(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 3, "got: %u\n", cnames); ok(cnames == 3, "got: %u\n", cnames);
ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0])); 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(name);
SysFreeString(helpfile); 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(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames); ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0])); 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(name);
SysFreeString(helpfile); 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(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames); ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0])); 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)); sprintf(buf, "sizeof(union %s)", dump_string(name));
break; break;
case TKIND_ENUM:
case TKIND_ALIAS: 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"); sprintf(buf, "4");
break; break;
@ -4155,10 +4165,10 @@ static void test_dump_typelib(const char *name)
printf(" \"%s\",\n", wine_dbgstr_guid(&attr->guid)); 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", " /*helpctx*/ 0x%04x, /*version*/ 0x%08x, /*#vtbl*/ %d, /*#func*/ %d",
map_value(attr->typekind, tkind_map), dump_type_flags(attr->wTypeFlags), 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), help_ctx, MAKELONG(attr->wMinorVerNum, attr->wMajorVerNum),
attr->cbSizeVft/sizeof(void*), attr->cFuncs); attr->cbSizeVft/sizeof(void*), attr->cFuncs);
@ -4258,13 +4268,13 @@ static const type_info info[] = {
{ {
"g", "g",
"{b14b6bb5-904e-4ff9-b247-bd361f7a0001}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"test_iface", "test_iface",
"{b14b6bb5-904e-4ff9-b247-bd361f7a0002}", "{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, /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 4, /*#func*/ 1,
{ {
{ {
@ -4286,7 +4296,7 @@ static const type_info info[] = {
{ {
"parent_iface", "parent_iface",
"{b14b6bb5-904e-4ff9-b247-bd361f7aa001}", "{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, /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 4, /*#func*/ 1,
{ {
{ {
@ -4308,7 +4318,7 @@ static const type_info info[] = {
{ {
"child_iface", "child_iface",
"{b14b6bb5-904e-4ff9-b247-bd361f7aa002}", "{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, /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 5, /*#func*/ 1,
{ {
{ {
@ -4328,43 +4338,43 @@ static const type_info info[] = {
{ {
"_n", "_n",
"{016fe2ec-b2c8-45f8-b23b-39e53a753903}", "{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 /*helpctx*/ 0x0003, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"n", "n",
"{016fe2ec-b2c8-45f8-b23b-39e53a753902}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"nn", "nn",
"{00000000-0000-0000-0000-000000000000}", "{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 /*helpctx*/ 0x0003, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"_m", "_m",
"{016fe2ec-b2c8-45f8-b23b-39e53a753906}", "{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 /*helpctx*/ 0x0003, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"m", "m",
"{016fe2ec-b2c8-45f8-b23b-39e53a753905}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"mm", "mm",
"{00000000-0000-0000-0000-000000000000}", "{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 /*helpctx*/ 0x0003, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"IDualIface", "IDualIface",
"{b14b6bb5-904e-4ff9-b247-bd361f7aaedd}", "{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, /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 7, /*#func*/ 8,
{ {
{ {
@ -4506,7 +4516,7 @@ static const type_info info[] = {
{ {
"ISimpleIface", "ISimpleIface",
"{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac009}", "{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, /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 8, /*#func*/ 1,
{ {
{ {
@ -4526,25 +4536,25 @@ static const type_info info[] = {
{ {
"test_struct", "test_struct",
"{4029f190-ca4a-4611-aeb9-673983cb96dd}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"test_struct2", "test_struct2",
"{4029f190-ca4a-4611-aeb9-673983cb96de}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"t_INT", "t_INT",
"{016fe2ec-b2c8-45f8-b23b-39e53a75396a}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"a", "a",
"{00000000-0000-0000-0000-000000000000}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
@ -4574,7 +4584,7 @@ static const type_info info[] = {
{ {
"c", "c",
"{016fe2ec-b2c8-45f8-b23b-39e53a75396b}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
@ -4592,7 +4602,7 @@ static const type_info info[] = {
{ {
"d", "d",
"{016fe2ec-b2c8-45f8-b23b-39e53a75396d}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
@ -4610,43 +4620,43 @@ static const type_info info[] = {
{ {
"e", "e",
"{016fe2ec-b2c8-45f8-b23b-39e53a753970}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"_e", "_e",
"{00000000-0000-0000-0000-000000000000}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"ee", "ee",
"{016fe2ec-b2c8-45f8-b23b-39e53a753971}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"f", "f",
"{016fe2ec-b2c8-45f8-b23b-39e53a753972}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"_f", "_f",
"{00000000-0000-0000-0000-000000000000}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"ff", "ff",
"{016fe2ec-b2c8-45f8-b23b-39e53a753973}", "{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 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
}, },
{ {
"ITestIface", "ITestIface",
"{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac00a}", "{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, /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 13, /*#func*/ 6,
{ {
{ {
@ -4746,7 +4756,7 @@ static void test_dump_typelib(const char *name)
{ {
WCHAR wszName[MAX_PATH]; WCHAR wszName[MAX_PATH];
ITypeLib *typelib; ITypeLib *typelib;
int ticount = sizeof(info)/sizeof(info[0]); int ticount = ARRAY_SIZE(info);
int iface, func; int iface, func;
MultiByteToWideChar(CP_ACP, 0, name, -1, wszName, MAX_PATH); 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)); ole_check(ITypeInfo_GetTypeAttr(typeinfo, &typeattr));
expect_int(typeattr->typekind, ti->type); expect_int(typeattr->typekind, ti->type);
expect_hex(typeattr->wTypeFlags, ti->wTypeFlags); 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->cbAlignment, ti->cbAlignment);
expect_int(typeattr->cbSizeInstance, ti->cbSizeInstance); expect_int(typeattr->cbSizeInstance, ti->cbSizeInstance);
}
expect_int(help_ctx, ti->help_ctx); expect_int(help_ctx, ti->help_ctx);
expect_int(MAKELONG(typeattr->wMinorVerNum, typeattr->wMajorVerNum), ti->version); expect_int(MAKELONG(typeattr->wMinorVerNum, typeattr->wMajorVerNum), ti->version);
expect_int(typeattr->cbSizeVft, ti->cbSizeVft * sizeof(void*)); 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; HRESULT hr;
GUID guid; 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); IIDFromString(guidW, &guid);
expect_guid(&guid, &typeattr->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_FDISPATCHABLE },
{ TKIND_INTERFACE, TYPEFLAG_FOLEAUTOMATION }, { TKIND_INTERFACE, TYPEFLAG_FOLEAUTOMATION },
{ TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FOLEAUTOMATION }, { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FOLEAUTOMATION },
{ TKIND_DISPATCH, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ }, { TKIND_DISPATCH, TYPEFLAG_FDUAL },
{ TKIND_DISPATCH, 0 /* TYPEFLAG_FDUAL - widl clears this flag for non-IDispatch derived interfaces */ }, { TKIND_DISPATCH, TYPEFLAG_FDUAL },
{ TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL }, { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
{ TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL }, { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
{ TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE }, { 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(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->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_ReleaseTypeAttr(dual_info, dual_attr);
ITypeInfo_Release(dual_info); 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); WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid); 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)) || if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
attr->typekind == TKIND_DISPATCH) 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); WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid); sprintf(key_name, "Interface\\%s", uuid);
@ -6261,7 +6259,7 @@ static void test_stub(void)
WCHAR guidW[40]; WCHAR guidW[40];
REGSAM opposite = side ^ (KEY_WOW64_64KEY | KEY_WOW64_32KEY); 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 */ /* Delete the opposite interface key */
lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_READ | opposite, &hkey); lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_READ | opposite, &hkey);

View file

@ -416,7 +416,7 @@ static void test_marshal_LPSAFEARRAY(void)
/* Test an array of VT_BSTR */ /* Test an array of VT_BSTR */
sab[0].lLbound = 3; sab[0].lLbound = 3;
sab[0].cElements = sizeof(values) / sizeof(values[0]); sab[0].cElements = ARRAY_SIZE(values);
lpsa = SafeArrayCreate(VT_BSTR, 1, sab); lpsa = SafeArrayCreate(VT_BSTR, 1, sab);
expected_bstr_size = 0; 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(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal, result %p\n", next); 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; BSTR gotvalue = NULL;
@ -777,6 +777,7 @@ static void test_marshal_VARIANT(void)
HRESULT hr; HRESULT hr;
LONG bound, bound2; LONG bound, bound2;
VARTYPE vt, vt2; VARTYPE vt, vt2;
IUnknown *unk;
stubMsg.RpcMsg = &rpcMsg; stubMsg.RpcMsg = &rpcMsg;
@ -964,6 +965,36 @@ static void test_marshal_VARIANT(void)
VARIANT_UserFree(&umcb.Flags, &v2); VARIANT_UserFree(&umcb.Flags, &v2);
HeapFree(GetProcessHeap(), 0, oldbuffer); 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 ***/ /*** R4 ***/
VariantInit(&v); VariantInit(&v);
V_VT(&v) = VT_R4; 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); ok(heap_unknown->refs == 1, "%d refcounts of IUnknown leaked\n", heap_unknown->refs - 1);
IUnknown_Release(&heap_unknown->IUnknown_iface); IUnknown_Release(&heap_unknown->IUnknown_iface);
HeapFree(GetProcessHeap(), 0, oldbuffer); 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);
} }

View file

@ -80,7 +80,7 @@ static void test_VarFormatNumber(void)
CHECKPTR(VarFormatNumber); 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]) if (buff[0] != '.' || buff[1])
{ {
skip("Skipping VarFormatNumber tests as decimal separator is '%s'\n", buff); 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 { \ #define VARFMT(vt,v,val,fmt,ret,str) do { \
out = NULL; \ out = NULL; \
V_VT(&in) = (vt); v(&in) = val; \ 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); \ hres = pVarFormat(&in,fmt ? buffW : NULL,fd,fw,flags,&out); \
if (SUCCEEDED(hres)) WideCharToMultiByte(CP_ACP, 0, out, -1, buff, sizeof(buff),0,0); \ if (SUCCEEDED(hres)) WideCharToMultiByte(CP_ACP, 0, out, -1, buff, sizeof(buff),0,0); \
else buff[0] = '\0'; \ else buff[0] = '\0'; \
@ -224,7 +224,7 @@ static const FMTDATERES VarFormat_namedtime_results[] =
}; };
#define VNUMFMT(vt,v) \ #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,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); \ 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"); skip("Skipping VarFormat tests for non English language\n");
return; 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]) if (buff[0] != '.' || buff[1])
{ {
skip("Skipping VarFormat tests as decimal separator is '%s'\n", buff); skip("Skipping VarFormat tests as decimal separator is '%s'\n", buff);
return; 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]) if (buff[0] != '2' || buff[1])
{ {
skip("Skipping VarFormat tests as decimal places is '%s'\n", buff); 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"); VARFMT(VT_BOOL|VT_BYREF,V_BOOLREF,&bFalse,"True/False",S_OK,"False");
/* Dates */ /* 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) if (i < 7)
fd = i + 1; /* Test first day */ fd = i + 1; /* Test first day */
@ -308,14 +308,14 @@ static void test_VarFormat(void)
} }
/* Named time formats */ /* 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")) if (strcmp(buff, "h:mm:ss tt"))
{ {
skip("Skipping named time tests as time format is '%s'\n", buff); skip("Skipping named time tests as time format is '%s'\n", buff);
} }
else else
{ {
for (i = 0; i < sizeof(VarFormat_namedtime_results)/sizeof(FMTDATERES); i++) for (i = 0; i < ARRAY_SIZE(VarFormat_namedtime_results); i++)
{ {
fd = 0; fd = 0;
VARFMT(VT_DATE,V_DATE,VarFormat_namedtime_results[i].val, VARFMT(VT_DATE,V_DATE,VarFormat_namedtime_results[i].val,

View file

@ -537,7 +537,7 @@ static const char *vtstr(int x)
return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK"; return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
default: 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); sprintf(vtstr_buffer[vtstr_current], "unknown variant type %d", x);
return vtstr_buffer[vtstr_current++]; return vtstr_buffer[vtstr_current++];
} }
@ -545,7 +545,7 @@ static const char *vtstr(int x)
static const char *variantstr( const VARIANT *var ) 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)) switch(V_VT(var))
{ {
case VT_I1: 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) static int strcmp_wa(const WCHAR *strw, const char *stra)
{ {
WCHAR buf[512]; 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); return lstrcmpW(strw, buf);
} }
@ -792,7 +792,7 @@ static void test_VariantClear(void)
* Also demonstrates that null pointers in 'v' are not dereferenced. * Also demonstrates that null pointers in 'v' are not dereferenced.
* Individual variant tests should test VariantClear() with non-NULL values. * 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; VARTYPE vt;
@ -921,7 +921,7 @@ static void test_VariantCopy(void)
*/ */
/* vSrc == vDst */ /* 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++) for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{ {
@ -949,7 +949,7 @@ static void test_VariantCopy(void)
memset(&vSrc, 0, sizeof(vSrc)); memset(&vSrc, 0, sizeof(vSrc));
V_VT(&vSrc) = VT_UI1; 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++) 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 */ /* 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++) for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{ {
@ -1079,7 +1079,7 @@ static void test_VariantCopyInd(void)
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
/* vSrc == vDst */ /* 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) if (ExtraFlags[i] & VT_ARRAY)
continue; /* Native crashes on NULL safearray */ continue; /* Native crashes on NULL safearray */
@ -1130,7 +1130,7 @@ static void test_VariantCopyInd(void)
V_VT(&vSrc) = VT_UI1|VT_BYREF; V_VT(&vSrc) = VT_UI1|VT_BYREF;
V_BYREF(&vSrc) = &buffer; 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++) for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{ {
@ -1156,7 +1156,7 @@ static void test_VariantCopyInd(void)
} }
/* bad src */ /* 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) if (ExtraFlags[i] & VT_ARRAY)
continue; /* Native crashes on NULL safearray */ 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 ) NUMPARSE *np, BYTE rgb[128], LCID lcid )
{ {
OLECHAR buff[128]; 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( rgb, FAILDIG, 128 );
memset( np, 255, sizeof(*np) ); memset( np, 255, sizeof(*np) );
np->cDig = dig; np->cDig = dig;
@ -2291,7 +2291,7 @@ static void test_VarAbs(void)
/* Test all possible V_VT values. /* 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; VARTYPE vt;
@ -2354,7 +2354,7 @@ static void test_VarAbs(void)
hres = pVarAbs(&v,&vDst); hres = pVarAbs(&v,&vDst);
ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000, ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
"VarAbs(CY): expected 0x0 got 0x%X\n", hres); "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]) if (buff[1])
{ {
trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff); trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff);
@ -2392,7 +2392,7 @@ static void test_VarNot(void)
CHECKPTR(VarNot); CHECKPTR(VarNot);
/* Test all possible V_VT values */ /* 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; VARTYPE vt;
@ -2523,7 +2523,7 @@ static void test_VarSub(void)
VariantInit(&result); VariantInit(&result);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -3254,7 +3254,7 @@ static void test_VarFix(void)
CHECKPTR(VarFix); CHECKPTR(VarFix);
/* Test all possible V_VT values */ /* 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; VARTYPE vt;
@ -3369,7 +3369,7 @@ static void test_VarInt(void)
CHECKPTR(VarInt); CHECKPTR(VarInt);
/* Test all possible V_VT values */ /* 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; VARTYPE vt;
@ -3490,7 +3490,7 @@ static void test_VarNeg(void)
* native version. This at least ensures (as with all tests here) that * native version. This at least ensures (as with all tests here) that
* we will notice if/when new vtypes/flags are added in native. * 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; 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, 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, 199 }, { 2, DECIMAL_NEG, 0, 0, 199 }, 2},
{{ 2, DECIMAL_NEG, 0, 0, 55 }, { 2, DECIMAL_NEG, 0, 0, 6 }, 1}, {{ 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) static void test_VarRound(void)
@ -3677,7 +3678,7 @@ static void test_VarRound(void)
VARROUND(DATE,-1.449,1,DATE,-1.4); VARROUND(DATE,-1.449,1,DATE,-1.4);
/* replace the decimal separator */ /* 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]) { if (!buff[1]) {
szNumMin[2] = buff[0]; szNumMin[2] = buff[0];
szNum[1] = 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)); "VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
/* VT_DECIMAL */ /* 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]; const struct decimal_round_t *ptr = &decimal_round_data[i];
DECIMAL *pdec; DECIMAL *pdec;
@ -3735,7 +3736,6 @@ static void test_VarRound(void)
S1(U1(*pdec)).Lo32 = ptr->source.Lo32; S1(U1(*pdec)).Lo32 = ptr->source.Lo32;
VariantInit(&vDst); VariantInit(&vDst);
hres = pVarRound(&v, ptr->dec, &vDst); hres = pVarRound(&v, ptr->dec, &vDst);
todo_wine
ok(hres == S_OK, "%d: got 0x%08x\n", i, hres); ok(hres == S_OK, "%d: got 0x%08x\n", i, hres);
if (hres == S_OK) if (hres == S_OK)
{ {
@ -3786,7 +3786,7 @@ static void test_VarXor(void)
CHECKPTR(VarXor); CHECKPTR(VarXor);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -4520,7 +4520,7 @@ static void test_VarOr(void)
CHECKPTR(VarOr); CHECKPTR(VarOr);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -5252,7 +5252,7 @@ static void test_VarEqv(void)
CHECKPTR(VarEqv); CHECKPTR(VarEqv);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -5396,7 +5396,7 @@ static void test_VarMul(void)
rbstr = SysAllocString(sz12); rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -5567,7 +5567,7 @@ static void test_VarAdd(void)
rbstr = SysAllocString(sz12); rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -6231,7 +6231,7 @@ static void test_VarAnd(void)
false_str = SysAllocString(szFalse); false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -6947,7 +6947,7 @@ static void test_VarCmp(void)
bstr1few = SysAllocString(sz1few); bstr1few = SysAllocString(sz1few);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt;
@ -7183,7 +7183,7 @@ static void test_VarPow(void)
num3_str = SysAllocString(str3); num3_str = SysAllocString(str3);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -7709,7 +7709,7 @@ static void test_VarDiv(void)
num2_str = SysAllocString(str2); num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -8082,7 +8082,7 @@ static void test_VarIdiv(void)
num2_str = SysAllocString(str2); num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;
@ -8648,7 +8648,7 @@ static void test_VarImp(void)
false_str = SysAllocString(szFalse); false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */ /* 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; VARTYPE leftvt, rightvt, resvt;

View file

@ -112,7 +112,7 @@ static BOOL has_locales;
#define CONVERT_STR(func,str,flags) \ #define CONVERT_STR(func,str,flags) \
SetLastError(0); \ 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) hres = func(str ? buff : NULL,in,flags,&out)
#define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \ #define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \
@ -2944,7 +2944,7 @@ static void test_VarDateFromDec(void)
#define DFS(str) \ #define DFS(str) \
buff[0] = '\0'; out = 0.0; \ 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) hres = VarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out)
#define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \ #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(38812.04309027778);
DFS("1 2 3 4.5.6"); EXPECT_DBL(37623.17020833334); 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; DFS(BadDateStrings[i]); EXPECT_MISMATCH;
} }
@ -4540,6 +4540,40 @@ static void test_VarBoolChangeTypeEx(void)
* BSTR * 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 void test_VarBstrFromR4(void)
{ {
static const WCHAR szNative[] = { '6','5','4','3','2','2','.','3','\0' }; 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 /* These two strings are considered equal even though one is
* NULL-terminated and the other not. * 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); VARBSTRCMP(bstr,bstr2,0,VARCMP_EQ);
SysFreeString(bstr2); SysFreeString(bstr2);
/* These two strings are not equal */ /* 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); VARBSTRCMP(bstr,bstr2,0,VARCMP_LT);
SysFreeString(bstr2); SysFreeString(bstr2);
@ -5235,8 +5269,7 @@ if (0)
ret = VarBstrCat(str1, str2, &res); ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret); ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n"); ok(res != NULL, "Expected a string\n");
ok(SysStringLen(res) == sizeof(sz1sz2) / sizeof(WCHAR) - 1, ok(SysStringLen(res) == ARRAY_SIZE(sz1sz2) - 1, "Unexpected length\n");
"Unexpected length\n");
ok(!memcmp(res, sz1sz2, sizeof(sz1sz2)), "Unexpected value\n"); ok(!memcmp(res, sz1sz2, sizeof(sz1sz2)), "Unexpected value\n");
SysFreeString(res); SysFreeString(res);
@ -5244,14 +5277,13 @@ if (0)
SysFreeString(str1); SysFreeString(str1);
/* Concatenation of two strings with embedded NULLs */ /* Concatenation of two strings with embedded NULLs */
str1 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR)); str1 = SysAllocStringLen(s1, ARRAY_SIZE(s1));
str2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR)); str2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
ret = VarBstrCat(str1, str2, &res); ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret); ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n"); ok(res != NULL, "Expected a string\n");
ok(SysStringLen(res) == sizeof(s1s2) / sizeof(WCHAR), ok(SysStringLen(res) == ARRAY_SIZE(s1s2), "Unexpected length\n");
"Unexpected length\n");
ok(!memcmp(res, s1s2, sizeof(s1s2)), "Unexpected value\n"); ok(!memcmp(res, s1s2, sizeof(s1s2)), "Unexpected value\n");
SysFreeString(res); SysFreeString(res);
@ -5893,13 +5925,13 @@ static void test_bstr_cache(void)
/* Fill the bucket with cached entries. /* Fill the bucket with cached entries.
We roll our own, to show that the cache doesn't use We roll our own, to show that the cache doesn't use
the bstr length field to determine bucket allocation. */ 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); DWORD_PTR *ptr = CoTaskMemAlloc(64);
ptr[0] = 0; ptr[0] = 0;
strs[i] = (BSTR)(ptr + 1); 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]); SysFreeString(strs[i]);
/* Following allocation will be made from cache */ /* Following allocation will be made from cache */
@ -6349,6 +6381,7 @@ START_TEST(vartype)
test_VarBoolCopy(); test_VarBoolCopy();
test_VarBoolChangeTypeEx(); test_VarBoolChangeTypeEx();
test_VarBstrFromI4();
test_VarBstrFromR4(); test_VarBstrFromR4();
test_VarBstrFromDate(); test_VarBstrFromDate();
test_VarBstrFromCy(); test_VarBstrFromCy();