[PATCH 9/9] Add stub IXmlReader implementation with initial tests
Nikolay Sivov
bunglehead at gmail.com
Thu Jan 14 14:07:58 CST 2010
---
.gitignore | 1 +
configure.ac | 1 +
dlls/xmllite/Makefile.in | 3 +-
dlls/xmllite/reader.c | 289 ++++++++++++++++++++++++++++++++++++++++
dlls/xmllite/tests/Makefile.in | 13 ++
dlls/xmllite/tests/reader.c | 95 +++++++++++++
dlls/xmllite/xmllite.spec | 2 +-
include/Makefile.in | 3 +-
include/xmllite.idl | 87 ++++++++++++
9 files changed, 491 insertions(+), 3 deletions(-)
create mode 100644 dlls/xmllite/reader.c
create mode 100644 dlls/xmllite/tests/Makefile.in
create mode 100644 dlls/xmllite/tests/reader.c
create mode 100644 include/xmllite.idl
diff --git a/.gitignore b/.gitignore
index 7dd1f9d..f2a0bd8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -212,6 +212,7 @@ include/wtypes.h
include/wuapi.h
include/xmldom.h
include/xmldso.h
+include/xmllite.h
libs/wpp/ppl.yy.c
libs/wpp/ppy.tab.c
libs/wpp/ppy.tab.h
diff --git a/configure.ac b/configure.ac
index 943938b..01cf3a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2587,6 +2587,7 @@ WINE_CONFIG_MAKEFILE([dlls/xinput1_3/Makefile],[dlls/Makedll.rules],[dlls],[ALL_
WINE_CONFIG_MAKEFILE([dlls/xinput1_3/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
WINE_CONFIG_MAKEFILE([dlls/xinput9_1_0/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
WINE_CONFIG_MAKEFILE([dlls/xmllite/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
+WINE_CONFIG_MAKEFILE([dlls/xmllite/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS],[enable_tests])
WINE_CONFIG_MAKEFILE([documentation/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
WINE_CONFIG_MAKEFILE([fonts/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
WINE_CONFIG_MAKEFILE([include/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
diff --git a/dlls/xmllite/Makefile.in b/dlls/xmllite/Makefile.in
index 17d8dd1..b0ba77e 100644
--- a/dlls/xmllite/Makefile.in
+++ b/dlls/xmllite/Makefile.in
@@ -3,9 +3,10 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = xmllite.dll
-IMPORTS = kernel32
+IMPORTS = uuid kernel32
C_SRCS = \
+ reader.c \
xmllite_main.c
@MAKE_DLL_RULES@
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
new file mode 100644
index 0000000..dcf27aa
--- /dev/null
+++ b/dlls/xmllite/reader.c
@@ -0,0 +1,289 @@
+/*
+ * IXmlReader implementation
+ *
+ * Copyright 2010 Nikolay Sivov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "initguid.h"
+#include "objbase.h"
+#include "xmllite.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(xmllite);
+
+typedef struct _xmlreader
+{
+ const IXmlReaderVtbl *lpVtbl;
+ LONG ref;
+} xmlreader;
+
+static inline xmlreader *impl_from_IXmlReader(IXmlReader *iface)
+{
+ return (xmlreader *)((char*)iface - FIELD_OFFSET(xmlreader, lpVtbl));
+}
+
+static HRESULT WINAPI xmlreader_QueryInterface(IXmlReader *iface, REFIID riid, void** ppvObject)
+{
+ xmlreader *This = impl_from_IXmlReader(iface);
+
+ TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
+
+ if (IsEqualGUID(riid, &IID_IUnknown) ||
+ IsEqualGUID(riid, &IID_IXmlReader))
+ {
+ *ppvObject = iface;
+ }
+ else
+ {
+ FIXME("interface %s not implemented\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+ }
+
+ IXmlReader_AddRef(iface);
+
+ return S_OK;
+}
+
+static ULONG WINAPI xmlreader_AddRef(IXmlReader *iface)
+{
+ xmlreader *This = impl_from_IXmlReader(iface);
+ TRACE("%p\n", This);
+ return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI xmlreader_Release(IXmlReader *iface)
+{
+ xmlreader *This = impl_from_IXmlReader(iface);
+ LONG ref;
+
+ TRACE("%p\n", This);
+
+ ref = InterlockedDecrement(&This->ref);
+ if (ref == 0)
+ {
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
+}
+
+static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input)
+{
+ FIXME("(%p %p): stub\n", iface, input);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT prop, LONG_PTR *value)
+{
+ FIXME("(%p %u %p): stub\n", iface, prop, value);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_SetProperty(IXmlReader* iface, UINT prop, LONG_PTR value)
+{
+ FIXME("(%p %u %lu): stub\n", iface, prop, value);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_Read(IXmlReader* iface, XmlNodeType *type)
+{
+ FIXME("(%p %p): stub\n", iface, type);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetNodeType(IXmlReader* iface, XmlNodeType *type)
+{
+ FIXME("(%p %p): stub\n", iface, type);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_MoveToFirstAttribute(IXmlReader* iface)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_MoveToNextAttribute(IXmlReader* iface)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface, LPCWSTR LocalName,
+ LPCWSTR NamespaceUri)
+{
+ FIXME("(%p %p %p): stub\n", iface, LocalName, NamespaceUri);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetQualifiedName(IXmlReader* iface, LPCWSTR *QualifiedName,
+ UINT *cntQualifiedName)
+{
+ FIXME("(%p %p %p): stub\n", iface, QualifiedName, cntQualifiedName);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetNamespaceUri(IXmlReader* iface, LPCWSTR *NamespaceUri,
+ UINT *cntNamespaceUri)
+{
+ FIXME("(%p %p %p): stub\n", iface, NamespaceUri, cntNamespaceUri);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetLocalName(IXmlReader* iface, LPCWSTR *LocalName,
+ UINT *cntLocalName)
+{
+ FIXME("(%p %p %p): stub\n", iface, LocalName, cntLocalName);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetPrefix(IXmlReader* iface, LPCWSTR *Prefix,
+ UINT *cntPrefix)
+{
+ FIXME("(%p %p %p): stub\n", iface, Prefix, cntPrefix);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetValue(IXmlReader* iface, LPCWSTR *Value,
+ UINT *cntValue)
+{
+ FIXME("(%p %p %p): stub\n", iface, Value, cntValue);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_ReadValueChunk(IXmlReader* iface, WCHAR *Buffer,
+ UINT ChunkSize, UINT *Read)
+{
+ FIXME("(%p %p %u %p): stub\n", iface, Buffer, ChunkSize, Read);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetBaseUri(IXmlReader* iface, LPCWSTR *BaseUri,
+ UINT *cntBaseUri)
+{
+ FIXME("(%p %p %p): stub\n", iface, BaseUri, cntBaseUri);
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI xmlreader_IsDefault(IXmlReader* iface)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI xmlreader_IsEmptyElement(IXmlReader* iface)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetLineNumber(IXmlReader* iface, UINT *LineNumber)
+{
+ FIXME("(%p %p): stub\n", iface, LineNumber);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetLinePosition(IXmlReader* iface, UINT *LinePosition)
+{
+ FIXME("(%p %p): stub\n", iface, LinePosition);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetAttributeCount(IXmlReader* iface, UINT *Count)
+{
+ FIXME("(%p %p): stub\n", iface, Count);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI xmlreader_GetDepth(IXmlReader* iface, UINT *depth)
+{
+ FIXME("(%p %p): stub\n", iface, depth);
+ return E_NOTIMPL;
+}
+
+static BOOL WINAPI xmlreader_IsEOF(IXmlReader* iface)
+{
+ FIXME("(%p): stub\n", iface);
+ return E_NOTIMPL;
+}
+
+static const struct IXmlReaderVtbl xmlreader_vtbl =
+{
+ xmlreader_QueryInterface,
+ xmlreader_AddRef,
+ xmlreader_Release,
+ xmlreader_SetInput,
+ xmlreader_GetProperty,
+ xmlreader_SetProperty,
+ xmlreader_Read,
+ xmlreader_GetNodeType,
+ xmlreader_MoveToFirstAttribute,
+ xmlreader_MoveToNextAttribute,
+ xmlreader_MoveToAttributeByName,
+ xmlreader_MoveToElement,
+ xmlreader_GetQualifiedName,
+ xmlreader_GetNamespaceUri,
+ xmlreader_GetLocalName,
+ xmlreader_GetPrefix,
+ xmlreader_GetValue,
+ xmlreader_ReadValueChunk,
+ xmlreader_GetBaseUri,
+ xmlreader_IsDefault,
+ xmlreader_IsEmptyElement,
+ xmlreader_GetLineNumber,
+ xmlreader_GetLinePosition,
+ xmlreader_GetAttributeCount,
+ xmlreader_GetDepth,
+ xmlreader_IsEOF
+};
+
+HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc)
+{
+ xmlreader *reader;
+
+ TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), pObject, pMalloc);
+
+ if (pMalloc) FIXME("custom IMalloc not supported yet\n");
+
+ if (!IsEqualGUID(riid, &IID_IXmlReader)) return E_FAIL;
+
+ reader = HeapAlloc(GetProcessHeap(), 0, sizeof (*reader));
+ if(!reader)
+ return E_OUTOFMEMORY;
+
+ reader->lpVtbl = &xmlreader_vtbl;
+ reader->ref = 1;
+
+ *pObject = &reader->lpVtbl;
+
+ TRACE("returning iface %p\n", *pObject);
+
+ return S_OK;
+}
+
diff --git a/dlls/xmllite/tests/Makefile.in b/dlls/xmllite/tests/Makefile.in
new file mode 100644
index 0000000..250c493
--- /dev/null
+++ b/dlls/xmllite/tests/Makefile.in
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../../..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+TESTDLL = xmllite.dll
+IMPORTS = kernel32 ole32
+
+CTESTS = \
+ reader.c
+
+ at MAKE_TEST_RULES@
+
+ at DEPENDENCIES@ # everything below this line is overwritten by make depend
diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c
new file mode 100644
index 0000000..9e9dec1
--- /dev/null
+++ b/dlls/xmllite/tests/reader.c
@@ -0,0 +1,95 @@
+/*
+ * XMLLite IXmlReader tests
+ *
+ * Copyright 2010 Nikolay Sivov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define COBJMACROS
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "ole2.h"
+#include "xmllite.h"
+#include "initguid.h"
+#include "wine/test.h"
+
+DEFINE_GUID(IID_IXmlReader, 0x7279fc81, 0x709d, 0x4095, 0xb6, 0x3d, 0x69,
+ 0xfe, 0x4b, 0x0d, 0x90, 0x30);
+
+HRESULT WINAPI (*pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc *pMalloc);
+
+static BOOL init_pointers(void)
+{
+ /* don't free module here, it's to be unloaded on exit */
+ HMODULE mod = LoadLibraryA("xmllite.dll");
+
+ if (!mod)
+ {
+ win_skip("xmllite library not available\n");
+ return FALSE;
+ }
+
+ pCreateXmlReader = (void*)GetProcAddress(mod, "CreateXmlReader");
+ if (!pCreateXmlReader) return FALSE;
+
+ return TRUE;
+}
+
+static void test_reader_create(void)
+{
+ HRESULT hr;
+ IXmlReader *reader;
+ IMalloc *imalloc;
+
+ /* crashes native */
+ if (0)
+ {
+ hr = pCreateXmlReader(&IID_IXmlReader, NULL, NULL);
+ hr = pCreateXmlReader(NULL, (LPVOID*)&reader, NULL);
+ }
+
+ hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = CoGetMalloc(1, &imalloc);
+ ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+
+ hr = IMalloc_DidAlloc(imalloc, reader);
+ ok(hr != 1, "Expected 0 or -1, got %08x\n", hr);
+
+ IXmlReader_Release(reader);
+}
+
+START_TEST(reader)
+{
+ HRESULT r;
+
+ r = CoInitialize( NULL );
+ ok( r == S_OK, "failed to init com\n");
+
+ if (!init_pointers())
+ {
+ CoUninitialize();
+ return;
+ }
+
+ test_reader_create();
+
+ CoUninitialize();
+}
diff --git a/dlls/xmllite/xmllite.spec b/dlls/xmllite/xmllite.spec
index cf43637..9b5a84a 100644
--- a/dlls/xmllite/xmllite.spec
+++ b/dlls/xmllite/xmllite.spec
@@ -1,4 +1,4 @@
-@ stub CreateXmlReader
+@ stdcall CreateXmlReader(ptr ptr ptr)
@ stub CreateXmlReaderInputWithEncodingCodePage
@ stub CreateXmlReaderInputWithEncodingName
@ stub CreateXmlWriter
diff --git a/include/Makefile.in b/include/Makefile.in
index f957a7b..0c01cfd 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -96,7 +96,8 @@ PUBLIC_IDL_H_SRCS = \
wtypes.idl \
wuapi.idl \
xmldom.idl \
- xmldso.idl
+ xmldso.idl \
+ xmllite.idl
IDL_TLB_SRCS = \
stdole2.idl
diff --git a/include/xmllite.idl b/include/xmllite.idl
new file mode 100644
index 0000000..13198c1
--- /dev/null
+++ b/include/xmllite.idl
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2010 Nikolay Sivov
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+import "unknwn.idl";
+import "objidl.idl";
+import "oaidl.idl";
+import "ocidl.idl";
+
+
+
+typedef enum XmlNodeType {
+ XmlNodeType_None = 0,
+ XmlNodeType_Element = 1,
+ XmlNodeType_Attribute = 2,
+ XmlNodeType_Text = 3,
+ XmlNodeType_CDATA = 4,
+ XmlNodeType_ProcessingInstruction = 7,
+ XmlNodeType_Comment = 8,
+ XmlNodeType_DocumentType = 10,
+ XmlNodeType_Whitespace = 13,
+ XmlNodeType_EndElement = 15,
+ XmlNodeType_XmlDeclaration = 17,
+ _XmlNodeType_Last = 17
+} XmlNodeType;
+
+/* IXmlReader */
+[
+ local,
+ object,
+ uuid(7279fc81-709d-4095-b63d-69fe4b0d9030),
+ pointer_default(unique)
+]
+interface IXmlReader : IUnknown
+{
+ HRESULT SetInput( [in] IUnknown *pInput);
+ HRESULT GetProperty( [in] UINT nProperty, [out] LONG_PTR *ppValue);
+ HRESULT SetProperty( [in] UINT nProperty, [in] LONG_PTR pValue);
+ HRESULT Read( [out] XmlNodeType *pNodeType);
+ HRESULT GetNodeType( [out] XmlNodeType *pNodeType);
+ HRESULT MoveToFirstAttribute(void);
+ HRESULT MoveToNextAttribute(void);
+ HRESULT MoveToAttributeByName( [in] LPCWSTR pwszLocalName,
+ [in] LPCWSTR pwszNamespaceUri);
+ HRESULT MoveToElement(void);
+ HRESULT GetQualifiedName( [out] LPCWSTR *ppwszQualifiedName,
+ [out] UINT *pcwchQualifiedName);
+ HRESULT GetNamespaceUri( [out] LPCWSTR *ppwszNamespaceUri,
+ [out] UINT *pcwchNamespaceUri);
+ HRESULT GetLocalName( [out] LPCWSTR *ppwszLocalName,
+ [out] UINT *pcwchLocalName);
+ HRESULT GetPrefix( [out] LPCWSTR *ppwszPrefix,
+ [out] UINT *pcwchPrefix);
+ HRESULT GetValue( [out] LPCWSTR *ppwszValue,
+ [out] UINT *pcwchValue);
+ HRESULT ReadValueChunk( [out] WCHAR *pwchBuffer,
+ [in] UINT cwchChunkSize,
+ [in,out] UINT *pcwchRead);
+ HRESULT GetBaseUri( [out] LPCWSTR *ppwszBaseUri,
+ [out] UINT *pcwchBaseUri);
+ BOOL IsDefault(void);
+ BOOL IsEmptyElement(void);
+ HRESULT GetLineNumber( [out] UINT *pnLineNumber);
+ HRESULT GetLinePosition( [out] UINT *pnLinePosition);
+ HRESULT GetAttributeCount( [out] UINT *pnAttributeCount);
+ HRESULT GetDepth( [out] UINT *pnDepth);
+ BOOL IsEOF(void);
+}
+
+/* IXmlReader construction */
+cpp_quote("STDAPI CreateXmlReader(REFIID riid, void **ppvObject, IMalloc *pMalloc);")
+
+
--
1.5.6.5
--=-EQuH0KtH9wfx1otACstv--
More information about the wine-patches
mailing list