From: Vibhav Pant <vibhavp(a)gmail.com> --- dlls/vccorlib140/tests/Makefile.in | 2 +- dlls/vccorlib140/tests/vccorlib.c | 165 +++++++++++++++++++++++++++++ dlls/vccorlib140/vccorlib.c | 48 +++++++++ dlls/vccorlib140/vccorlib140.spec | 22 ++-- 4 files changed, 225 insertions(+), 12 deletions(-) diff --git a/dlls/vccorlib140/tests/Makefile.in b/dlls/vccorlib140/tests/Makefile.in index b75d820bc8c..9d20ff64424 100644 --- a/dlls/vccorlib140/tests/Makefile.in +++ b/dlls/vccorlib140/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = vccorlib140.dll -IMPORTS = ole32 uuid +IMPORTS = combase ole32 uuid SOURCES = \ vccorlib.c diff --git a/dlls/vccorlib140/tests/vccorlib.c b/dlls/vccorlib140/tests/vccorlib.c index 199481ff779..bef246f2760 100644 --- a/dlls/vccorlib140/tests/vccorlib.c +++ b/dlls/vccorlib140/tests/vccorlib.c @@ -27,6 +27,9 @@ #include "activation.h" #include "objbase.h" #include "weakreference.h" +#define WIDL_using_Windows_Foundation +#include "windows.foundation.h" +#include "winstring.h" #include "wine/test.h" #define DEFINE_EXPECT(func) \ @@ -103,6 +106,12 @@ DEFINE_EXPECT(PostInitialize); DEFINE_EXPECT(PreUninitialize); DEFINE_EXPECT(PostUninitialize); +struct __abi_type_descriptor +{ + const WCHAR *name; + int type_id; +}; + static HRESULT (__cdecl *pInitializeData)(int); static void (__cdecl *pUninitializeData)(int); static HRESULT (WINAPI *pGetActivationFactoryByPCWSTR)(const WCHAR *, const GUID *, void **); @@ -111,6 +120,11 @@ static void *(__cdecl *pAllocate)(size_t); static void (__cdecl *pFree)(void *); static void *(__cdecl *pAllocateWithWeakRef)(ptrdiff_t, size_t); static void (__thiscall *pReleaseTarget)(void *); +static void *(WINAPI *p___abi_make_type_id)(const struct __abi_type_descriptor *desc); +static bool (__cdecl *p_platform_type_Equals_Object)(void *, void *); +static int (__cdecl *p_platform_type_GetTypeCode)(void *); +static HSTRING (__cdecl *p_platform_type_ToString)(void *); +static HSTRING (__cdecl *p_platform_type_get_FullName)(void *); static BOOL init(void) { @@ -137,6 +151,13 @@ static BOOL init(void) pFree = (void *)GetProcAddress(hmod, "?Free(a)Heap@Details(a)Platform@@SAXPAX(a)Z"); pAllocateWithWeakRef = (void *)GetProcAddress(hmod, "?Allocate(a)Heap@Details(a)Platform@@SAPAXII(a)Z"); pReleaseTarget = (void *)GetProcAddress(hmod, "?ReleaseTarget(a)ControlBlock@Details(a)Platform@@AAAXXZ"); + p___abi_make_type_id = (void *)GetProcAddress(hmod, + "?__abi_make_type_id@@YAP$AAVType(a)Platform@@ABU__abi_type_descriptor@@@Z"); + p_platform_type_Equals_Object = (void *)GetProcAddress(hmod, "?Equals(a)Type@Platform@@U$AAA_NP$AAVObject(a)2@@Z"); + p_platform_type_GetTypeCode = (void *)GetProcAddress(hmod, + "?GetTypeCode(a)Type@Platform@@SA?AW4TypeCode(a)2@P$AAV12@@Z"); + p_platform_type_ToString = (void *)GetProcAddress(hmod, "?ToString(a)Type@Platform@@U$AAAP$AAVString(a)2@XZ"); + p_platform_type_get_FullName = (void *)GetProcAddress(hmod, "?get(a)FullName@Type(a)Platform@@Q$AAAP$AAVString(a)3@XZ"); #else if (sizeof(void *) == 8) { @@ -147,6 +168,15 @@ static BOOL init(void) pFree = (void *)GetProcAddress(hmod, "?Free(a)Heap@Details(a)Platform@@SAXPEAX(a)Z"); pAllocateWithWeakRef = (void *)GetProcAddress(hmod, "?Allocate(a)Heap@Details(a)Platform@@SAPEAX_K0(a)Z"); pReleaseTarget = (void *)GetProcAddress(hmod, "?ReleaseTarget(a)ControlBlock@Details(a)Platform@@AEAAXXZ"); + p___abi_make_type_id = (void *)GetProcAddress(hmod, + "?__abi_make_type_id@@YAPE$AAVType(a)Platform@@AEBU__abi_type_descriptor@@@Z"); + p_platform_type_Equals_Object = (void *)GetProcAddress(hmod, + "?Equals(a)Type@Platform@@UE$AAA_NPE$AAVObject(a)2@@Z"); + p_platform_type_GetTypeCode = (void *)GetProcAddress(hmod, + "?GetTypeCode(a)Type@Platform@@SA?AW4TypeCode(a)2@PE$AAV12@@Z"); + p_platform_type_ToString = (void *)GetProcAddress(hmod, "?ToString(a)Type@Platform@@UE$AAAPE$AAVString(a)2@XZ"); + p_platform_type_get_FullName = (void *)GetProcAddress(hmod, + "?get(a)FullName@Type(a)Platform@@QE$AAAPE$AAVString(a)3@XZ"); } else { @@ -157,6 +187,14 @@ static BOOL init(void) pFree = (void *)GetProcAddress(hmod, "?Free(a)Heap@Details(a)Platform@@SAXPAX(a)Z"); pAllocateWithWeakRef = (void *)GetProcAddress(hmod, "?Allocate(a)Heap@Details(a)Platform@@SAPAXII(a)Z"); pReleaseTarget = (void *)GetProcAddress(hmod, "?ReleaseTarget(a)ControlBlock@Details(a)Platform@@AAEXXZ"); + p___abi_make_type_id = (void *)GetProcAddress(hmod, + "?__abi_make_type_id@@YGP$AAVType(a)Platform@@ABU__abi_type_descriptor@@@Z"); + p_platform_type_Equals_Object = (void *)GetProcAddress(hmod, "?Equals(a)Type@Platform@@U$AAA_NP$AAVObject(a)2@@Z"); + p_platform_type_GetTypeCode = (void *)GetProcAddress(hmod, + "?GetTypeCode(a)Type@Platform@@SA?AW4TypeCode(a)2@P$AAV12@@Z"); + p_platform_type_ToString = (void *)GetProcAddress(hmod, "?ToString(a)Type@Platform@@U$AAAP$AAVString(a)2@XZ"); + p_platform_type_get_FullName = (void *)GetProcAddress(hmod, + "?get(a)FullName@Type(a)Platform@@Q$AAAP$AAVString(a)3@XZ"); } #endif ok(pGetActivationFactoryByPCWSTR != NULL, "GetActivationFactoryByPCWSTR not available\n"); @@ -165,6 +203,11 @@ static BOOL init(void) ok(pFree != NULL, "Free not available\n"); ok(pAllocateWithWeakRef != NULL, "AllocateWithWeakRef not available\n"); ok(pReleaseTarget != NULL, "ReleaseTarget not available\n"); + ok(p___abi_make_type_id != NULL, "__abi_make_type_id not available\n"); + ok(p_platform_type_Equals_Object != NULL, "Platform::Type::Equals not available\n"); + ok(p_platform_type_GetTypeCode != NULL, "Platform::Type::GetTypeCode not available\n"); + ok(p_platform_type_ToString != NULL, "Platform::Type::ToString not available\n"); + ok(p_platform_type_get_FullName != NULL, "Platform::Type::FullName not available\n"); init_thiscall_thunk(); @@ -610,6 +653,127 @@ static void test_AllocateWithWeakRef(void) ok(count == 0, "got count %lu\n", count); } +#define check_interface(o, i) check_interface_(__LINE__, (o), (i)) +static void check_interface_(int line, void *obj, const GUID *iid) +{ + HRESULT hr; + void *out; + + hr = IUnknown_QueryInterface((IUnknown *)obj, iid, &out); + ok_(__FILE__, line)(hr == S_OK, "got hr %#lx\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release((IUnknown *)out); +} + +/* Additional interfaces implemented by Platform::Object. */ +DEFINE_GUID(IID_IEquatable,0xde0cbaec,0xe077,0x4e92,0x84,0xbe,0xc6,0xd4,0x8d,0xca,0x30,0x06); +DEFINE_GUID(IID_IPrintable,0xde0cbaeb,0x8065,0x4a45,0x96,0xb1,0xc9,0xd4,0x43,0xf9,0xba,0xb3); + +static void test___abi_make_type_id(void) +{ + const struct __abi_type_descriptor desc = {L"foo", 0xdeadbeef}, desc2 = {L"foo", 0xdeadbeef}, desc3 = {NULL, 1}; + void *type_obj, *type_obj2; + const WCHAR *buf; + int typecode; + HSTRING str; + ULONG count; + bool equals; + HRESULT hr; + + type_obj = p___abi_make_type_id(&desc); + todo_wine ok(type_obj != NULL, "got type_obj %p\n", type_obj); + if (!type_obj) + { + skip("__abi_make_type_id failed\n"); + return; + } + + todo_wine check_interface(type_obj, &IID_IInspectable); + todo_wine check_interface(type_obj, &IID_IClosable); + todo_wine check_interface(type_obj, &IID_IMarshal); + todo_wine check_interface(type_obj, &IID_IAgileObject); + todo_wine check_interface(type_obj, &IID_IEquatable); + todo_wine check_interface(type_obj, &IID_IPrintable); + + hr = IInspectable_GetRuntimeClassName(type_obj, &str); + ok(hr == S_OK, "got hr %#lx\n", hr); + buf = WindowsGetStringRawBuffer(str, NULL); + todo_wine ok(buf && !wcscmp(buf, L"Platform.Type"), "got buf %s\n", debugstr_w(buf)); + WindowsDeleteString(str); + + equals = p_platform_type_Equals_Object(type_obj, type_obj); + todo_wine ok(equals, "got equals %d\n", equals); + equals = p_platform_type_Equals_Object(type_obj, NULL); + todo_wine ok(!equals, "got equals %d\n", equals); + + typecode = p_platform_type_GetTypeCode(type_obj); + todo_wine ok(typecode == 0xdeadbeef, "got typecode %d\n", typecode); + + str = p_platform_type_ToString(type_obj); + buf = WindowsGetStringRawBuffer(str, NULL); + todo_wine ok(buf && !wcscmp(buf, L"foo"), "got buf %s\n", debugstr_w(buf)); + WindowsDeleteString(str); + + str = p_platform_type_get_FullName(type_obj); + todo_wine ok(str != NULL, "got str %p\n", str); + buf = WindowsGetStringRawBuffer(str, NULL); + todo_wine ok(buf && !wcscmp(buf, L"foo"), "got buf %s != %s\n", debugstr_w(buf), debugstr_w(L"foo")); + WindowsDeleteString(str); + + type_obj2 = p___abi_make_type_id(&desc); + todo_wine ok(type_obj2 != NULL, "got type_obj %p\n", type_obj); + ok(type_obj2 != type_obj, "got type_obj2 %p\n", type_obj2); + + todo_wine check_interface(type_obj2, &IID_IInspectable); + todo_wine check_interface(type_obj2, &IID_IClosable); + todo_wine check_interface(type_obj2, &IID_IMarshal); + todo_wine check_interface(type_obj2, &IID_IAgileObject); + todo_wine check_interface(type_obj2, &IID_IEquatable); + todo_wine check_interface(type_obj2, &IID_IPrintable); + + equals = p_platform_type_Equals_Object(type_obj2, type_obj); + todo_wine ok(equals, "got equals %d\n", equals); + + count = IInspectable_Release(type_obj); + ok(count == 0, "got count %lu\n", count); + + equals = p_platform_type_Equals_Object(NULL, NULL); + todo_wine ok(equals, "got equals %d\n", equals); + + type_obj = p___abi_make_type_id(&desc2); + todo_wine ok(type_obj != NULL, "got type_obj %p\n", type_obj); + + /* Platform::Type::Equals only seems to compare the value of the __abi_type_descriptor pointer. */ + equals = p_platform_type_Equals_Object(type_obj, type_obj2); + todo_wine ok(!equals, "got equals %d\n", equals); + + count = IInspectable_Release(type_obj); + ok(count == 0, "got count %lu\n", count); + + type_obj = p___abi_make_type_id(&desc3); + todo_wine ok(type_obj != NULL, "got type_obj %p\n", type_obj); + + equals = p_platform_type_Equals_Object(type_obj, type_obj2); + todo_wine ok(!equals, "got equals %d\n", equals); + + typecode = p_platform_type_GetTypeCode(type_obj); + todo_wine ok(typecode == 1, "got typecode %d\n", typecode); + + str = p_platform_type_ToString(type_obj); + ok(str == NULL, "got str %s\n", debugstr_hstring(str)); + + str = p_platform_type_get_FullName(type_obj); + ok(str == NULL, "got str %s\n", debugstr_hstring(str)); + + count = IInspectable_Release(type_obj); + ok(count == 0, "got count %lu\n", count); + + count = IInspectable_Release(type_obj2); + ok(count == 0, "got count %lu\n", count); + + typecode = p_platform_type_GetTypeCode(NULL); + ok(typecode == 0, "got typecode %d\n", typecode); +} + START_TEST(vccorlib) { if(!init()) @@ -621,4 +785,5 @@ START_TEST(vccorlib) test_Allocate(); test_AllocateWithWeakRef_inline(); test_AllocateWithWeakRef(); + test___abi_make_type_id(); } diff --git a/dlls/vccorlib140/vccorlib.c b/dlls/vccorlib140/vccorlib.c index e225e7ce5a7..9cccd2533d6 100644 --- a/dlls/vccorlib140/vccorlib.c +++ b/dlls/vccorlib140/vccorlib.c @@ -225,3 +225,51 @@ void __thiscall control_block_ReleaseTarget(struct control_block *weakref) if ((object = InterlockedCompareExchangePointer((void *)&weakref->object, NULL, weakref->object))) Free(object); } + +struct __abi_type_descriptor +{ + const WCHAR *name; + int type_id; +}; + +static const char *debugstr_abi_type_descriptor(const struct __abi_type_descriptor *desc) +{ + if (!desc) return "(null)"; + + return wine_dbg_sprintf("{%s, %d}", debugstr_w(desc->name), desc->type_id); +} + +void *WINAPI __abi_make_type_id(const struct __abi_type_descriptor *desc) +{ + FIXME("(%s) stub\n", debugstr_abi_type_descriptor(desc)); + + return NULL; +} + +bool __cdecl platform_type_Equals_Object(void *this, void *object) +{ + FIXME("(%p, %p) stub\n", this, object); + + return false; +} + +int __cdecl platform_type_GetTypeCode(void *this) +{ + FIXME("(%p) stub\n", this); + + return 0; +} + +HSTRING __cdecl platform_type_ToString(void *this) +{ + FIXME("(%p) stub\n", this); + + return NULL; +} + +HSTRING __cdecl platform_type_get_FullName(void *type) +{ + FIXME("(%p) stub\n", type); + + return NULL; +} diff --git a/dlls/vccorlib140/vccorlib140.spec b/dlls/vccorlib140/vccorlib140.spec index 8ff8b9b09fc..97f2b4d3cc7 100644 --- a/dlls/vccorlib140/vccorlib140.spec +++ b/dlls/vccorlib140/vccorlib140.spec @@ -12,8 +12,8 @@ @ stub -arch=win64 ?Equals(a)OnePhaseConstructedAttribute@CompilerServices(a)Runtime@Platform@@QE$AAA_NPE$AAVObject(a)4@@Z @ stub -arch=win32 ?Equals(a)STAThreadAttribute@Platform@@Q$AAA_NP$AAVObject(a)2@@Z @ stub -arch=win64 ?Equals(a)STAThreadAttribute@Platform@@QE$AAA_NPE$AAVObject(a)2@@Z -@ stub -arch=win32 ?Equals(a)Type@Platform@@U$AAA_NP$AAVObject(a)2@@Z -@ stub -arch=win64 ?Equals(a)Type@Platform@@UE$AAA_NPE$AAVObject(a)2@@Z +@ cdecl -arch=win32 ?Equals(a)Type@Platform@@U$AAA_NP$AAVObject(a)2@@Z(ptr ptr) platform_type_Equals_Object +@ cdecl -arch=win64 ?Equals(a)Type@Platform@@UE$AAA_NPE$AAVObject(a)2@@Z(ptr ptr) platform_type_Equals_Object @ stub -arch=win32 ?Equals(a)ValueType@Platform@@Q$AAA_NP$AAVObject(a)2@@Z @ stub -arch=win64 ?Equals(a)ValueType@Platform@@QE$AAA_NPE$AAVObject(a)2@@Z @ stub -arch=win32 ?Equals(a)char16@default@@QAA_NP$AAVObject(a)Platform@@@Z @@ -177,8 +177,8 @@ @ stub -arch=win64 ?GetType(a)uint64@default@@QEAAPE$AAVType(a)Platform@@XZ @ stub -arch=win32 ?GetType(a)uint8@default@@QAAP$AAVType(a)Platform@@XZ @ stub -arch=win64 ?GetType(a)uint8@default@@QEAAPE$AAVType(a)Platform@@XZ -@ stub -arch=win32 ?GetTypeCode(a)Type@Platform@@SA?AW4TypeCode(a)2@P$AAV12@@Z -@ stub -arch=win64 ?GetTypeCode(a)Type@Platform@@SA?AW4TypeCode(a)2@PE$AAV12@@Z +@ cdecl -arch=win32 ?GetTypeCode(a)Type@Platform@@SA?AW4TypeCode(a)2@P$AAV12@@Z(ptr) platform_type_GetTypeCode +@ cdecl -arch=win64 ?GetTypeCode(a)Type@Platform@@SA?AW4TypeCode(a)2@PE$AAV12@@Z(ptr) platform_type_GetTypeCode @ stub -arch=i386 ?GetWeakReference(a)Details@Platform@@YGPAU__abi_IUnknown@@Q$ADVObject(a)2@@Z @ stub -arch=arm ?GetWeakReference(a)Details@Platform@@YAPAU__abi_IUnknown@@Q$ADVObject(a)2@@Z @ stub -arch=win64 ?GetWeakReference(a)Details@Platform@@YAPEAU__abi_IUnknown@@QE$ADVObject(a)2@@Z @@ -246,8 +246,8 @@ @ stub -arch=win64 ?<Dispose>@String(a)Platform@@UE$AAAXXZ @ stub -arch=win32 ??0FailureException(a)Platform@@Q$AAA(a)P$AAVString(a)1@@Z @ stub -arch=win64 ??0FailureException(a)Platform@@QE$AAA(a)PE$AAVString(a)1@@Z -@ stub -arch=win32 ?ToString(a)Type@Platform@@U$AAAP$AAVString(a)2@XZ -@ stub -arch=win64 ?ToString(a)Type@Platform@@UE$AAAPE$AAVString(a)2@XZ +@ cdecl -arch=win32 ?ToString(a)Type@Platform@@U$AAAP$AAVString(a)2@XZ(ptr) platform_type_ToString +@ cdecl -arch=win64 ?ToString(a)Type@Platform@@UE$AAAPE$AAVString(a)2@XZ(ptr) platform_type_ToString @ stub -arch=win32 ?ToString(a)ValueType@Platform@@Q$AAAP$AAVString(a)2@XZ @ stub -arch=win64 ?ToString(a)ValueType@Platform@@QE$AAAPE$AAVString(a)2@XZ @ stub -arch=win32 ?ToString(a)char16@default@@QAAP$AAVString(a)Platform@@XZ @@ -347,9 +347,9 @@ @ stub -arch=i386 ?__abi_cast_String_to_Object(a)__abi_details@@YGP$AAVObject(a)Platform@@P$AAVString(a)3@@Z @ stub -arch=arm ?__abi_cast_String_to_Object(a)__abi_details@@YAP$AAVObject(a)Platform@@P$AAVString(a)3@@Z @ stub -arch=win64 ?__abi_cast_String_to_Object(a)__abi_details@@YAPE$AAVObject(a)Platform@@PE$AAVString(a)3@@Z -@ stub -arch=i386 ?__abi_make_type_id@@YGP$AAVType(a)Platform@@ABU__abi_type_descriptor@@@Z -@ stub -arch=arm ?__abi_make_type_id@@YAP$AAVType(a)Platform@@ABU__abi_type_descriptor@@@Z -@ stub -arch=win64 ?__abi_make_type_id@@YAPE$AAVType(a)Platform@@AEBU__abi_type_descriptor@@@Z +@ stdcall -arch=i386 ?__abi_make_type_id@@YGP$AAVType(a)Platform@@ABU__abi_type_descriptor@@@Z(ptr) __abi_make_type_id +@ stdcall -arch=arm ?__abi_make_type_id@@YAP$AAVType(a)Platform@@ABU__abi_type_descriptor@@@Z(ptr) __abi_make_type_id +@ stdcall -arch=win64 ?__abi_make_type_id@@YAPE$AAVType(a)Platform@@AEBU__abi_type_descriptor@@@Z(ptr) __abi_make_type_id @ stub -arch=win32 ??0IntPtr(a)Platform@@QAA(a)PAX@Z @ stub -arch=win64 ??0IntPtr(a)Platform@@QEAA(a)PEAX@Z @ stub -arch=i386 ?__abi_translateCurrentException@@YGJ_N(a)Z @@ -365,8 +365,8 @@ @ stub ?get(a)CurrentAllocationId@Heap(a)Details@Platform@@SAHXZ @ stub ?get(a)Empty@Rect(a)Foundation@Windows@@SA?AV234(a)XZ @ stub ?get(a)Empty@Size(a)Foundation@Windows@@SA?AV234(a)XZ -@ stub -arch=win32 ?get(a)FullName@Type(a)Platform@@Q$AAAP$AAVString(a)3@XZ -@ stub -arch=win64 ?get(a)FullName@Type(a)Platform@@QE$AAAPE$AAVString(a)3@XZ +@ cdecl -arch=win32 ?get(a)FullName@Type(a)Platform@@Q$AAAP$AAVString(a)3@XZ(ptr) platform_type_get_FullName +@ cdecl -arch=win64 ?get(a)FullName@Type(a)Platform@@QE$AAAPE$AAVString(a)3@XZ(ptr) platform_type_get_FullName @ stub -arch=win32 ?get(a)HasInverse@Matrix3D(a)Media3D@Media(a)Xaml@UI(a)Windows@@QAA_NXZ @ stub -arch=win64 ?get(a)HasInverse@Matrix3D(a)Media3D@Media(a)Xaml@UI(a)Windows@@QEAA_NXZ @ stub -arch=win32 ??0InvalidArgumentException(a)Platform@@Q$AAA(a)P$AAVString(a)1@@Z -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8831