push 87b6981010d7405c33b14cddcceec21b47729eba
[wine/hacks.git] / dlls / msxml3 / schema.c
blobf0a616979a0d01cff87bfdb71854d95ca81ba430
1 /*
2 * Schema cache implementation
4 * Copyright 2007 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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml2.h"
32 #include "wine/debug.h"
34 #include "msxml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
39 typedef struct
41 const struct IXMLDOMSchemaCollectionVtbl *lpVtbl;
42 LONG ref;
43 } schema_t;
45 static inline schema_t *impl_from_IXMLDOMSchemaCollection( IXMLDOMSchemaCollection *iface )
47 return (schema_t *)((char*)iface - FIELD_OFFSET(schema_t, lpVtbl));
50 static HRESULT WINAPI schema_cache_QueryInterface( IXMLDOMSchemaCollection *iface, REFIID riid, void** ppvObject )
52 schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
54 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
56 if ( IsEqualIID( riid, &IID_IUnknown ) ||
57 IsEqualIID( riid, &IID_IDispatch ) ||
58 IsEqualIID( riid, &IID_IXMLDOMSchemaCollection ) )
60 *ppvObject = iface;
62 else
64 FIXME("interface %s not implemented\n", debugstr_guid(riid));
65 return E_NOINTERFACE;
68 IXMLDOMSchemaCollection_AddRef( iface );
70 return S_OK;
73 static ULONG WINAPI schema_cache_AddRef( IXMLDOMSchemaCollection *iface )
75 schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
76 LONG ref = InterlockedIncrement( &This->ref );
77 TRACE("%p new ref %d\n", This, ref);
78 return ref;
81 static ULONG WINAPI schema_cache_Release( IXMLDOMSchemaCollection *iface )
83 schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
84 LONG ref = InterlockedDecrement( &This->ref );
85 TRACE("%p new ref %d\n", This, ref);
87 if ( ref == 0 )
89 heap_free( This );
92 return ref;
95 static HRESULT WINAPI schema_cache_GetTypeInfoCount( IXMLDOMSchemaCollection *iface, UINT* pctinfo )
97 schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
99 TRACE("(%p)->(%p)\n", This, pctinfo);
101 *pctinfo = 1;
103 return S_OK;
106 static HRESULT WINAPI schema_cache_GetTypeInfo( IXMLDOMSchemaCollection *iface,
107 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
109 schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
110 HRESULT hr;
112 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
114 hr = get_typeinfo(IXMLDOMSchemaCollection_tid, ppTInfo);
116 return hr;
119 static HRESULT WINAPI schema_cache_GetIDsOfNames( IXMLDOMSchemaCollection *iface,
120 REFIID riid,
121 LPOLESTR* rgszNames,
122 UINT cNames,
123 LCID lcid,
124 DISPID* rgDispId )
126 schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
127 ITypeInfo *typeinfo;
128 HRESULT hr;
130 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
131 lcid, rgDispId);
133 if(!rgszNames || cNames == 0 || !rgDispId)
134 return E_INVALIDARG;
136 hr = get_typeinfo(IXMLDOMSchemaCollection_tid, &typeinfo);
137 if(SUCCEEDED(hr))
139 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
140 ITypeInfo_Release(typeinfo);
143 return hr;
146 static HRESULT WINAPI schema_cache_Invoke( IXMLDOMSchemaCollection *iface,
147 DISPID dispIdMember,
148 REFIID riid,
149 LCID lcid,
150 WORD wFlags,
151 DISPPARAMS* pDispParams,
152 VARIANT* pVarResult,
153 EXCEPINFO* pExcepInfo,
154 UINT* puArgErr )
156 schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
157 ITypeInfo *typeinfo;
158 HRESULT hr;
160 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
161 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
163 hr = get_typeinfo(IXMLDOMSchemaCollection_tid, &typeinfo);
164 if(SUCCEEDED(hr))
166 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
167 pVarResult, pExcepInfo, puArgErr);
168 ITypeInfo_Release(typeinfo);
171 return hr;
174 static HRESULT WINAPI schema_cache_add( IXMLDOMSchemaCollection *iface, BSTR uri, VARIANT var )
176 FIXME("(%p)->(%s, var(vt %x)): stub\n", iface, debugstr_w(uri), V_VT(&var));
177 return S_OK;
180 static HRESULT WINAPI schema_cache_get( IXMLDOMSchemaCollection *iface, BSTR uri, IXMLDOMNode **node )
182 FIXME("stub\n");
183 return E_NOTIMPL;
186 static HRESULT WINAPI schema_cache_remove( IXMLDOMSchemaCollection *iface, BSTR uri )
188 FIXME("stub\n");
189 return E_NOTIMPL;
192 static HRESULT WINAPI schema_cache_get_length( IXMLDOMSchemaCollection *iface, LONG *length )
194 FIXME("stub\n");
195 return E_NOTIMPL;
198 static HRESULT WINAPI schema_cache_get_namespaceURI( IXMLDOMSchemaCollection *iface, LONG index, BSTR *len )
200 FIXME("stub\n");
201 return E_NOTIMPL;
204 static HRESULT WINAPI schema_cache_addCollection( IXMLDOMSchemaCollection *iface, IXMLDOMSchemaCollection *otherCollection )
206 FIXME("stub\n");
207 return E_NOTIMPL;
210 static HRESULT WINAPI schema_cache_get__newEnum( IXMLDOMSchemaCollection *iface, IUnknown **ppUnk )
212 FIXME("stub\n");
213 return E_NOTIMPL;
216 static const struct IXMLDOMSchemaCollectionVtbl schema_vtbl =
218 schema_cache_QueryInterface,
219 schema_cache_AddRef,
220 schema_cache_Release,
221 schema_cache_GetTypeInfoCount,
222 schema_cache_GetTypeInfo,
223 schema_cache_GetIDsOfNames,
224 schema_cache_Invoke,
225 schema_cache_add,
226 schema_cache_get,
227 schema_cache_remove,
228 schema_cache_get_length,
229 schema_cache_get_namespaceURI,
230 schema_cache_addCollection,
231 schema_cache_get__newEnum
234 HRESULT SchemaCache_create(IUnknown *pUnkOuter, LPVOID *ppObj)
236 schema_t *schema = heap_alloc( sizeof (*schema) );
237 if( !schema )
238 return E_OUTOFMEMORY;
240 schema->lpVtbl = &schema_vtbl;
241 schema->ref = 1;
243 *ppObj = &schema->lpVtbl;
244 return S_OK;