diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 0c3ab84bd14..b8904a3f20a 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "windef.h" #include "winbase.h" @@ -44,7 +45,7 @@ #define expect_int(expr, value) expect_eq(expr, (int)(value), int, "%d") #define expect_hex(expr, value) expect_eq(expr, (int)(value), int, "0x%x") #define expect_null(expr) expect_eq(expr, NULL, const void *, "%p") -#define expect_guid(expected, guid) { ok(IsEqualGUID(expected, guid), "got wrong guid\n"); } +#define expect_guid(expected, guid) { ok(IsEqualGUID(expected, guid), "got wrong guid %s\n", wine_dbgstr_guid(guid)); } #define expect_wstr_acpval(expr, value) \ { \ @@ -3665,11 +3666,9 @@ static void test_CreateTypeLib(SYSKIND sys) { static char *dump_string(LPWSTR wstr) { - int size = lstrlenW(wstr)+3; + int size = lstrlenW(wstr)+1; char *out = CoTaskMemAlloc(size); - WideCharToMultiByte(20127, 0, wstr, -1, out+1, size, NULL, NULL); - out[0] = '\"'; - strcat(out, "\""); + WideCharToMultiByte(20127, 0, wstr, -1, out, size, NULL, NULL); return out; } @@ -3710,6 +3709,19 @@ static const struct map_entry invkind_map[] = { {0, NULL} }; +static const struct map_entry callconv_map[] = { + MAP_ENTRY(CC_FASTCALL), + MAP_ENTRY(CC_CDECL), + MAP_ENTRY(CC_PASCAL), + MAP_ENTRY(CC_MACPASCAL), + MAP_ENTRY(CC_STDCALL), + MAP_ENTRY(CC_FPFASTCALL), + MAP_ENTRY(CC_SYSCALL), + MAP_ENTRY(CC_MPWCDECL), + MAP_ENTRY(CC_MPWPASCAL), + {0, NULL} +}; + #undef MAP_ENTRY static const char *map_value(DWORD val, const struct map_entry *map) @@ -3730,6 +3742,66 @@ static const char *map_value(DWORD val, const struct map_entry *map) return buf; } +static const char *dump_type_flags(DWORD flags) +{ + static char buf[256]; + + if (!flags) return "0"; + + buf[0] = 0; + +#define ADD_FLAG(x) if (flags & x) { if (buf[0]) strcat(buf, "|"); strcat(buf, #x); flags &= ~x; } + ADD_FLAG(TYPEFLAG_FPROXY) + ADD_FLAG(TYPEFLAG_FREVERSEBIND) + ADD_FLAG(TYPEFLAG_FDISPATCHABLE) + ADD_FLAG(TYPEFLAG_FREPLACEABLE) + ADD_FLAG(TYPEFLAG_FAGGREGATABLE) + ADD_FLAG(TYPEFLAG_FRESTRICTED) + ADD_FLAG(TYPEFLAG_FOLEAUTOMATION) + ADD_FLAG(TYPEFLAG_FNONEXTENSIBLE) + ADD_FLAG(TYPEFLAG_FDUAL) + ADD_FLAG(TYPEFLAG_FCONTROL) + ADD_FLAG(TYPEFLAG_FHIDDEN) + ADD_FLAG(TYPEFLAG_FPREDECLID) + ADD_FLAG(TYPEFLAG_FLICENSED) + ADD_FLAG(TYPEFLAG_FCANCREATE) + ADD_FLAG(TYPEFLAG_FAPPOBJECT) +#undef ADD_FLAG + + assert(!flags); + assert(strlen(buf) < sizeof(buf)); + + return buf; +} + +static char *print_size(BSTR name, TYPEATTR *attr) +{ + static char buf[256]; + + switch (attr->typekind) + { + case TKIND_DISPATCH: + case TKIND_INTERFACE: + sprintf(buf, "sizeof(%s*)", dump_string(name)); + break; + + case TKIND_RECORD: + sprintf(buf, "sizeof(struct %s)", dump_string(name)); + break; + + case TKIND_ENUM: + case TKIND_ALIAS: + sprintf(buf, "4"); + break; + + default: + assert(0); + return NULL; + } + + return buf; +} + static void test_dump_typelib(const char *name) { WCHAR wszString[260]; @@ -3740,8 +3812,10 @@ static void test_dump_typelib(const char *name) MultiByteToWideChar(CP_ACP, 0, name, -1, wszString, 260); OLE_CHECK(LoadTypeLib(wszString, &lib)); + + printf("/*** Autogenerated data. Do not edit, change the generator above instead. ***/\n"); + count = ITypeLib_GetTypeInfoCount(lib); - printf("/* interfaces count: %d */\n", count); for (i = 0; i < count; i++) { TYPEATTR *attr; @@ -3750,17 +3824,22 @@ static void test_dump_typelib(const char *name) OLE_CHECK(ITypeLib_GetDocumentation(lib, i, &name, NULL, NULL, NULL)); printf("{\n" - " %s,\n", dump_string(name)); - SysFreeString(name); + " \"%s\",\n", dump_string(name)); OLE_CHECK(ITypeLib_GetTypeInfo(lib, i, &info)); - ITypeInfo_GetTypeAttr(info, &attr); - printf(" /*kind*/ %s, /*flags*/ 0x%x, /*align*/ %d, /*size*/ %d,\n" - " /*#vtbl*/ %d, /*#func*/ %d,\n" - " {\n", - map_value(attr->typekind, tkind_map), attr->wTypeFlags, attr->cbAlignment, attr->cbSizeInstance, attr->cbSizeVft, + OLE_CHECK(ITypeInfo_GetTypeAttr(info, &attr)); + + printf(" \"%s\",\n", wine_dbgstr_guid(&attr->guid)); + + printf(" /*kind*/ %s, /*flags*/ %s, /*align*/ %d, /*size*/ %s,\n" + " /*#vtbl*/ %d, /*#func*/ %d", + map_value(attr->typekind, tkind_map), dump_type_flags(attr->wTypeFlags), + attr->cbAlignment, print_size(name, attr), attr->cbSizeVft/sizeof(void*), attr->cFuncs); - ITypeInfo_ReleaseTypeAttr(info, attr); + + if (attr->cFuncs) printf(",\n {\n"); + else printf("\n"); + while (1) { FUNCDESC *desc; @@ -3771,11 +3850,11 @@ static void test_dump_typelib(const char *name) if (FAILED(ITypeInfo_GetFuncDesc(info, f, &desc))) break; printf(" {\n" - " 0x%x, /*func*/ %s, /*inv*/ %s, /*call*/ 0x%x,\n", + " /*id*/ 0x%x, /*func*/ %s, /*inv*/ %s, /*call*/ %s,\n", desc->memid, map_value(desc->funckind, funckind_map), map_value(desc->invkind, invkind_map), - desc->callconv); + map_value(desc->callconv, callconv_map)); printf(" /*#param*/ %d, /*#opt*/ %d, /*vtbl*/ %d, /*#scodes*/ %d, /*flags*/ 0x%x,\n", - desc->cParams, desc->cParamsOpt, desc->oVft, desc->cScodes, desc->wFuncFlags); + desc->cParams, desc->cParamsOpt, desc->oVft/sizeof(void*), desc->cScodes, desc->wFuncFlags); printf(" {%d, %x}, /* ret */\n", desc->elemdescFunc.tdesc.vt, U(desc->elemdescFunc).paramdesc.wParamFlags); printf(" { /* params */\n"); for (p = 0; p < desc->cParams; p++) @@ -3789,7 +3868,7 @@ static void test_dump_typelib(const char *name) OLE_CHECK(ITypeInfo_GetNames(info, desc->memid, tab, 256, &cNames)); for (p = 0; p < cNames; p++) { - printf(" %s,\n", dump_string(tab[p])); + printf(" \"%s\",\n", dump_string(tab[p])); SysFreeString(tab[p]); } printf(" NULL,\n"); @@ -3798,9 +3877,11 @@ static void test_dump_typelib(const char *name) ITypeInfo_ReleaseFuncDesc(info, desc); f++; } - printf(" }\n"); + if (attr->cFuncs) printf(" }\n"); printf("},\n"); + ITypeInfo_ReleaseTypeAttr(info, attr); ITypeInfo_Release(info); + SysFreeString(name); } ITypeLib_Release(lib); } @@ -3843,14 +3924,15 @@ typedef struct _type_info } type_info; static const type_info info[] = { +/*** Autogenerated data. Do not edit, change the generator above instead. ***/ { "IDualIface", "{b14b6bb5-904e-4ff9-b247-bd361f7aaedd}", - /*kind*/ TKIND_DISPATCH, /*flags*/ TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL, /*align*/ 4, /*size*/ sizeof(void*), + /*kind*/ TKIND_DISPATCH, /*flags*/ TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL, /*align*/ 4, /*size*/ sizeof(IDualIface*), /*#vtbl*/ 7, /*#func*/ 8, { { - 0x60000000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60000000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 2, /*#opt*/ 0, /*vtbl*/ 0, /*#scodes*/ 0, /*flags*/ 0x1, {24, 0}, /* ret */ { /* params */ @@ -3866,7 +3948,7 @@ static const type_info info[] = { }, }, { - 0x60000001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60000001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 1, /*#scodes*/ 0, /*flags*/ 0x1, {19, 0}, /* ret */ { /* params */ @@ -3878,7 +3960,7 @@ static const type_info info[] = { }, }, { - 0x60000002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60000002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 2, /*#scodes*/ 0, /*flags*/ 0x1, {19, 0}, /* ret */ { /* params */ @@ -3890,7 +3972,7 @@ static const type_info info[] = { }, }, { - 0x60010000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60010000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 3, /*#scodes*/ 0, /*flags*/ 0x1, {24, 0}, /* ret */ { /* params */ @@ -3904,7 +3986,7 @@ static const type_info info[] = { }, }, { - 0x60010001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60010001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 3, /*#opt*/ 0, /*vtbl*/ 4, /*#scodes*/ 0, /*flags*/ 0x1, {24, 0}, /* ret */ { /* params */ @@ -3922,7 +4004,7 @@ static const type_info info[] = { }, }, { - 0x60010002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60010002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 5, /*#opt*/ 0, /*vtbl*/ 5, /*#scodes*/ 0, /*flags*/ 0x1, {24, 0}, /* ret */ { /* params */ @@ -3944,7 +4026,7 @@ static const type_info info[] = { }, }, { - 0x60010003, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60010003, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 8, /*#opt*/ 0, /*vtbl*/ 6, /*#scodes*/ 0, /*flags*/ 0x1, {24, 0}, /* ret */ { /* params */ @@ -3972,7 +4054,7 @@ static const type_info info[] = { }, }, { - 0x60020000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60020000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0, {24, 0}, /* ret */ { /* params */ @@ -3988,11 +4070,11 @@ static const type_info info[] = { { "ISimpleIface", "{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac009}", - /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ 4, /*size*/ sizeof(void*), + /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ 4, /*size*/ sizeof(ISimpleIface*), /*#vtbl*/ 8, /*#func*/ 1, { { - 0x60020000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, + /*id*/ 0x60020000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL, /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0x0, {25, 0}, /* ret */ { /* params */ @@ -4008,12 +4090,14 @@ 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*/ 4, /*size*/ sizeof(struct test_struct), + /*#vtbl*/ 0, /*#func*/ 0 }, { "test_struct2", "{4029f190-ca4a-4611-aeb9-673983cb96de}", - /* kind */ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct test_struct) + /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct test_struct2), + /*#vtbl*/ 0, /*#func*/ 0 } }; @@ -4068,8 +4152,8 @@ static void test_dump_typelib(const char *name) /* check that it's possible to search using this uuid */ typeinfo2 = NULL; hr = ITypeLib_GetTypeInfoOfGuid(typelib, &guid, &typeinfo2); - ok(hr == S_OK, "got 0x%08x\n", hr); - ITypeInfo_Release(typeinfo2); + ok(hr == S_OK || (IsEqualGUID(&guid, &IID_NULL) && hr == TYPE_E_ELEMENTNOTFOUND), "got 0x%08x\n", hr); + if (hr == S_OK) ITypeInfo_Release(typeinfo2); } for (func = 0; func < typeattr->cFuncs; func++)