Implement get_parseError.
[wine] / dlls / msxml3 / parseerror.c
1 /*
2  *    ParseError implementation
3  *
4  * Copyright 2005 Huw Davies
5  *
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.
10  *
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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21
22 #define COBJMACROS
23
24 #include <stdarg.h>
25 #include <assert.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winerror.h"
29 #include "winuser.h"
30 #include "ole2.h"
31 #include "msxml.h"
32 #include "xmldom.h"
33
34 #include "msxml_private.h"
35
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
39
40 typedef struct
41 {
42     const struct IXMLDOMParseErrorVtbl *lpVtbl;
43     LONG ref;
44     LONG code, line, linepos, filepos;
45     BSTR url, reason, srcText;
46 } parse_error_t;
47
48 static inline parse_error_t *impl_from_IXMLDOMParseError( IXMLDOMParseError *iface )
49 {
50     return (parse_error_t *)((char*)iface - FIELD_OFFSET(parse_error_t, lpVtbl));
51 }
52
53 static HRESULT WINAPI parseError_QueryInterface(
54     IXMLDOMParseError *iface,
55     REFIID riid,
56     void** ppvObject )
57 {
58     TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
59
60     if ( IsEqualGUID( riid, &IID_IUnknown ) ||
61          IsEqualGUID( riid, &IID_IDispatch ) ||
62          IsEqualGUID( riid, &IID_IXMLDOMParseError ) )
63     {
64         *ppvObject = iface;
65     }
66     else
67         return E_NOINTERFACE;
68
69     IXMLDOMParseError_AddRef( iface );
70
71     return S_OK;
72 }
73
74 static ULONG WINAPI parseError_AddRef(
75     IXMLDOMParseError *iface )
76 {
77     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
78     ULONG ref = InterlockedIncrement( &This->ref );
79     TRACE("(%p) ref now %ld\n", This, ref);
80     return ref;
81 }
82
83 static ULONG WINAPI parseError_Release(
84     IXMLDOMParseError *iface )
85 {
86     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
87     ULONG ref;
88
89     ref = InterlockedDecrement( &This->ref );
90     TRACE("(%p) ref now %ld\n", This, ref);
91     if ( ref == 0 )
92     {
93         SysFreeString(This->url);
94         SysFreeString(This->reason);
95         SysFreeString(This->srcText);
96         HeapFree( GetProcessHeap(), 0, This );
97     }
98
99     return ref;
100 }
101
102 static HRESULT WINAPI parseError_GetTypeInfoCount(
103     IXMLDOMParseError *iface,
104     UINT* pctinfo )
105 {
106     FIXME("\n");
107     return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI parseError_GetTypeInfo(
111     IXMLDOMParseError *iface,
112     UINT iTInfo,
113     LCID lcid,
114     ITypeInfo** ppTInfo )
115 {
116     FIXME("\n");
117     return E_NOTIMPL;
118 }
119
120 static HRESULT WINAPI parseError_GetIDsOfNames(
121     IXMLDOMParseError *iface,
122     REFIID riid,
123     LPOLESTR* rgszNames,
124     UINT cNames,
125     LCID lcid,
126     DISPID* rgDispId )
127 {
128     FIXME("\n");
129     return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI parseError_Invoke(
133     IXMLDOMParseError *iface,
134     DISPID dispIdMember,
135     REFIID riid,
136     LCID lcid,
137     WORD wFlags,
138     DISPPARAMS* pDispParams,
139     VARIANT* pVarResult,
140     EXCEPINFO* pExcepInfo,
141     UINT* puArgErr )
142 {
143     FIXME("\n");
144     return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI parseError_get_errorCode(
148     IXMLDOMParseError *iface,
149     LONG *code )
150 {
151     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
152     TRACE("(%p)->(%p)\n", This, code);
153
154     *code = This->code;
155
156     if(This->code == 0)
157         return S_FALSE;
158
159     return S_OK;
160 }
161
162 static HRESULT WINAPI parseError_get_url(
163     IXMLDOMParseError *iface,
164     BSTR *url )
165 {
166     FIXME("\n");
167     return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI parseError_get_reason(
171     IXMLDOMParseError *iface,
172     BSTR *reason )
173 {
174     FIXME("\n");
175     return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI parseError_get_srcText(
179     IXMLDOMParseError *iface,
180     BSTR *srcText )
181 {
182     FIXME("\n");
183     return E_NOTIMPL;
184 }
185
186 static HRESULT WINAPI parseError_get_line(
187     IXMLDOMParseError *iface,
188     LONG *line )
189 {
190     FIXME("\n");
191     return E_NOTIMPL;
192 }
193
194 static HRESULT WINAPI parseError_get_linepos(
195     IXMLDOMParseError *iface,
196     LONG *linepos )
197 {
198     FIXME("\n");
199     return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI parseError_get_filepos(
203     IXMLDOMParseError *iface,
204     LONG *filepos )
205 {
206     FIXME("\n");
207     return E_NOTIMPL;
208 }
209
210 static const struct IXMLDOMParseErrorVtbl parseError_vtbl =
211 {
212     parseError_QueryInterface,
213     parseError_AddRef,
214     parseError_Release,
215     parseError_GetTypeInfoCount,
216     parseError_GetTypeInfo,
217     parseError_GetIDsOfNames,
218     parseError_Invoke,
219     parseError_get_errorCode,
220     parseError_get_url,
221     parseError_get_reason,
222     parseError_get_srcText,
223     parseError_get_line,
224     parseError_get_linepos,
225     parseError_get_filepos
226 };
227
228 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
229                                       LONG line, LONG linepos, LONG filepos )
230 {
231     parse_error_t *This;
232
233     This = HeapAlloc( GetProcessHeap(), 0, sizeof(*This) );
234     if ( !This )
235         return NULL;
236
237     This->lpVtbl = &parseError_vtbl;
238     This->ref = 1;
239
240     This->code = code;
241     This->url = url;
242     This->reason = reason;
243     This->srcText = srcText;
244     This->line = line;
245     This->linepos = linepos;
246     This->filepos = filepos;
247
248     return (IXMLDOMParseError*) &This->lpVtbl;
249 }