From: Vibhav Pant vibhavp@gmail.com
--- dlls/vccorlib140/tests/vccorlib.c | 28 +++--- dlls/vccorlib140/vccorlib.c | 147 ++++++++++++++++++++++++------ 2 files changed, 135 insertions(+), 40 deletions(-)
diff --git a/dlls/vccorlib140/tests/vccorlib.c b/dlls/vccorlib140/tests/vccorlib.c index cc1c3a4ed01..a19f6f86d2a 100644 --- a/dlls/vccorlib140/tests/vccorlib.c +++ b/dlls/vccorlib140/tests/vccorlib.c @@ -2141,36 +2141,36 @@ static void test_ToString(void) HSTRING str;
str = p_uint64_ToString(&uint64); - todo_wine test_hstring(str, L"16045690984833335023"); + test_hstring(str, L"16045690984833335023"); str = p_int64_ToString(&int64); - todo_wine test_hstring(str, L"-2401053088876216593"); + test_hstring(str, L"-2401053088876216593"); str = p_float64_ToString(&float64); - todo_wine test_hstring(str, L"2.71828"); + test_hstring(str, L"2.71828"); str = p_float32_ToString(&float32); - todo_wine test_hstring(str, L"2.71828"); + test_hstring(str, L"2.71828"); str = p_uint32_ToString(&uint32); - todo_wine test_hstring(str, L"3735928559"); + test_hstring(str, L"3735928559"); str = p_int32_ToString(&int32); - todo_wine test_hstring(str, L"-559038737"); + test_hstring(str, L"-559038737"); str = p_uint16_ToString(&uint16); - todo_wine test_hstring(str, L"48879"); + test_hstring(str, L"48879"); str = p_int16_ToString(&int16); - todo_wine test_hstring(str, L"-16657"); + test_hstring(str, L"-16657"); str = p_int8_ToString(&int8); - todo_wine test_hstring(str, L"-1"); + test_hstring(str, L"-1"); str = p_uint8_ToString(&uint8); - todo_wine test_hstring(str, L"255"); + test_hstring(str, L"255"); str = p_char16_ToString(&char16); - todo_wine test_hstring(str, L"a"); + test_hstring(str, L"a");
str = p_Boolean_ToString(&bool_val); - todo_wine test_hstring(str, L"true"); + test_hstring(str, L"true"); bool_val = false; str = p_Boolean_ToString(&bool_val); - todo_wine test_hstring(str, L"false"); + test_hstring(str, L"false");
str = p_Guid_ToString(&guid); - todo_wine test_hstring(str, L"{af86e2e0-b12d-4c6a-9c5a-d7aa65101e90}"); + test_hstring(str, L"{af86e2e0-b12d-4c6a-9c5a-d7aa65101e90}"); }
START_TEST(vccorlib) diff --git a/dlls/vccorlib140/vccorlib.c b/dlls/vccorlib140/vccorlib.c index b875801176b..85ec1a2ef27 100644 --- a/dlls/vccorlib140/vccorlib.c +++ b/dlls/vccorlib140/vccorlib.c @@ -617,82 +617,177 @@ HSTRING WINAPI __abi_ObjectToString(IUnknown *obj, bool try_stringable) return NULL; }
+static HRESULT hstring_sprintf(HSTRING *out, const WCHAR *fmt, ...) +{ + WCHAR buf[100]; + va_list args; + int len; + + va_start(args, fmt); + len = vswprintf(buf, ARRAY_SIZE(buf), fmt, args); + va_end(args); + return WindowsCreateString(buf, len, out); +} + HSTRING __cdecl Guid_ToString(const GUID *this) { - FIXME("(%s): stub!\n", debugstr_guid(this)); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%s)\n", debugstr_guid(this)); + + hr = hstring_sprintf(&str, L"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", this->Data1, this->Data2, + this->Data3, this->Data4[0], this->Data4[1], this->Data4[2], this->Data4[3], this->Data4[4], + this->Data4[5], this->Data4[6], this->Data4[7]); + if (FAILED(hr)) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl Boolean_ToString(const boolean *this) { - FIXME("(%p): stub!\n", this); - return NULL; + const WCHAR *strW; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + strW = *this ? L"true" : L"false"; + if (FAILED((hr = WindowsCreateString(strW, wcslen(strW), &str)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl char16_ToString(const WCHAR *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p): stub!\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%c", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl float32_ToString(const FLOAT *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%g", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl float64_ToString(const DOUBLE *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%g", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl int16_ToString(const INT16 *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%hd", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl int32_ToString(const INT32 *this) { - FIXME("(%p): stub\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%I32d", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl int64_ToString(const INT64 *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%I64d", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl int8_ToString(const INT8 *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%hhd", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl uint16_ToString(const UINT16 *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%hu", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl uint32_ToString(const UINT32 *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%I32u", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl uint64_ToString(const UINT64 *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%I64u", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
HSTRING __cdecl uint8_ToString(const UINT8 *this) { - FIXME("(%p): stub!\n", this); - return NULL; + HSTRING str; + HRESULT hr; + + TRACE("(%p)\n", this); + + if (FAILED((hr = hstring_sprintf(&str, L"%hhu", *this)))) + __abi_WinRTraiseCOMException(hr); + return str; }
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)