comctl32: Constify some variables.
[wine] / dlls / msxml3 / schema.c
1 /*
2  * Schema cache implementation
3  *
4  * Copyright 2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define COBJMACROS
22
23 #include "config.h"
24
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
31 #include "msxml2.h"
32
33 #include "wine/debug.h"
34
35 #include "msxml_private.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38
39
40 typedef struct
41 {
42     const struct IXMLDOMSchemaCollectionVtbl *lpVtbl;
43     LONG ref;
44 } schema_t;
45
46 static inline schema_t *impl_from_IXMLDOMSchemaCollection( IXMLDOMSchemaCollection *iface )
47 {
48     return (schema_t *)((char*)iface - FIELD_OFFSET(schema_t, lpVtbl));
49 }
50
51 static HRESULT WINAPI schema_cache_QueryInterface( IXMLDOMSchemaCollection *iface, REFIID riid, void** ppvObject )
52 {
53     schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
54
55     TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
56
57     if ( IsEqualIID( riid, &IID_IUnknown ) ||
58          IsEqualIID( riid, &IID_IDispatch ) ||
59          IsEqualIID( riid, &IID_IXMLDOMSchemaCollection ) )
60     {
61         *ppvObject = iface;
62     }
63     else
64     {
65         FIXME("interface %s not implemented\n", debugstr_guid(riid));
66         return E_NOINTERFACE;
67     }
68
69     IXMLDOMSchemaCollection_AddRef( iface );
70
71     return S_OK;
72 }
73
74 static ULONG WINAPI schema_cache_AddRef( IXMLDOMSchemaCollection *iface )
75 {
76     schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
77     LONG ref = InterlockedIncrement( &This->ref );
78     TRACE("%p new ref %d\n", This, ref);
79     return ref;
80 }
81
82 static ULONG WINAPI schema_cache_Release( IXMLDOMSchemaCollection *iface )
83 {
84     schema_t *This = impl_from_IXMLDOMSchemaCollection( iface );
85     LONG ref = InterlockedDecrement( &This->ref );
86     TRACE("%p new ref %d\n", This, ref);
87
88     if ( ref == 0 )
89     {
90         HeapFree( GetProcessHeap(), 0, This );
91     }
92
93     return ref;
94 }
95
96 static HRESULT WINAPI schema_cache_GetTypeInfoCount( IXMLDOMSchemaCollection *iface, UINT* pctinfo )
97 {
98     FIXME("\n");
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI schema_cache_GetTypeInfo( IXMLDOMSchemaCollection *iface,
103                                                 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
104 {
105     FIXME("\n");
106     return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI schema_cache_GetIDsOfNames( IXMLDOMSchemaCollection *iface,
110                                                   REFIID riid,
111                                                   LPOLESTR* rgszNames,
112                                                   UINT cNames,
113                                                   LCID lcid,
114                                                   DISPID* rgDispId )
115 {
116     FIXME("\n");
117     return E_NOTIMPL;
118 }
119
120 static HRESULT WINAPI schema_cache_Invoke( IXMLDOMSchemaCollection *iface,
121                                            DISPID dispIdMember,
122                                            REFIID riid,
123                                            LCID lcid,
124                                            WORD wFlags,
125                                            DISPPARAMS* pDispParams,
126                                            VARIANT* pVarResult,
127                                            EXCEPINFO* pExcepInfo,
128                                            UINT* puArgErr )
129 {
130     FIXME("\n");
131     return E_NOTIMPL;
132 }
133
134 static HRESULT WINAPI schema_cache_add( IXMLDOMSchemaCollection *iface, BSTR uri, VARIANT var )
135 {
136     FIXME("(%p)->(%s, var(vt %x)): stub\n", iface, debugstr_w(uri), V_VT(&var));
137     return S_OK;
138 }
139
140 static HRESULT WINAPI schema_cache_get( IXMLDOMSchemaCollection *iface, BSTR uri, IXMLDOMNode **node )
141 {
142     FIXME("stub\n");
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI schema_cache_remove( IXMLDOMSchemaCollection *iface, BSTR uri )
147 {
148     FIXME("stub\n");
149     return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI schema_cache_get_length( IXMLDOMSchemaCollection *iface, long *length )
153 {
154     FIXME("stub\n");
155     return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI schema_cache_get_namespaceURI( IXMLDOMSchemaCollection *iface, long index, BSTR *len )
159 {
160     FIXME("stub\n");
161     return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI schema_cache_addCollection( IXMLDOMSchemaCollection *iface, IXMLDOMSchemaCollection *otherCollection )
165 {
166     FIXME("stub\n");
167     return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI schema_cache_get__newEnum( IXMLDOMSchemaCollection *iface, IUnknown **ppUnk )
171 {
172     FIXME("stub\n");
173     return E_NOTIMPL;
174 }
175
176 static const struct IXMLDOMSchemaCollectionVtbl schema_vtbl =
177 {
178     schema_cache_QueryInterface,
179     schema_cache_AddRef,
180     schema_cache_Release,
181     schema_cache_GetTypeInfoCount,
182     schema_cache_GetTypeInfo,
183     schema_cache_GetIDsOfNames,
184     schema_cache_Invoke,
185     schema_cache_add,
186     schema_cache_get,
187     schema_cache_remove,
188     schema_cache_get_length,
189     schema_cache_get_namespaceURI,
190     schema_cache_addCollection,
191     schema_cache_get__newEnum
192 };
193
194 HRESULT SchemaCache_create(IUnknown *pUnkOuter, LPVOID *ppObj)
195 {
196     schema_t *schema = HeapAlloc( GetProcessHeap(), 0, sizeof (*schema) );
197     if( !schema )
198         return E_OUTOFMEMORY;
199
200     schema->lpVtbl = &schema_vtbl;
201     schema->ref = 1;
202
203     *ppObj = &schema->lpVtbl;
204     return S_OK;
205 }