Commit 892b2108 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Implement _newEnum() for schema cache.

parent 03ad0acf
...@@ -259,7 +259,7 @@ struct nodemap_funcs ...@@ -259,7 +259,7 @@ struct nodemap_funcs
/* used by IEnumVARIANT to access outer object items */ /* used by IEnumVARIANT to access outer object items */
struct enumvariant_funcs struct enumvariant_funcs
{ {
HRESULT (*get_item)(IUnknown*, LONG, IDispatch**); HRESULT (*get_item)(IUnknown*, LONG, VARIANT*);
HRESULT (*next)(IUnknown*); HRESULT (*next)(IUnknown*);
}; };
......
...@@ -62,9 +62,10 @@ typedef struct ...@@ -62,9 +62,10 @@ typedef struct
IEnumVARIANT *enumvariant; IEnumVARIANT *enumvariant;
} xmlnodelist; } xmlnodelist;
static HRESULT nodelist_get_item(IUnknown *iface, LONG index, IDispatch** item) static HRESULT nodelist_get_item(IUnknown *iface, LONG index, VARIANT *item)
{ {
return IXMLDOMNodeList_get_item((IXMLDOMNodeList*)iface, index, (IXMLDOMNode**)item); V_VT(item) = VT_DISPATCH;
return IXMLDOMNodeList_get_item((IXMLDOMNodeList*)iface, index, (IXMLDOMNode**)&V_DISPATCH(item));
} }
static const struct enumvariant_funcs nodelist_enumvariant = { static const struct enumvariant_funcs nodelist_enumvariant = {
......
...@@ -288,6 +288,17 @@ static void validate_serror(void* ctx, xmlErrorPtr err) ...@@ -288,6 +288,17 @@ static void validate_serror(void* ctx, xmlErrorPtr err)
} }
#endif #endif
static HRESULT schema_cache_get_item(IUnknown *iface, LONG index, VARIANT *item)
{
V_VT(item) = VT_BSTR;
return IXMLDOMSchemaCollection2_get_namespaceURI((IXMLDOMSchemaCollection2*)iface, index, &V_BSTR(item));
}
static const struct enumvariant_funcs schemacache_enumvariant = {
schema_cache_get_item,
NULL
};
static inline HRESULT Schema_validate_tree(xmlSchemaPtr schema, xmlNodePtr tree) static inline HRESULT Schema_validate_tree(xmlSchemaPtr schema, xmlNodePtr tree)
{ {
xmlSchemaValidCtxtPtr svctx; xmlSchemaValidCtxtPtr svctx;
...@@ -1327,14 +1338,11 @@ static HRESULT WINAPI schema_cache_addCollection(IXMLDOMSchemaCollection2* iface ...@@ -1327,14 +1338,11 @@ static HRESULT WINAPI schema_cache_addCollection(IXMLDOMSchemaCollection2* iface
return S_OK; return S_OK;
} }
static HRESULT WINAPI schema_cache_get__newEnum(IXMLDOMSchemaCollection2* iface, static HRESULT WINAPI schema_cache_get__newEnum(IXMLDOMSchemaCollection2* iface, IUnknown** enumv)
IUnknown** ppUnk)
{ {
schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface); schema_cache* This = impl_from_IXMLDOMSchemaCollection2(iface);
FIXME("(%p)->(%p): stub\n", This, ppUnk); TRACE("(%p)->(%p)\n", This, enumv);
if (ppUnk) return create_enumvariant((IUnknown*)iface, TRUE, &schemacache_enumvariant, (IEnumVARIANT**)enumv);
*ppUnk = NULL;
return E_NOTIMPL;
} }
static HRESULT WINAPI schema_cache_validate(IXMLDOMSchemaCollection2* iface) static HRESULT WINAPI schema_cache_validate(IXMLDOMSchemaCollection2* iface)
......
...@@ -83,9 +83,10 @@ typedef struct ...@@ -83,9 +83,10 @@ typedef struct
IEnumVARIANT *enumvariant; IEnumVARIANT *enumvariant;
} domselection; } domselection;
static HRESULT selection_get_item(IUnknown *iface, LONG index, IDispatch** item) static HRESULT selection_get_item(IUnknown *iface, LONG index, VARIANT* item)
{ {
return IXMLDOMSelection_get_item((IXMLDOMSelection*)iface, index, (IXMLDOMNode**)item); V_VT(item) = VT_DISPATCH;
return IXMLDOMSelection_get_item((IXMLDOMSelection*)iface, index, (IXMLDOMNode**)&V_DISPATCH(item));
} }
static HRESULT selection_next(IUnknown *iface) static HRESULT selection_next(IUnknown *iface)
...@@ -510,15 +511,12 @@ static HRESULT WINAPI enumvariant_Next( ...@@ -510,15 +511,12 @@ static HRESULT WINAPI enumvariant_Next(
for (; celt > 0; celt--, var++, This->pos++) for (; celt > 0; celt--, var++, This->pos++)
{ {
IDispatch *disp = NULL; HRESULT hr = This->funcs->get_item(This->outer, This->pos, var);
HRESULT hr; if (hr != S_OK)
{
hr = This->funcs->get_item(This->outer, This->pos, &disp); V_VT(var) = VT_EMPTY;
if (hr != S_OK) break; break;
}
V_VT(var) = VT_DISPATCH;
V_DISPATCH(var) = disp;
ret_count++; ret_count++;
} }
......
...@@ -11700,7 +11700,8 @@ static void test_get_namespaces(void) ...@@ -11700,7 +11700,8 @@ static void test_get_namespaces(void)
{ {
IXMLDOMSchemaCollection *collection, *collection2; IXMLDOMSchemaCollection *collection, *collection2;
IXMLDOMDocument2 *doc, *doc2; IXMLDOMDocument2 *doc, *doc2;
IEnumVARIANT *enumv; IEnumVARIANT *enumv, *enum2;
IUnknown *unk1, *unk2;
IXMLDOMNode *node; IXMLDOMNode *node;
VARIANT_BOOL b; VARIANT_BOOL b;
HRESULT hr; HRESULT hr;
...@@ -11789,34 +11790,43 @@ static void test_get_namespaces(void) ...@@ -11789,34 +11790,43 @@ static void test_get_namespaces(void)
/* enumerate */ /* enumerate */
enumv = (void*)0xdeadbeef; enumv = (void*)0xdeadbeef;
EXPECT_REF(collection, 2);
hr = IXMLDOMSchemaCollection_get__newEnum(collection, (IUnknown**)&enumv); hr = IXMLDOMSchemaCollection_get__newEnum(collection, (IUnknown**)&enumv);
todo_wine
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
if (hr == S_OK) EXPECT_REF(collection, 3);
{ ok(enumv != NULL, "got %p\n", enumv);
ok(enumv != NULL, "got %p\n", enumv);
V_VT(&v) = VT_EMPTY; hr = IXMLDOMSchemaCollection_QueryInterface(collection, &IID_IUnknown, (void**)&unk1);
hr = IEnumVARIANT_Next(enumv, 1, &v, NULL); EXPECT_HR(hr, S_OK);
EXPECT_HR(hr, S_OK); hr = IEnumVARIANT_QueryInterface(enumv, &IID_IUnknown, (void**)&unk2);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v)); EXPECT_HR(hr, S_OK);
ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v))); ok(unk1 != unk2, "got %p, %p\n", unk1, unk2);
VariantClear(&v); IUnknown_Release(unk1);
IUnknown_Release(unk2);
V_VT(&v) = VT_EMPTY; hr = IXMLDOMSchemaCollection_QueryInterface(collection, &IID_IEnumVARIANT, (void**)&enum2);
hr = IEnumVARIANT_Next(enumv, 1, &v, NULL); EXPECT_HR(hr, E_NOINTERFACE);
EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
V_VT(&v) = VT_NULL; V_VT(&v) = VT_EMPTY;
hr = IEnumVARIANT_Next(enumv, 1, &v, NULL); hr = IEnumVARIANT_Next(enumv, 1, &v, NULL);
EXPECT_HR(hr, S_FALSE); EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_EMPTY, "got %d\n", V_VT(&v)); ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
IEnumVARIANT_Release(enumv); V_VT(&v) = VT_EMPTY;
} hr = IEnumVARIANT_Next(enumv, 1, &v, NULL);
EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
V_VT(&v) = VT_NULL;
hr = IEnumVARIANT_Next(enumv, 1, &v, NULL);
EXPECT_HR(hr, S_FALSE);
ok(V_VT(&v) == VT_EMPTY, "got %d\n", V_VT(&v));
IEnumVARIANT_Release(enumv);
IXMLDOMSchemaCollection_Release(collection); IXMLDOMSchemaCollection_Release(collection);
IXMLDOMDocument2_Release(doc); IXMLDOMDocument2_Release(doc);
...@@ -11900,33 +11910,29 @@ todo_wine ...@@ -11900,33 +11910,29 @@ todo_wine
/* enumerate */ /* enumerate */
enumv = (void*)0xdeadbeef; enumv = (void*)0xdeadbeef;
hr = IXMLDOMSchemaCollection_get__newEnum(collection, (IUnknown**)&enumv); hr = IXMLDOMSchemaCollection_get__newEnum(collection, (IUnknown**)&enumv);
todo_wine
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
if (hr == S_OK) ok(enumv != NULL, "got %p\n", enumv);
{
ok(enumv != NULL, "got %p\n", enumv);
V_VT(&v) = VT_EMPTY; V_VT(&v) = VT_EMPTY;
hr = IEnumVARIANT_Next(enumv, 1, &v, NULL); hr = IEnumVARIANT_Next(enumv, 1, &v, NULL);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v)); ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v))); ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v); VariantClear(&v);
V_VT(&v) = VT_EMPTY; V_VT(&v) = VT_EMPTY;
hr = IEnumVARIANT_Next(enumv, 1, &v, NULL); hr = IEnumVARIANT_Next(enumv, 1, &v, NULL);
EXPECT_HR(hr, S_OK); EXPECT_HR(hr, S_OK);
ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v)); ok(V_VT(&v) == VT_BSTR, "got %d\n", V_VT(&v));
ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v))); ok(!lstrcmpW(V_BSTR(&v), _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v); VariantClear(&v);
V_VT(&v) = VT_NULL; V_VT(&v) = VT_NULL;
hr = IEnumVARIANT_Next(enumv, 1, &v, NULL); hr = IEnumVARIANT_Next(enumv, 1, &v, NULL);
EXPECT_HR(hr, S_FALSE); EXPECT_HR(hr, S_FALSE);
ok(V_VT(&v) == VT_EMPTY, "got %d\n", V_VT(&v)); ok(V_VT(&v) == VT_EMPTY, "got %d\n", V_VT(&v));
IEnumVARIANT_Release(enumv); IEnumVARIANT_Release(enumv);
}
IXMLDOMSchemaCollection_Release(collection); IXMLDOMSchemaCollection_Release(collection);
IXMLDOMDocument2_Release(doc); IXMLDOMDocument2_Release(doc);
free_bstrs(); free_bstrs();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment