Get rid of the non-standard ICOM_VTABLE macro.
[wine/wine-gecko.git] / dlls / dmloader / classfactory.c
blobc06d38f24216734b96029a8254ccc8aca2813c59
1 /* IDirectMusicLoaderCF
2 * IDirectMusicContainerCF
4 * Copyright (C) 2004 Rok Mandeljc
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "dmloader_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
25 /*****************************************************************************
26 * IDirectMusicLoaderCF implementation
28 HRESULT WINAPI IDirectMusicLoaderCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
29 ICOM_THIS(IDirectMusicLoaderCF, iface);
31 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
32 if (IsEqualIID (riid, &IID_IUnknown) ||
33 IsEqualIID (riid, &IID_IClassFactory)) {
34 IDirectMusicLoaderCF_AddRef (iface);
35 *ppobj = This;
36 return S_OK;
39 WARN(": not found\n");
40 return E_NOINTERFACE;
43 ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface) {
44 ICOM_THIS(IDirectMusicLoaderCF, iface);
45 TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
46 return InterlockedIncrement (&This->dwRef);
49 ULONG WINAPI IDirectMusicLoaderCF_Release (LPCLASSFACTORY iface) {
50 ICOM_THIS(IDirectMusicLoaderCF, iface);
52 DWORD dwRef = InterlockedDecrement (&This->dwRef);
53 TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
54 if (dwRef == 0) {
55 HeapFree(GetProcessHeap (), 0, This);
56 /* decrease number of instances */
57 InterlockedDecrement(&dwDirectMusicLoader);
60 return dwRef;
63 HRESULT WINAPI IDirectMusicLoaderCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
64 ICOM_THIS(IDirectMusicLoaderCF, iface);
66 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
67 if (pOuter) {
68 ERR(": pOuter should be NULL\n");
69 return CLASS_E_NOAGGREGATION;
72 return DMUSIC_CreateDirectMusicLoaderImpl (riid, ppobj, pOuter);
75 HRESULT WINAPI IDirectMusicLoaderCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
76 ICOM_THIS(IDirectMusicLoaderCF, iface);
77 TRACE("(%p, %d)\n", This, dolock);
78 if (dolock == TRUE)
79 InterlockedIncrement (&dwDirectMusicLoader);
80 else
81 InterlockedDecrement (&dwDirectMusicLoader);
82 return S_OK;
85 IClassFactoryVtbl DirectMusicLoaderCF_Vtbl = {
86 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
87 IDirectMusicLoaderCF_QueryInterface,
88 IDirectMusicLoaderCF_AddRef,
89 IDirectMusicLoaderCF_Release,
90 IDirectMusicLoaderCF_CreateInstance,
91 IDirectMusicLoaderCF_LockServer
94 HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
95 IDirectMusicLoaderCF *obj;
97 TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
98 obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderCF));
99 if (NULL == obj) {
100 *ppobj = (LPCLASSFACTORY)NULL;
101 return E_OUTOFMEMORY;
103 obj->lpVtbl = &DirectMusicLoaderCF_Vtbl;
104 obj->dwRef = 0; /* will be inited with QueryInterface */
106 /* increase number of instances */
107 InterlockedIncrement (&dwDirectMusicLoader);
109 return IDirectMusicLoaderCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);
113 /*****************************************************************************
114 * IDirectMusicContainerCF implementation
116 HRESULT WINAPI IDirectMusicContainerCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
117 ICOM_THIS(IDirectMusicContainerCF, iface);
119 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
120 if (IsEqualIID (riid, &IID_IUnknown) ||
121 IsEqualIID (riid, &IID_IClassFactory)) {
122 IDirectMusicContainerCF_AddRef (iface);
123 *ppobj = This;
124 return S_OK;
127 WARN(": not found\n");
128 return E_NOINTERFACE;
131 ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface) {
132 ICOM_THIS(IDirectMusicContainerCF, iface);
133 TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
134 return InterlockedIncrement (&This->dwRef);
137 ULONG WINAPI IDirectMusicContainerCF_Release (LPCLASSFACTORY iface) {
138 ICOM_THIS(IDirectMusicContainerCF, iface);
140 DWORD dwRef = InterlockedDecrement (&This->dwRef);
141 TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
142 if (dwRef == 0) {
143 HeapFree(GetProcessHeap (), 0, This);
144 /* decrease number of instances */
145 InterlockedDecrement(&dwDirectMusicContainer);
148 return dwRef;
151 HRESULT WINAPI IDirectMusicContainerCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
152 ICOM_THIS(IDirectMusicContainerCF, iface);
154 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
155 if (pOuter) {
156 ERR(": pOuter should be NULL\n");
157 return CLASS_E_NOAGGREGATION;
160 return DMUSIC_CreateDirectMusicContainerImpl (riid, ppobj, pOuter);
163 HRESULT WINAPI IDirectMusicContainerCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
164 ICOM_THIS(IDirectMusicContainerCF, iface);
165 TRACE("(%p, %d)\n", This, dolock);
166 if (dolock == TRUE)
167 InterlockedIncrement (&dwDirectMusicContainer);
168 else
169 InterlockedDecrement (&dwDirectMusicContainer);
170 return S_OK;
173 IClassFactoryVtbl DirectMusicContainerCF_Vtbl = {
174 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
175 IDirectMusicContainerCF_QueryInterface,
176 IDirectMusicContainerCF_AddRef,
177 IDirectMusicContainerCF_Release,
178 IDirectMusicContainerCF_CreateInstance,
179 IDirectMusicContainerCF_LockServer
182 HRESULT WINAPI DMUSIC_CreateDirectMusicContainerCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
183 IDirectMusicContainerCF *obj;
185 TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
186 obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerCF));
187 if (NULL == obj) {
188 *ppobj = (LPCLASSFACTORY)NULL;
189 return E_OUTOFMEMORY;
191 obj->lpVtbl = &DirectMusicContainerCF_Vtbl;
192 obj->dwRef = 0; /* will be inited with QueryInterface */
194 /* increase number of instances */
195 InterlockedIncrement (&dwDirectMusicContainer);
197 return IDirectMusicContainerCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);