d3dcompiler_43: Use BOOL type where appropriate.
[wine.git] / dlls / msxml3 / parseerror.c
blobb5c79480d7b13e1b430340ff3ae51aef8e113f7e
1 /*
2 * ParseError implementation
4 * Copyright 2005 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
24 #include "config.h"
26 #include <stdarg.h>
27 #ifdef HAVE_LIBXML2
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
30 #endif
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winerror.h"
35 #include "winuser.h"
36 #include "ole2.h"
37 #include "msxml6.h"
39 #include "msxml_private.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 typedef struct
47 DispatchEx dispex;
48 IXMLDOMParseError2 IXMLDOMParseError2_iface;
49 LONG ref;
50 LONG code, line, linepos, filepos;
51 BSTR url, reason, srcText;
52 } parse_error_t;
54 static inline parse_error_t *impl_from_IXMLDOMParseError2( IXMLDOMParseError2 *iface )
56 return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError2_iface);
59 static HRESULT WINAPI parseError_QueryInterface(
60 IXMLDOMParseError2 *iface,
61 REFIID riid,
62 void** ppvObject )
64 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
66 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
68 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
69 IsEqualGUID( riid, &IID_IDispatch ) ||
70 IsEqualGUID( riid, &IID_IXMLDOMParseError ) ||
71 IsEqualGUID( riid, &IID_IXMLDOMParseError2 ) )
73 *ppvObject = iface;
75 else if (dispex_query_interface(&This->dispex, riid, ppvObject))
77 return *ppvObject ? S_OK : E_NOINTERFACE;
79 else
81 FIXME("interface %s not implemented\n", debugstr_guid(riid));
82 *ppvObject = NULL;
83 return E_NOINTERFACE;
86 IXMLDOMParseError2_AddRef( iface );
88 return S_OK;
91 static ULONG WINAPI parseError_AddRef(
92 IXMLDOMParseError2 *iface )
94 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
95 ULONG ref = InterlockedIncrement( &This->ref );
96 TRACE("(%p)->(%d)\n", This, ref);
97 return ref;
100 static ULONG WINAPI parseError_Release(
101 IXMLDOMParseError2 *iface )
103 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
104 ULONG ref = InterlockedDecrement( &This->ref );
106 TRACE("(%p)->(%d)\n", This, ref);
107 if ( ref == 0 )
109 SysFreeString(This->url);
110 SysFreeString(This->reason);
111 SysFreeString(This->srcText);
112 release_dispex(&This->dispex);
113 heap_free( This );
116 return ref;
119 static HRESULT WINAPI parseError_GetTypeInfoCount(
120 IXMLDOMParseError2 *iface,
121 UINT* pctinfo )
123 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
124 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
127 static HRESULT WINAPI parseError_GetTypeInfo(
128 IXMLDOMParseError2 *iface,
129 UINT iTInfo,
130 LCID lcid,
131 ITypeInfo** ppTInfo )
133 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
134 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
135 iTInfo, lcid, ppTInfo);
138 static HRESULT WINAPI parseError_GetIDsOfNames(
139 IXMLDOMParseError2 *iface,
140 REFIID riid,
141 LPOLESTR* rgszNames,
142 UINT cNames,
143 LCID lcid,
144 DISPID* rgDispId )
146 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
147 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
148 riid, rgszNames, cNames, lcid, rgDispId);
151 static HRESULT WINAPI parseError_Invoke(
152 IXMLDOMParseError2 *iface,
153 DISPID dispIdMember,
154 REFIID riid,
155 LCID lcid,
156 WORD wFlags,
157 DISPPARAMS* pDispParams,
158 VARIANT* pVarResult,
159 EXCEPINFO* pExcepInfo,
160 UINT* puArgErr )
162 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
163 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
164 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
167 static HRESULT WINAPI parseError_get_errorCode(
168 IXMLDOMParseError2 *iface,
169 LONG *code )
171 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
172 TRACE("(%p)->(%p)\n", This, code);
174 *code = This->code;
176 if(This->code == 0)
177 return S_FALSE;
179 return S_OK;
182 static HRESULT WINAPI parseError_get_url(
183 IXMLDOMParseError2 *iface,
184 BSTR *url )
186 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
187 FIXME("(%p)->(%p)\n", This, url);
188 return E_NOTIMPL;
191 static HRESULT WINAPI parseError_get_reason(
192 IXMLDOMParseError2 *iface,
193 BSTR *reason )
195 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
196 TRACE("(%p)->(%p)\n", This, reason);
198 if(!This->reason)
200 *reason = NULL;
201 return S_FALSE;
203 *reason = SysAllocString(This->reason);
204 return S_OK;
207 static HRESULT WINAPI parseError_get_srcText(
208 IXMLDOMParseError2 *iface,
209 BSTR *srcText )
211 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
213 TRACE("(%p)->(%p)\n", This, srcText);
215 if (!srcText) return E_INVALIDARG;
217 *srcText = SysAllocString(This->srcText);
219 return S_OK;
222 static HRESULT WINAPI parseError_get_line(
223 IXMLDOMParseError2 *iface,
224 LONG *line )
226 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
228 TRACE("(%p)->(%p): stub\n", This, line);
230 if (!line) return E_INVALIDARG;
232 *line = This->line;
233 return S_OK;
236 static HRESULT WINAPI parseError_get_linepos(
237 IXMLDOMParseError2 *iface,
238 LONG *linepos )
240 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
242 TRACE("(%p)->(%p)\n", This, linepos);
244 if (!linepos) return E_INVALIDARG;
246 *linepos = This->linepos;
247 return S_OK;
250 static HRESULT WINAPI parseError_get_filepos(
251 IXMLDOMParseError2 *iface,
252 LONG *filepos )
254 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
255 FIXME("(%p)->(%p)\n", This, filepos);
256 return E_NOTIMPL;
259 static HRESULT WINAPI parseError_get_errorXPath(
260 IXMLDOMParseError2 *iface,
261 BSTR *xpathexpr)
263 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
264 FIXME("(%p)->(%p)\n", This, xpathexpr);
265 return E_NOTIMPL;
268 static HRESULT WINAPI parseError_get_AllErrors(
269 IXMLDOMParseError2 *iface,
270 IXMLDOMParseErrorCollection **allErrors)
272 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
273 FIXME("(%p)->(%p)\n", This, allErrors);
274 return E_NOTIMPL;
277 static HRESULT WINAPI parseError_errorParameters(
278 IXMLDOMParseError2 *iface,
279 LONG index,
280 BSTR *param)
282 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
283 FIXME("(%p)->(%p)\n", This, param);
284 return E_NOTIMPL;
287 static HRESULT WINAPI parseError_get_errorParametersCount(
288 IXMLDOMParseError2 *iface,
289 LONG *count)
291 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
292 FIXME("(%p)->(%p)\n", This, count);
293 return E_NOTIMPL;
296 static const struct IXMLDOMParseError2Vtbl XMLDOMParseError2Vtbl =
298 parseError_QueryInterface,
299 parseError_AddRef,
300 parseError_Release,
301 parseError_GetTypeInfoCount,
302 parseError_GetTypeInfo,
303 parseError_GetIDsOfNames,
304 parseError_Invoke,
305 parseError_get_errorCode,
306 parseError_get_url,
307 parseError_get_reason,
308 parseError_get_srcText,
309 parseError_get_line,
310 parseError_get_linepos,
311 parseError_get_filepos,
312 parseError_get_errorXPath,
313 parseError_get_AllErrors,
314 parseError_errorParameters,
315 parseError_get_errorParametersCount
318 static const tid_t parseError_iface_tids[] = {
319 IXMLDOMParseError2_tid,
323 static dispex_static_data_t parseError_dispex = {
324 NULL,
325 IXMLDOMParseError2_tid,
326 NULL,
327 parseError_iface_tids
330 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
331 LONG line, LONG linepos, LONG filepos )
333 parse_error_t *This;
335 This = heap_alloc( sizeof(*This) );
336 if ( !This )
337 return NULL;
339 This->IXMLDOMParseError2_iface.lpVtbl = &XMLDOMParseError2Vtbl;
340 This->ref = 1;
342 This->code = code;
343 This->url = url;
344 This->reason = reason;
345 This->srcText = srcText;
346 This->line = line;
347 This->linepos = linepos;
348 This->filepos = filepos;
350 init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMParseError2_iface, &parseError_dispex);
352 return (IXMLDOMParseError*)&This->IXMLDOMParseError2_iface;