Adam Martinson : msxml3: Implement schema_cache_addCollection().

Alexandre Julliard julliard at winehq.org
Thu Oct 21 10:50:48 CDT 2010


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

Author: Adam Martinson <amartinson at codeweavers.com>
Date:   Wed Oct 20 16:36:50 2010 -0500

msxml3: Implement schema_cache_addCollection().

---

 dlls/msxml3/schema.c       |   25 +++++++++++++++++++++++--
 dlls/msxml3/tests/schema.c |   19 +++++++++++++++++--
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/dlls/msxml3/schema.c b/dlls/msxml3/schema.c
index 7eadd51..2df038f 100644
--- a/dlls/msxml3/schema.c
+++ b/dlls/msxml3/schema.c
@@ -474,10 +474,31 @@ static HRESULT WINAPI schema_cache_get_namespaceURI(IXMLDOMSchemaCollection *ifa
     return E_NOTIMPL;
 }
 
+static void cache_copy(void* data, void* dest, xmlChar* name)
+{
+    schema_cache* This = (schema_cache*) dest;
+    cache_entry* entry = (cache_entry*) data;
+
+    if (xmlHashLookup(This->cache, name) == NULL)
+    {
+        cache_entry_add_ref(entry);
+        xmlHashAddEntry(This->cache, name, entry);
+    }
+}
+
 static HRESULT WINAPI schema_cache_addCollection(IXMLDOMSchemaCollection *iface, IXMLDOMSchemaCollection *otherCollection)
 {
-    FIXME("stub\n");
-    return E_NOTIMPL;
+    schema_cache* This = impl_from_IXMLDOMSchemaCollection(iface);
+    schema_cache* That = impl_from_IXMLDOMSchemaCollection(otherCollection);
+    TRACE("(%p)->(%p)\n", This, That);
+
+    if (!otherCollection)
+        return E_POINTER;
+
+    /* TODO: detect errors while copying & return E_FAIL */
+    xmlHashScan(That->cache, cache_copy, This);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI schema_cache_get__newEnum(IXMLDOMSchemaCollection *iface, IUnknown **ppUnk)
diff --git a/dlls/msxml3/tests/schema.c b/dlls/msxml3/tests/schema.c
index ba99c28..0754a1b 100644
--- a/dlls/msxml3/tests/schema.c
+++ b/dlls/msxml3/tests/schema.c
@@ -324,6 +324,7 @@ static void test_collection_refs(void)
     IXMLDOMDocument2 *schema1, *schema2, *schema3;
     IXMLDOMSchemaCollection *cache1, *cache2, *cache3;
     VARIANT_BOOL b;
+    LONG length;
 
     schema1 = create_document(&IID_IXMLDOMDocument2);
     schema2 = create_document(&IID_IXMLDOMDocument2);
@@ -376,8 +377,22 @@ static void test_collection_refs(void)
     if (schema2) todo_wine check_refs(IXMLDOMDocument2, schema2, 1);
     if (schema3) todo_wine check_refs(IXMLDOMDocument2, schema3, 1);
 
-    todo_wine ole_check(IXMLDOMSchemaCollection_addCollection(cache2, cache1));
-    todo_wine ole_check(IXMLDOMSchemaCollection_addCollection(cache3, cache2));
+    ole_expect(IXMLDOMSchemaCollection_addCollection(cache1, NULL), E_POINTER);
+    ole_check(IXMLDOMSchemaCollection_addCollection(cache2, cache1));
+    ole_check(IXMLDOMSchemaCollection_addCollection(cache3, cache2));
+
+    length = -1;
+    ole_check(IXMLDOMSchemaCollection_get_length(cache1, &length));
+    ok(length == 1, "expected length 1, got %i", length);
+
+    length = -1;
+    ole_check(IXMLDOMSchemaCollection_get_length(cache2, &length));
+    ok(length == 2, "expected length 2, got %i", length);
+
+    length = -1;
+    ole_check(IXMLDOMSchemaCollection_get_length(cache3, &length));
+    ok(length == 3, "expected length 3, got %i", length);
+
 
     /* merging collections does not affect the ref count */
     check_refs(IXMLDOMSchemaCollection, cache1, 1);




More information about the wine-cvs mailing list