Commit 67c07ff4 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite: Store reader input impl pointer in reader structure.

parent 6f7624f5
...@@ -64,17 +64,6 @@ typedef struct ...@@ -64,17 +64,6 @@ typedef struct
unsigned int written; unsigned int written;
} encoded_buffer; } encoded_buffer;
typedef struct _xmlreader
{
IXmlReader IXmlReader_iface;
LONG ref;
IXmlReaderInput *input;
IMalloc *imalloc;
XmlReadState state;
DtdProcessing dtdmode;
UINT line, pos; /* reader position in XML stream */
} xmlreader;
typedef struct input_buffer input_buffer; typedef struct input_buffer input_buffer;
typedef struct _xmlreaderinput typedef struct _xmlreaderinput
...@@ -91,6 +80,17 @@ typedef struct _xmlreaderinput ...@@ -91,6 +80,17 @@ typedef struct _xmlreaderinput
input_buffer *buffer; input_buffer *buffer;
} xmlreaderinput; } xmlreaderinput;
typedef struct _xmlreader
{
IXmlReader IXmlReader_iface;
LONG ref;
xmlreaderinput *input;
IMalloc *imalloc;
XmlReadState state;
DtdProcessing dtdmode;
UINT line, pos; /* reader position in XML stream */
} xmlreader;
struct input_buffer struct input_buffer
{ {
encoded_buffer utf16; encoded_buffer utf16;
...@@ -226,27 +226,24 @@ static void free_input_buffer(input_buffer *buffer) ...@@ -226,27 +226,24 @@ static void free_input_buffer(input_buffer *buffer)
readerinput_free(buffer->input, buffer); readerinput_free(buffer->input, buffer);
} }
static void xmlreaderinput_release_stream(IXmlReaderInput *iface) static void xmlreaderinput_release_stream(xmlreaderinput *readerinput)
{ {
xmlreaderinput *This = impl_from_IXmlReaderInput(iface); if (readerinput->stream) {
ISequentialStream_Release(readerinput->stream);
if (This->stream) { readerinput->stream = NULL;
ISequentialStream_Release(This->stream);
This->stream = NULL;
} }
} }
/* Queries already stored interface for IStream/ISequentialStream. /* Queries already stored interface for IStream/ISequentialStream.
Interface supplied on creation will be overwritten */ Interface supplied on creation will be overwritten */
static HRESULT xmlreaderinput_query_for_stream(IXmlReaderInput *iface) static HRESULT xmlreaderinput_query_for_stream(xmlreaderinput *readerinput)
{ {
xmlreaderinput *This = impl_from_IXmlReaderInput(iface);
HRESULT hr; HRESULT hr;
xmlreaderinput_release_stream(iface); xmlreaderinput_release_stream(readerinput);
hr = IUnknown_QueryInterface(This->input, &IID_IStream, (void**)&This->stream); hr = IUnknown_QueryInterface(readerinput->input, &IID_IStream, (void**)&readerinput->stream);
if (hr != S_OK) if (hr != S_OK)
hr = IUnknown_QueryInterface(This->input, &IID_ISequentialStream, (void**)&This->stream); hr = IUnknown_QueryInterface(readerinput->input, &IID_ISequentialStream, (void**)&readerinput->stream);
return hr; return hr;
} }
...@@ -291,7 +288,7 @@ static ULONG WINAPI xmlreader_Release(IXmlReader *iface) ...@@ -291,7 +288,7 @@ static ULONG WINAPI xmlreader_Release(IXmlReader *iface)
if (ref == 0) if (ref == 0)
{ {
IMalloc *imalloc = This->imalloc; IMalloc *imalloc = This->imalloc;
if (This->input) IUnknown_Release(This->input); if (This->input) IUnknown_Release(&This->input->IXmlReaderInput_iface);
reader_free(This, This); reader_free(This, This);
if (imalloc) IMalloc_Release(imalloc); if (imalloc) IMalloc_Release(imalloc);
} }
...@@ -309,7 +306,7 @@ static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input) ...@@ -309,7 +306,7 @@ static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input)
if (This->input) if (This->input)
{ {
xmlreaderinput_release_stream(This->input); xmlreaderinput_release_stream(This->input);
IUnknown_Release(This->input); IUnknown_Release(&This->input->IXmlReaderInput_iface);
This->input = NULL; This->input = NULL;
} }
...@@ -326,10 +323,13 @@ static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input) ...@@ -326,10 +323,13 @@ static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input)
hr = IUnknown_QueryInterface(input, &IID_IXmlReaderInput, (void**)&This->input); hr = IUnknown_QueryInterface(input, &IID_IXmlReaderInput, (void**)&This->input);
if (hr != S_OK) if (hr != S_OK)
{ {
IXmlReaderInput *readerinput;
/* create IXmlReaderInput basing on supplied interface */ /* create IXmlReaderInput basing on supplied interface */
hr = CreateXmlReaderInputWithEncodingName(input, hr = CreateXmlReaderInputWithEncodingName(input,
NULL, NULL, FALSE, NULL, &This->input); NULL, NULL, FALSE, NULL, &readerinput);
if (hr != S_OK) return hr; if (hr != S_OK) return hr;
This->input = impl_from_IXmlReaderInput(readerinput);
} }
/* set stream for supplied IXmlReaderInput */ /* set stream for supplied IXmlReaderInput */
......
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