Nikolay Sivov : xmllite: Implement attribute iteration methods.
Alexandre Julliard
julliard at winehq.org
Thu Dec 6 16:25:10 CST 2012
Module: wine
Branch: master
Commit: f6e6b835b60a9780f68a34eb71c25e2fe382691c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f6e6b835b60a9780f68a34eb71c25e2fe382691c
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Dec 6 16:05:19 2012 +0400
xmllite: Implement attribute iteration methods.
---
dlls/xmllite/reader.c | 37 +++++++++++++++++++++++++++++++------
dlls/xmllite/tests/reader.c | 32 ++++++++++++++++++++++++++++++--
2 files changed, 61 insertions(+), 8 deletions(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
index 0d33296..ec7fe37 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -113,6 +113,7 @@ typedef struct _xmlreader
DtdProcessing dtdmode;
UINT line, pos; /* reader position in XML stream */
struct list attrs; /* attributes list for current node */
+ struct attribute *attr; /* current attribute */
UINT attr_count;
} xmlreader;
@@ -942,14 +943,32 @@ static HRESULT WINAPI xmlreader_GetNodeType(IXmlReader* iface, XmlNodeType *node
static HRESULT WINAPI xmlreader_MoveToFirstAttribute(IXmlReader* iface)
{
- FIXME("(%p): stub\n", iface);
- return E_NOTIMPL;
+ xmlreader *This = impl_from_IXmlReader(iface);
+
+ TRACE("(%p)\n", This);
+
+ if (!This->attr_count) return S_FALSE;
+ This->attr = LIST_ENTRY(list_head(&This->attrs), struct attribute, entry);
+ return S_OK;
}
static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface)
{
- FIXME("(%p): stub\n", iface);
- return E_NOTIMPL;
+ xmlreader *This = impl_from_IXmlReader(iface);
+ const struct list *next;
+
+ TRACE("(%p)\n", This);
+
+ if (!This->attr_count) return S_FALSE;
+
+ if (!This->attr)
+ return IXmlReader_MoveToFirstAttribute(iface);
+
+ next = list_next(&This->attrs, &This->attr->entry);
+ if (next)
+ This->attr = LIST_ENTRY(next, struct attribute, entry);
+
+ return next ? S_OK : S_FALSE;
}
static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface,
@@ -962,8 +981,13 @@ static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface,
static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
{
- FIXME("(%p): stub\n", iface);
- return E_NOTIMPL;
+ xmlreader *This = impl_from_IXmlReader(iface);
+
+ TRACE("(%p)\n", This);
+
+ if (!This->attr_count) return S_FALSE;
+ This->attr = NULL;
+ return S_OK;
}
static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *qualifiedName,
@@ -1202,6 +1226,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
reader->nodetype = XmlNodeType_None;
list_init(&reader->attrs);
reader->attr_count = 0;
+ reader->attr = NULL;
*obj = &reader->IXmlReader_iface;
diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c
index c44816c..099c8fb 100644
--- a/dlls/xmllite/tests/reader.c
+++ b/dlls/xmllite/tests/reader.c
@@ -591,6 +591,7 @@ static void test_read_xmldeclaration(void)
HRESULT hr;
XmlNodeType type;
UINT count = 0;
+ const WCHAR *val;
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
@@ -611,6 +612,16 @@ static void test_read_xmldeclaration(void)
ok(hr == S_OK, "got %08x\n", hr);
ok(count == 0, "got %d\n", count);
+ /* try to move without attributes */
+ hr = IXmlReader_MoveToElement(reader);
+ ok(hr == S_FALSE, "got %08x\n", hr);
+
+ hr = IXmlReader_MoveToNextAttribute(reader);
+ ok(hr == S_FALSE, "got %08x\n", hr);
+
+ hr = IXmlReader_MoveToFirstAttribute(reader);
+ ok(hr == S_FALSE, "got %08x\n", hr);
+
ok_pos(reader, 0, 0, -1, -1, FALSE);
type = -1;
@@ -622,13 +633,27 @@ static void test_read_xmldeclaration(void)
ok_pos(reader, 1, 3, -1, 55, TRUE);
test_read_state(reader, XmlReadState_Interactive, -1, 0);
+ hr = IXmlReader_GetValue(reader, &val, NULL);
+todo_wine
+ ok(hr == S_OK, "got %08x\n", hr);
+ if (hr == S_OK)
+ ok(*val == 0, "got %s\n", wine_dbgstr_w(val));
+
/* check attributes */
hr = IXmlReader_MoveToNextAttribute(reader);
- todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(hr == S_OK, "got %08x\n", hr);
ok_pos(reader, 1, 7, -1, 55, TRUE);
+ /* try to move from last attribute */
+ hr = IXmlReader_MoveToNextAttribute(reader);
+ ok(hr == S_OK, "got %08x\n", hr);
+ hr = IXmlReader_MoveToNextAttribute(reader);
+ ok(hr == S_OK, "got %08x\n", hr);
+ hr = IXmlReader_MoveToNextAttribute(reader);
+ ok(hr == S_FALSE, "got %08x\n", hr);
+
hr = IXmlReader_MoveToFirstAttribute(reader);
- todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ ok(hr == S_OK, "got %08x\n", hr);
ok_pos(reader, 1, 7, -1, 55, TRUE);
hr = IXmlReader_GetAttributeCount(reader, NULL);
@@ -644,6 +669,9 @@ todo_wine {
ok(count == 1, "Expected 1, got %d\n", count);
}
+ hr = IXmlReader_MoveToElement(reader);
+ ok(hr == S_OK, "got %08x\n", hr);
+
IStream_Release(stream);
IXmlReader_Release(reader);
}
More information about the wine-cvs
mailing list