From: Vibhav Pant vibhavp@gmail.com
--- dlls/vccorlib140/tests/vccorlib.c | 6 +++--- dlls/vccorlib140/vccorlib.c | 36 ++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/dlls/vccorlib140/tests/vccorlib.c b/dlls/vccorlib140/tests/vccorlib.c index 3862c9ca0ff..64a99e06151 100644 --- a/dlls/vccorlib140/tests/vccorlib.c +++ b/dlls/vccorlib140/tests/vccorlib.c @@ -1109,7 +1109,7 @@ static void test___abi_make_type_id(void) check_interface(type_obj, &IID_IMarshal); check_interface(type_obj, &IID_IAgileObject); todo_wine check_interface(type_obj, &IID_IEquatable); - todo_wine check_interface(type_obj, &IID_IPrintable); + check_interface(type_obj, &IID_IPrintable);
hr = IInspectable_GetRuntimeClassName(type_obj, &str); ok(hr == S_OK, "got hr %#lx\n", hr); @@ -1143,7 +1143,7 @@ static void test___abi_make_type_id(void)
str = p__abi_ObjectToString(type_obj, TRUE); buf = WindowsGetStringRawBuffer(str, NULL); - todo_wine ok(buf && !wcscmp(buf, L"foo"), "got buf %s != %s\n", debugstr_w(buf), debugstr_w(L"foo")); + 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); @@ -1179,7 +1179,7 @@ static void test___abi_make_type_id(void) check_interface(type_obj2, &IID_IMarshal); check_interface(type_obj2, &IID_IAgileObject); todo_wine check_interface(type_obj2, &IID_IEquatable); - todo_wine check_interface(type_obj2, &IID_IPrintable); + check_interface(type_obj2, &IID_IPrintable);
equals = p_platform_type_Equals_Object(type_obj2, type_obj); ok(equals, "got equals %d\n", equals); diff --git a/dlls/vccorlib140/vccorlib.c b/dlls/vccorlib140/vccorlib.c index e1652502e74..7704716eb97 100644 --- a/dlls/vccorlib140/vccorlib.c +++ b/dlls/vccorlib140/vccorlib.c @@ -305,6 +305,7 @@ struct __abi_type_descriptor struct platform_type { IInspectable IInspectable_iface; + IStringable IPrintable_iface; IClosable IClosable_iface; IUnknown *marshal; const struct __abi_type_descriptor *desc; @@ -329,6 +330,11 @@ HRESULT WINAPI platform_type_QueryInterface(IInspectable *iface, const GUID *iid IInspectable_AddRef((*out = &impl->IInspectable_iface)); return S_OK; } + if (IsEqualGUID(iid, &IID_IPrintable)) + { + IStringable_AddRef((*out = &impl->IPrintable_iface)); + return S_OK; + } if (IsEqualGUID(iid, &IID_IClosable)) { IClosable_AddRef((*out = &impl->IClosable_iface)); @@ -394,6 +400,29 @@ COM_VTABLE_ENTRY(platform_type_GetRuntimeClassName) COM_VTABLE_ENTRY(platform_type_GetTrustLevel) COM_VTABLE_RTTI_END;
+DEFINE_IINSPECTABLE_(platform_type_printable, IStringable, struct platform_type, + impl_platform_type_from_IStringable, IPrintable_iface, &impl->IInspectable_iface); + +static HRESULT WINAPI platform_type_printable_ToString(IStringable *iface, HSTRING *str) +{ + struct platform_type *impl = impl_platform_type_from_IStringable(iface); + + TRACE("(%p, %p)\n", iface, str); + + return WindowsCreateString(impl->desc->name, impl->desc->name ? wcslen(impl->desc->name ) : 0, str); +} + +DEFINE_RTTI_DATA(platform_type_printable, offsetof(struct platform_type, IPrintable_iface), ".?AVType@Platform@@"); +COM_VTABLE_RTTI_START(IStringable, platform_type_printable) +COM_VTABLE_ENTRY(platform_type_printable_QueryInterface) +COM_VTABLE_ENTRY(platform_type_printable_AddRef) +COM_VTABLE_ENTRY(platform_type_printable_Release) +COM_VTABLE_ENTRY(platform_type_printable_GetIids) +COM_VTABLE_ENTRY(platform_type_printable_GetRuntimeClassName) +COM_VTABLE_ENTRY(platform_type_printable_GetTrustLevel) +COM_VTABLE_ENTRY(platform_type_printable_ToString) +COM_VTABLE_RTTI_END; + DEFINE_IINSPECTABLE(platform_type_closable, IClosable, struct platform_type, IInspectable_iface);
static HRESULT WINAPI platform_type_closable_Close(IClosable *iface) @@ -417,6 +446,7 @@ static void init_platform_type(void *base) { INIT_RTTI(type_info, base); INIT_RTTI(platform_type, base); + INIT_RTTI(platform_type_printable, base); INIT_RTTI(platform_type_closable, base); }
@@ -430,7 +460,7 @@ static const char *debugstr_abi_type_descriptor(const struct __abi_type_descript void *WINAPI __abi_make_type_id(const struct __abi_type_descriptor *desc) { /* TODO: - * Implement IEquatable and IPrintable. */ + * Implement IEquatable. */ struct platform_type *obj; HRESULT hr;
@@ -438,6 +468,7 @@ void *WINAPI __abi_make_type_id(const struct __abi_type_descriptor *desc)
obj = Allocate(sizeof(*obj)); obj->IInspectable_iface.lpVtbl = &platform_type_vtable.vtable; + obj->IPrintable_iface.lpVtbl = &platform_type_printable_vtable.vtable; obj->IClosable_iface.lpVtbl = &platform_type_closable_vtable.vtable; obj->desc = desc; obj->ref = 1; @@ -471,8 +502,7 @@ HSTRING __cdecl platform_type_ToString(struct platform_type *this)
TRACE("(%p)\n", this);
- hr = WindowsCreateString(this->desc->name, this->desc->name ? wcslen(this->desc->name) : 0, &str); - if (FAILED(hr)) + if (FAILED(hr = IStringable_ToString(&this->IPrintable_iface, &str))) __abi_WinRTraiseCOMException(hr); return str; }