Commit 4e3283fd authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite: Add IXmlReaderInput stub implementation.

parent 5c1f0dba
...@@ -31,17 +31,31 @@ ...@@ -31,17 +31,31 @@
WINE_DEFAULT_DEBUG_CHANNEL(xmllite); WINE_DEFAULT_DEBUG_CHANNEL(xmllite);
/* not defined in public headers */
DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda);
typedef struct _xmlreader typedef struct _xmlreader
{ {
const IXmlReaderVtbl *lpVtbl; const IXmlReaderVtbl *lpVtbl;
LONG ref; LONG ref;
} xmlreader; } xmlreader;
typedef struct _xmlreaderinput
{
const IUnknownVtbl *lpVtbl;
LONG ref;
} xmlreaderinput;
static inline xmlreader *impl_from_IXmlReader(IXmlReader *iface) static inline xmlreader *impl_from_IXmlReader(IXmlReader *iface)
{ {
return (xmlreader *)((char*)iface - FIELD_OFFSET(xmlreader, lpVtbl)); return (xmlreader *)((char*)iface - FIELD_OFFSET(xmlreader, lpVtbl));
} }
static inline xmlreaderinput *impl_from_IXmlReaderInput(IXmlReaderInput *iface)
{
return (xmlreaderinput *)((char*)iface - FIELD_OFFSET(xmlreaderinput, lpVtbl));
}
static HRESULT WINAPI xmlreader_QueryInterface(IXmlReader *iface, REFIID riid, void** ppvObject) static HRESULT WINAPI xmlreader_QueryInterface(IXmlReader *iface, REFIID riid, void** ppvObject)
{ {
xmlreader *This = impl_from_IXmlReader(iface); xmlreader *This = impl_from_IXmlReader(iface);
...@@ -271,6 +285,59 @@ static const struct IXmlReaderVtbl xmlreader_vtbl = ...@@ -271,6 +285,59 @@ static const struct IXmlReaderVtbl xmlreader_vtbl =
xmlreader_IsEOF xmlreader_IsEOF
}; };
/* IXmlReaderInput */
static HRESULT WINAPI xmlreaderinput_QueryInterface(IXmlReaderInput *iface, REFIID riid, void** ppvObject)
{
xmlreaderinput *This = impl_from_IXmlReaderInput(iface);
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
if (IsEqualGUID(riid, &IID_IXmlReaderInput) ||
IsEqualGUID(riid, &IID_IUnknown))
{
*ppvObject = iface;
}
else
{
FIXME("interface %s not implemented\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
IUnknown_AddRef(iface);
return S_OK;
}
static ULONG WINAPI xmlreaderinput_AddRef(IXmlReaderInput *iface)
{
xmlreaderinput *This = impl_from_IXmlReaderInput(iface);
TRACE("%p\n", This);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI xmlreaderinput_Release(IXmlReaderInput *iface)
{
xmlreaderinput *This = impl_from_IXmlReaderInput(iface);
LONG ref;
TRACE("%p\n", This);
ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static const struct IUnknownVtbl xmlreaderinput_vtbl =
{
xmlreaderinput_QueryInterface,
xmlreaderinput_AddRef,
xmlreaderinput_Release
};
HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc) HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc)
{ {
xmlreader *reader; xmlreader *reader;
...@@ -305,7 +372,22 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, ...@@ -305,7 +372,22 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream,
LPCWSTR base_uri, LPCWSTR base_uri,
IXmlReaderInput **ppInput) IXmlReaderInput **ppInput)
{ {
FIXME("%p %p %s %d %s %p\n", stream, pMalloc, wine_dbgstr_w(encoding), xmlreaderinput *readerinput;
FIXME("%p %p %s %d %s %p: stub\n", stream, pMalloc, wine_dbgstr_w(encoding),
hint, wine_dbgstr_w(base_uri), ppInput); hint, wine_dbgstr_w(base_uri), ppInput);
return E_NOTIMPL;
if (!stream || !ppInput) return E_INVALIDARG;
readerinput = HeapAlloc(GetProcessHeap(), 0, sizeof (*readerinput));
if(!readerinput) return E_OUTOFMEMORY;
readerinput->lpVtbl = &xmlreaderinput_vtbl;
readerinput->ref = 1;
*ppInput = (IXmlReaderInput*)&readerinput->lpVtbl;
TRACE("returning iface %p\n", *ppInput);
return S_OK;
} }
...@@ -218,9 +218,9 @@ static void test_readerinput(void) ...@@ -218,9 +218,9 @@ static void test_readerinput(void)
LONG ref; LONG ref;
hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, NULL); hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, NULL);
todo_wine ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, &reader_input); hr = pCreateXmlReaderInputWithEncodingName(NULL, NULL, NULL, FALSE, NULL, &reader_input);
todo_wine ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
...@@ -229,17 +229,11 @@ static void test_readerinput(void) ...@@ -229,17 +229,11 @@ static void test_readerinput(void)
ok(ref == 2, "Expected 2, got %d\n", ref); ok(ref == 2, "Expected 2, got %d\n", ref);
IStream_Release(stream); IStream_Release(stream);
hr = pCreateXmlReaderInputWithEncodingName((IUnknown*)stream, NULL, NULL, FALSE, NULL, &reader_input); hr = pCreateXmlReaderInputWithEncodingName((IUnknown*)stream, NULL, NULL, FALSE, NULL, &reader_input);
todo_wine ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
if(hr != S_OK)
{
skip("CreateXmlReaderInputWithEncodingName not implemented\n");
IStream_Release(stream);
return;
}
/* IXmlReader grabs a stream reference */ /* IXmlReader grabs a stream reference */
ref = IStream_AddRef(stream); ref = IStream_AddRef(stream);
ok(ref == 3, "Expected 3, got %d\n", ref); todo_wine ok(ref == 3, "Expected 3, got %d\n", ref);
IStream_Release(stream); IStream_Release(stream);
/* IID_IXmlReaderInput */ /* IID_IXmlReaderInput */
...@@ -249,6 +243,9 @@ static void test_readerinput(void) ...@@ -249,6 +243,9 @@ static void test_readerinput(void)
obj = (IUnknown*)0xdeadbeef; obj = (IUnknown*)0xdeadbeef;
hr = IUnknown_QueryInterface(reader_input, &IID_IXmlReaderInput, (void**)&obj); hr = IUnknown_QueryInterface(reader_input, &IID_IXmlReaderInput, (void**)&obj);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ref = IUnknown_AddRef(reader_input);
ok(ref == 3, "Expected 3, got %d\n", ref);
IUnknown_Release(reader_input);
IUnknown_Release(reader_input); IUnknown_Release(reader_input);
IStream_Release(stream); IStream_Release(stream);
......
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