scrrun: Support BYREF types for integer keys.

This commit is contained in:
Nikolay Sivov 2015-03-23 08:19:12 +03:00 committed by Alexandre Julliard
parent 94a1838b7e
commit f70ddf7614
2 changed files with 40 additions and 3 deletions

View File

@ -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:

View File

@ -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 */