[3/3] scrrun: Implement IDictionary Exists
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Fri Oct 5 04:32:11 CDT 2012
Hi,
Changelog:
scrrun: Implement IDictionary Exists
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 79289659bf8ff2a17bbb888e079be986f1a09865 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri, 5 Oct 2012 12:01:13 +1000
Subject: [PATCH] Implement IDictionary Exists
To: wine-patches <wine-patches at winehq.org>
---
dlls/scrrun/dictionary.c | 25 +++++++++++++++++++++++--
dlls/scrrun/tests/dictionary.c | 18 ++++++++++++++----
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c
index fbd007e..ec80745 100644
--- a/dlls/scrrun/dictionary.c
+++ b/dlls/scrrun/dictionary.c
@@ -32,6 +32,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
+#define ERR_DUPLICATE_ITEM 0x800a01c9
typedef struct dictitem
{
@@ -249,9 +250,14 @@ static HRESULT WINAPI dictionary_Add(IDictionary *iface, VARIANT *Key, VARIANT *
{
dictionary *This = impl_from_IDictionary(iface);
struct dictitem *newitem;
+ VARIANT_BOOL exists;
TRACE("(%p)->(%s %s)\n", This, debugstr_variant(Key), debugstr_variant(Item));
+ IDictionary_Exists(iface, Key, &exists);
+ if(exists == VARIANT_TRUE)
+ return ERR_DUPLICATE_ITEM;
+
newitem = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dictitem));
if(!newitem)
return E_OUTOFMEMORY;
@@ -280,11 +286,26 @@ static HRESULT WINAPI dictionary_get_Count(IDictionary *iface, LONG *pCount)
static HRESULT WINAPI dictionary_Exists(IDictionary *iface, VARIANT *Key, VARIANT_BOOL *pExists)
{
+ struct dictitem *cursor, *cursor2;
dictionary *This = impl_from_IDictionary(iface);
+ LCID lcid;
- FIXME("(%p)->(%p %p)\n", This, Key, pExists);
+ TRACE("(%p)->(%s %p)\n", This, debugstr_variant(Key), pExists);
- return E_NOTIMPL;
+ *pExists = VARIANT_FALSE;
+
+ lcid = GetUserDefaultLCID();
+
+ LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->items, struct dictitem, entry)
+ {
+ if(VarCmp(&cursor->name, Key, lcid, 0) == VARCMP_EQ)
+ {
+ *pExists = VARIANT_TRUE;
+ break;
+ }
+ }
+
+ return S_OK;
}
static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *pItemsArray)
diff --git a/dlls/scrrun/tests/dictionary.c b/dlls/scrrun/tests/dictionary.c
index d32d8a1..08c74ab 100644
--- a/dlls/scrrun/tests/dictionary.c
+++ b/dlls/scrrun/tests/dictionary.c
@@ -28,6 +28,8 @@
#include "scrrun.h"
+#define ERR_DUPLICATE_ITEM 0x800a01c9
+
static void test_interfaces(void)
{
static const WCHAR key_add[] = {'a', 0};
@@ -69,6 +71,14 @@ static void test_interfaces(void)
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
VariantClear(&value);
+ V_VT(&key) = VT_BSTR;
+ V_BSTR(&key) = SysAllocString(key_add);
+ V_VT(&value) = VT_BSTR;
+ V_BSTR(&value) = SysAllocString(key_add_value);
+ hr = IDictionary_Add(dict, &key, &value);
+ ok(hr == ERR_DUPLICATE_ITEM, "got 0x%08x, expected 0x%08x\n", hr, ERR_DUPLICATE_ITEM);
+ VariantClear(&value);
+
/* The following tests crash under windows */
#if 0
hr = IDictionary_Add(dict, NULL, &value);
@@ -80,16 +90,16 @@ static void test_interfaces(void)
exists = VARIANT_FALSE;
hr = IDictionary_Exists(dict, &key, &exists);
- todo_wine ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
- todo_wine ok(exists == VARIANT_TRUE, "Expected TRUE but got FALSE.\n");
+ ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
+ ok(exists == VARIANT_TRUE, "Expected TRUE but got FALSE.\n");
VariantClear(&key);
exists = VARIANT_TRUE;
V_VT(&key) = VT_BSTR;
V_BSTR(&key) = SysAllocString(key_non_exist);
hr = IDictionary_Exists(dict, &key, &exists);
- todo_wine ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
- todo_wine ok(exists == VARIANT_FALSE, "Expected FALSE but got TRUE.\n");
+ ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
+ ok(exists == VARIANT_FALSE, "Expected FALSE but got TRUE.\n");
VariantClear(&key);
hr = IDictionary_get_Count(dict, &count);
--
1.7.9.5
More information about the wine-patches
mailing list