windowscodecs: Silence fixme for IID_CMetaBitmapRenderTarget.
[wine.git] / dlls / diasymreader / main.c
blob28e0525d75c2ec9805b2ae0b19e98d94036c7a5b
1 /* Copyright (C) 2022 Esme Povirk
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 #include <stdarg.h>
20 #define COBJMACROS
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winnls.h"
25 #include "objbase.h"
26 #include "ocidl.h"
27 #include "rpcproxy.h"
29 #include "wine/debug.h"
31 #include "initguid.h"
33 #include "diasymreader_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(diasymreader);
37 typedef struct {
38 REFCLSID classid;
39 HRESULT (*constructor)(REFIID,void**);
40 } classinfo;
42 static const classinfo classes[] = {
43 {&CLSID_CorSymWriter_SxS, SymWriter_CreateInstance}
46 typedef struct {
47 IClassFactory IClassFactory_iface;
48 LONG ref;
49 const classinfo *info;
50 } ClassFactoryImpl;
52 static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
54 return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
57 static HRESULT WINAPI ClassFactoryImpl_QueryInterface(IClassFactory *iface,
58 REFIID iid, void **ppv)
60 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
61 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
63 if (!ppv) return E_INVALIDARG;
65 if (IsEqualIID(&IID_IUnknown, iid) ||
66 IsEqualIID(&IID_IClassFactory, iid))
68 *ppv = &This->IClassFactory_iface;
70 else
72 *ppv = NULL;
73 return E_NOINTERFACE;
76 IUnknown_AddRef((IUnknown*)*ppv);
77 return S_OK;
80 static ULONG WINAPI ClassFactoryImpl_AddRef(IClassFactory *iface)
82 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
83 ULONG ref = InterlockedIncrement(&This->ref);
85 TRACE("(%p) refcount=%lu\n", iface, ref);
87 return ref;
90 static ULONG WINAPI ClassFactoryImpl_Release(IClassFactory *iface)
92 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
93 ULONG ref = InterlockedDecrement(&This->ref);
95 TRACE("(%p) refcount=%lu\n", iface, ref);
97 if (ref == 0)
98 free(This);
100 return ref;
103 static HRESULT WINAPI ClassFactoryImpl_CreateInstance(IClassFactory *iface,
104 IUnknown *pUnkOuter, REFIID riid, void **ppv)
106 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
108 *ppv = NULL;
110 if (pUnkOuter) return CLASS_E_NOAGGREGATION;
112 return This->info->constructor(riid, ppv);
115 static HRESULT WINAPI ClassFactoryImpl_LockServer(IClassFactory *iface, BOOL lock)
117 TRACE("(%p, %i): stub\n", iface, lock);
118 return E_NOTIMPL;
121 static const IClassFactoryVtbl ClassFactoryImpl_Vtbl = {
122 ClassFactoryImpl_QueryInterface,
123 ClassFactoryImpl_AddRef,
124 ClassFactoryImpl_Release,
125 ClassFactoryImpl_CreateInstance,
126 ClassFactoryImpl_LockServer
129 static HRESULT ClassFactoryImpl_Constructor(const classinfo *info, REFIID riid, LPVOID *ppv)
131 ClassFactoryImpl *This;
132 HRESULT ret;
134 *ppv = NULL;
136 This = malloc(sizeof(ClassFactoryImpl));
137 if (!This) return E_OUTOFMEMORY;
139 This->IClassFactory_iface.lpVtbl = &ClassFactoryImpl_Vtbl;
140 This->ref = 1;
141 This->info = info;
143 ret = IClassFactory_QueryInterface(&This->IClassFactory_iface, riid, ppv);
144 IClassFactory_Release(&This->IClassFactory_iface);
146 return ret;
149 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
151 HRESULT ret;
152 const classinfo *info=NULL;
153 int i;
155 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
157 if (!rclsid || !iid || !ppv)
158 return E_INVALIDARG;
160 *ppv = NULL;
162 for (i=0; classes[i].classid; i++)
164 if (IsEqualCLSID(classes[i].classid, rclsid))
166 info = &classes[i];
167 break;
171 if (info)
172 ret = ClassFactoryImpl_Constructor(info, iid, ppv);
173 else
174 ret = CLASS_E_CLASSNOTAVAILABLE;
176 TRACE("<-- %08lx\n", ret);
177 return ret;