Module: wine Branch: master Commit: 94a1838b7ebb416b1cbbf0adb20f3199a0bf5a30 URL: http://source.winehq.org/git/wine.git/?a=commit;h=94a1838b7ebb416b1cbbf0adb2...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Mon Mar 23 08:18:30 2015 +0300
scrrun: Added support for VT_DATE keys, and BYREF float key types.
---
dlls/scrrun/dictionary.c | 38 +++++++++++++++----------- dlls/scrrun/tests/dictionary.c | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 15 deletions(-)
diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c index 24ca094..2dc5d2c 100644 --- a/dlls/scrrun/dictionary.c +++ b/dlls/scrrun/dictionary.c @@ -761,6 +761,22 @@ static DWORD get_num_hash(FLOAT num) return (*((DWORD*)&num)) % DICT_HASH_MOD; }
+static HRESULT get_flt_hash(FLOAT flt, LONG *hash) +{ + if (isinf(flt)) { + *hash = 0; + return S_OK; + } + else if (!isnan(flt)) { + *hash = get_num_hash(flt); + return S_OK; + } + + /* NaN case */ + *hash = ~0u; + return CTL_E_ILLEGALFUNCTIONCALL; +} + static DWORD get_ptr_hash(void *ptr) { return PtrToUlong(ptr) % DICT_HASH_MOD; @@ -810,23 +826,15 @@ static HRESULT WINAPI dictionary_get_HashVal(IDictionary *iface, VARIANT *key, V IUnknown_Release(unk); break; } + case VT_DATE|VT_BYREF: + case VT_DATE: + return get_flt_hash(V_VT(key) & VT_BYREF ? *V_DATEREF(key) : V_DATE(key), &V_I4(hash)); + case VT_R4|VT_BYREF: case VT_R4: + return get_flt_hash(V_VT(key) & VT_BYREF ? *V_R4REF(key) : V_R4(key), &V_I4(hash)); + case VT_R8|VT_BYREF: case VT_R8: - { - FLOAT flt = V_VT(key) == VT_R4 ? V_R4(key) : V_R8(key); - - if (isinf(flt)) - { - V_I4(hash) = 0; - break; - } - else if (!isnan(flt)) - { - V_I4(hash) = get_num_hash(flt); - break; - } - /* fallthrough on NAN */ - } + return get_flt_hash(V_VT(key) & VT_BYREF ? *V_R8REF(key) : V_R8(key), &V_I4(hash)); case VT_INT: case VT_UINT: case VT_I1: diff --git a/dlls/scrrun/tests/dictionary.c b/dlls/scrrun/tests/dictionary.c index de65310..f53222f 100644 --- a/dlls/scrrun/tests/dictionary.c +++ b/dlls/scrrun/tests/dictionary.c @@ -499,6 +499,15 @@ static void test_hash_value(void) ok(V_I4(&hash) == ~0u || broken(V_I4(&hash) == 0 /* win2k */ || V_I4(&hash) == 0x1f4 /* vista, win2k8 */), "got hash 0x%08x\n", V_I4(&hash));
+ V_VT(&key) = VT_DATE; + V_DATE(&key) = fx8.d; + VariantInit(&hash); + hr = IDictionary_get_HashVal(dict, &key, &hash); + ok(hr == CTL_E_ILLEGALFUNCTIONCALL || broken(hr == S_OK) /* win2k, win2k3 */, "got 0x%08x\n", hr); + ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); + ok(V_I4(&hash) == ~0u || broken(V_I4(&hash) == 0 /* win2k */ || + V_I4(&hash) == 0x1f4 /* vista, win2k8 */), "got hash 0x%08x\n", V_I4(&hash)); + /* inf */ fx8.d = 10.0; fx8.i.m_lo = 0; @@ -513,7 +522,19 @@ static void test_hash_value(void) ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); ok(V_I4(&hash) == 0, "got hash 0x%08x\n", V_I4(&hash));
+ V_VT(&key) = VT_DATE; + V_DATE(&key) = fx8.d; + V_I4(&hash) = 10; + hr = IDictionary_get_HashVal(dict, &key, &hash); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); + ok(V_I4(&hash) == 0, "got hash 0x%08x\n", V_I4(&hash)); + for (i = 0; i < sizeof(float_hash_tests)/sizeof(float_hash_tests[0]); i++) { + double dbl; + FLOAT flt; + DATE date; + expected = get_num_hash(float_hash_tests[i]);
V_VT(&key) = VT_R4; @@ -525,6 +546,16 @@ static void test_hash_value(void) ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash), expected);
+ flt = float_hash_tests[i]; + V_VT(&key) = VT_R4|VT_BYREF; + V_R4REF(&key) = &flt; + VariantInit(&hash); + hr = IDictionary_get_HashVal(dict, &key, &hash); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); + ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash), + expected); + V_VT(&key) = VT_R8; V_R8(&key) = float_hash_tests[i]; VariantInit(&hash); @@ -533,6 +564,35 @@ static void test_hash_value(void) ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash), expected); + + dbl = float_hash_tests[i]; + V_VT(&key) = VT_R8|VT_BYREF; + V_R8REF(&key) = &dbl; + VariantInit(&hash); + hr = IDictionary_get_HashVal(dict, &key, &hash); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); + ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash), + expected); + + V_VT(&key) = VT_DATE; + V_DATE(&key) = float_hash_tests[i]; + VariantInit(&hash); + hr = IDictionary_get_HashVal(dict, &key, &hash); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); + ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash), + expected); + + V_VT(&key) = VT_DATE|VT_BYREF; + date = float_hash_tests[i]; + V_DATEREF(&key) = &date; + VariantInit(&hash); + hr = IDictionary_get_HashVal(dict, &key, &hash); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(V_VT(&hash) == VT_I4, "got %d\n", V_VT(&hash)); + ok(V_I4(&hash) == expected, "%d: got hash 0x%08x, expected 0x%08x\n", i, V_I4(&hash), + expected); }
/* interface pointers as keys */