From f70ddf76140fd808996c726d1ce3495081f78467 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 23 Mar 2015 08:19:12 +0300 Subject: [PATCH] scrrun: Support BYREF types for integer keys. --- dlls/scrrun/dictionary.c | 9 ++++++--- dlls/scrrun/tests/dictionary.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c index 2dc5d2cbdc5..cce8a37160a 100644 --- a/dlls/scrrun/dictionary.c +++ b/dlls/scrrun/dictionary.c @@ -795,14 +795,17 @@ static HRESULT WINAPI dictionary_get_HashVal(IDictionary *iface, VARIANT *key, V case VT_BSTR: V_I4(hash) = get_str_hash(get_key_strptr(key), This->method); break; + case VT_UI1|VT_BYREF: case VT_UI1: - V_I4(hash) = get_num_hash(V_UI1(key)); + V_I4(hash) = get_num_hash(V_VT(key) & VT_BYREF ? *V_UI1REF(key) : V_UI1(key)); break; + case VT_I2|VT_BYREF: case VT_I2: - V_I4(hash) = get_num_hash(V_I2(key)); + V_I4(hash) = get_num_hash(V_VT(key) & VT_BYREF ? *V_I2REF(key) : V_I2(key)); break; + case VT_I4|VT_BYREF: case VT_I4: - V_I4(hash) = get_num_hash(V_I4(key)); + V_I4(hash) = get_num_hash(V_VT(key) & VT_BYREF ? *V_I4REF(key) : V_I4(key)); break; case VT_UNKNOWN|VT_BYREF: case VT_DISPATCH|VT_BYREF: diff --git a/dlls/scrrun/tests/dictionary.c b/dlls/scrrun/tests/dictionary.c index f53222fc6e2..e1c80f91f64 100644 --- a/dlls/scrrun/tests/dictionary.c +++ b/dlls/scrrun/tests/dictionary.c @@ -429,6 +429,10 @@ static void test_hash_value(void) ok(V_I4(&hash) == ~0u, "got hash 0x%08x\n", V_I4(&hash)); for (i = 0; i < sizeof(int_hash_tests)/sizeof(int_hash_tests[0]); i++) { + SHORT i2; + BYTE ui1; + LONG i4; + expected = get_num_hash(int_hash_tests[i]); V_VT(&key) = VT_I2; @@ -440,6 +444,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); + i2 = int_hash_tests[i]; + V_VT(&key) = VT_I2|VT_BYREF; + V_I2REF(&key) = &i2; + 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_I4; V_I4(&key) = int_hash_tests[i]; VariantInit(&hash); @@ -449,6 +463,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); + i4 = int_hash_tests[i]; + V_VT(&key) = VT_I4|VT_BYREF; + V_I4REF(&key) = &i4; + 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); + expected = get_num_hash((FLOAT)(BYTE)int_hash_tests[i]); V_VT(&key) = VT_UI1; V_UI1(&key) = int_hash_tests[i]; @@ -458,6 +482,16 @@ 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); + + ui1 = int_hash_tests[i]; + V_VT(&key) = VT_UI1|VT_BYREF; + V_UI1REF(&key) = &ui1; + 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); } /* nan */