Nikolay Sivov : scrrun: Implement Item() property for dictionary.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 2 08:51:51 CST 2015


Module: wine
Branch: master
Commit: 1bc4c57e551e3d92ac2776d0e65d9a6d96a4acdd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1bc4c57e551e3d92ac2776d0e65d9a6d96a4acdd

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Feb 27 18:13:04 2015 +0300

scrrun: Implement Item() property for dictionary.

---

 dlls/scrrun/dictionary.c       | 24 ++++++++++++++++++------
 dlls/scrrun/tests/dictionary.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c
index 524485b..a7c90db 100644
--- a/dlls/scrrun/dictionary.c
+++ b/dlls/scrrun/dictionary.c
@@ -316,22 +316,34 @@ static HRESULT WINAPI dictionary_putref_Item(IDictionary *iface, VARIANT *Key, V
     return E_NOTIMPL;
 }
 
-static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem)
+static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *key, VARIANT *item)
 {
     dictionary *This = impl_from_IDictionary(iface);
+    struct keyitem_pair *pair;
 
-    FIXME("(%p)->(%p %p)\n", This, Key, pRetItem);
+    TRACE("(%p)->(%s %s)\n", This, debugstr_variant(key), debugstr_variant(item));
 
-    return E_NOTIMPL;
+    if ((pair = get_keyitem_pair(This, key)))
+        return VariantCopyInd(&pair->item, item);
+
+    return IDictionary_Add(iface, key, item);
 }
 
-static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem)
+static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *key, VARIANT *item)
 {
     dictionary *This = impl_from_IDictionary(iface);
+    struct keyitem_pair *pair;
 
-    FIXME("(%p)->(%p %p)\n", This, Key, pRetItem );
+    TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), item);
 
-    return E_NOTIMPL;
+    if ((pair = get_keyitem_pair(This, key)))
+        VariantCopy(item, &pair->item);
+    else {
+        VariantInit(item);
+        return IDictionary_Add(iface, key, item);
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI dictionary_Add(IDictionary *iface, VARIANT *key, VARIANT *item)
diff --git a/dlls/scrrun/tests/dictionary.c b/dlls/scrrun/tests/dictionary.c
index 066a5ab..c9e71a5 100644
--- a/dlls/scrrun/tests/dictionary.c
+++ b/dlls/scrrun/tests/dictionary.c
@@ -574,6 +574,34 @@ todo_wine
     IDictionary_Release(dict);
 }
 
+static void test_Item(void)
+{
+    VARIANT key, item;
+    IDictionary *dict;
+    HRESULT hr;
+
+    hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
+            &IID_IDictionary, (void**)&dict);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    V_VT(&key) = VT_I2;
+    V_I2(&key) = 10;
+    V_VT(&item) = VT_I2;
+    V_I2(&item) = 123;
+    hr = IDictionary_get_Item(dict, &key, &item);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(V_VT(&item) == VT_EMPTY, "got %d\n", V_VT(&item));
+
+    V_VT(&key) = VT_I2;
+    V_I2(&key) = 10;
+    V_VT(&item) = VT_I2;
+    hr = IDictionary_get_Item(dict, &key, &item);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(V_VT(&item) == VT_EMPTY, "got %d\n", V_VT(&item));
+
+    IDictionary_Release(dict);
+}
+
 START_TEST(dictionary)
 {
     IDispatch *disp;
@@ -596,6 +624,7 @@ START_TEST(dictionary)
     test_Exists();
     test_Keys();
     test_Remove();
+    test_Item();
 
     CoUninitialize();
 }




More information about the wine-cvs mailing list