scrrun/dictionary: Implement putref_Item() method.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56781
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-06-05 11:52:49 +02:00 committed by Alexandre Julliard
parent b6fb9e5c5c
commit 0da33d5493
2 changed files with 50 additions and 5 deletions

View file

@ -559,11 +559,17 @@ static HRESULT WINAPI dictionary_Invoke(IDictionary *iface, DISPID dispIdMember,
return hr;
}
static HRESULT WINAPI dictionary_putref_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem)
static HRESULT WINAPI dictionary_putref_Item(IDictionary *iface, VARIANT *key, VARIANT *item)
{
FIXME("%p, %p, %p stub\n", iface, Key, pRetItem);
struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair;
return E_NOTIMPL;
TRACE("%p, %s, %s.\n", iface, debugstr_variant(key), debugstr_variant(item));
if ((pair = get_keyitem_pair(dictionary, key)))
return VariantCopyInd(&pair->item, item);
return add_keyitem_pair(dictionary, key, item);
}
static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *key, VARIANT *item)
@ -576,7 +582,7 @@ static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *key, VARI
if ((pair = get_keyitem_pair(dictionary, key)))
return VariantCopyInd(&pair->item, item);
return IDictionary_Add(iface, key, item);
return add_keyitem_pair(dictionary, key, item);
}
static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *key, VARIANT *item)

View file

@ -243,7 +243,6 @@ static HRESULT WINAPI test_unk_no_QI(IUnknown *iface, REFIID riid, void **obj)
static ULONG WINAPI test_unk_AddRef(IUnknown *iface)
{
ok(0, "unexpected\n");
return 2;
}
@ -1168,6 +1167,45 @@ static void test_IEnumVARIANT(void)
IDictionary_Release(dict);
}
static void test_putref_Item(void)
{
IUnknown *obj = &test_unk;
VARIANT key, item, item2;
IDictionary *dict;
HRESULT hr;
hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IDictionary, (void **)&dict);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
V_VT(&key) = VT_I2;
V_I2(&key) = 10;
V_VT(&item) = VT_UNKNOWN;
V_UNKNOWN(&item) = obj;
hr = IDictionary_putref_Item(dict, &key, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
VariantInit(&item2);
hr = IDictionary_get_Item(dict, &key, &item2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(V_VT(&item2) == VT_UNKNOWN, "Unexpected type.\n");
ok(V_UNKNOWN(&item2) == obj, "Unexpected value.\n");
VariantClear(&item2);
V_VT(&key) = VT_I2;
V_I2(&key) = 11;
V_VT(&item) = VT_UNKNOWN|VT_BYREF;
V_UNKNOWNREF(&item) = &obj;
hr = IDictionary_putref_Item(dict, &key, &item);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IDictionary_get_Item(dict, &key, &item2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(V_VT(&item2) == VT_UNKNOWN, "Unexpected type.\n");
ok(V_UNKNOWN(&item2) == obj, "Unexpected value.\n");
IDictionary_Release(dict);
}
START_TEST(dictionary)
{
IDispatch *disp;
@ -1193,6 +1231,7 @@ START_TEST(dictionary)
test_Item();
test_Add();
test_IEnumVARIANT();
test_putref_Item();
CoUninitialize();
}