Commit 89092c92 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite: Basic input object creation on IXmlReader::SetInput().

parent 4e3283fd
......@@ -38,6 +38,7 @@ typedef struct _xmlreader
{
const IXmlReaderVtbl *lpVtbl;
LONG ref;
IXmlReaderInput *input;
} xmlreader;
typedef struct _xmlreaderinput
......@@ -95,6 +96,7 @@ static ULONG WINAPI xmlreader_Release(IXmlReader *iface)
ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
if (This->input) IUnknown_Release(This->input);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -103,8 +105,40 @@ static ULONG WINAPI xmlreader_Release(IXmlReader *iface)
static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input)
{
FIXME("(%p %p): stub\n", iface, input);
return E_NOTIMPL;
xmlreader *This = impl_from_IXmlReader(iface);
HRESULT hr;
TRACE("(%p %p)\n", This, input);
if (This->input)
{
IUnknown_Release(This->input);
This->input = NULL;
}
/* just reset current input */
if (!input) return S_OK;
/* now try IXmlReaderInput, ISequentialStream, IStream */
hr = IUnknown_QueryInterface(input, &IID_IXmlReaderInput, (void**)&This->input);
if (hr != S_OK)
{
IUnknown *stream_input = NULL;
hr = IUnknown_QueryInterface(input, &IID_ISequentialStream, (void**)&stream_input);
if (hr != S_OK)
{
hr = IUnknown_QueryInterface(input, &IID_IStream, (void**)&stream_input);
if (hr != S_OK) return hr;
}
/* create IXmlReaderInput basing on supplied interface */
IUnknown_Release(stream_input);
return CreateXmlReaderInputWithEncodingName(stream_input,
NULL, NULL, FALSE, NULL, &This->input);
}
return S_OK;
}
static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT property, LONG_PTR *value)
......@@ -357,6 +391,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc)
reader->lpVtbl = &xmlreader_vtbl;
reader->ref = 1;
reader->input = NULL;
*pObject = &reader->lpVtbl;
......
......@@ -195,14 +195,18 @@ static void test_reader_create(void)
hr = IMalloc_DidAlloc(imalloc, reader);
ok(hr != 1, "Expected 0 or -1, got %08x\n", hr);
/* Null input pointer, releases previous input */
hr = IXmlReader_SetInput(reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
/* test input interface selection sequence */
hr = testinput_createinstance((void**)&input);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
input_iids.count = 0;
hr = IXmlReader_SetInput(reader, input);
todo_wine ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr);
ok_iids(&input_iids, setinput_full, sizeof(setinput_full)/sizeof(REFIID), TRUE);
ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr);
ok_iids(&input_iids, setinput_full, sizeof(setinput_full)/sizeof(REFIID), FALSE);
IUnknown_Release(input);
......
......@@ -81,4 +81,7 @@ interface IXmlReader : IUnknown
/* IXmlReader construction */
cpp_quote("STDAPI CreateXmlReader(REFIID riid, void **ppvObject, IMalloc *pMalloc);")
typedef IUnknown IXmlReaderInput;
cpp_quote("typedef IUnknown IXmlReaderInput;")
cpp_quote("STDAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, IMalloc *pMalloc,")
cpp_quote(" LPCWSTR encoding, BOOL hint,")
cpp_quote(" LPCWSTR base_uri, IXmlReaderInput **ppInput);")
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