wined3d: Do not set the dynlock flag on all created surfaces.
[wine.git] / dlls / quartz / enummoniker.c
blob5c3149429369d9751a4daa4b1c2cd4dc91962197
1 /*
2 * IEnumMoniker implementation
4 * Copyright 2003 Robert Shearman
6 * This file contains the (internal) driver registration functions,
7 * driver enumeration APIs and DirectDraw creation functions.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define COBJMACROS
26 #include "quartz_private.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
32 typedef struct EnumMonikerImpl
34 const IEnumMonikerVtbl *lpVtbl;
35 LONG ref;
36 IMoniker ** ppMoniker;
37 ULONG nMonikerCount;
38 ULONG index;
39 } EnumMonikerImpl;
41 static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl;
43 static ULONG WINAPI EnumMonikerImpl_AddRef(LPENUMMONIKER iface);
45 HRESULT EnumMonikerImpl_Create(IMoniker ** ppMoniker, ULONG nMonikerCount, IEnumMoniker ** ppEnum)
47 /* NOTE: assumes that array of IMonikers has already been AddRef'd
48 * I.e. this function does not AddRef the array of incoming
49 * IMonikers */
50 EnumMonikerImpl * pemi = CoTaskMemAlloc(sizeof(EnumMonikerImpl));
52 TRACE("(%p, %d, %p)\n", ppMoniker, nMonikerCount, ppEnum);
54 *ppEnum = NULL;
56 if (!pemi)
57 return E_OUTOFMEMORY;
59 pemi->lpVtbl = &EnumMonikerImpl_Vtbl;
60 pemi->ref = 1;
61 pemi->ppMoniker = CoTaskMemAlloc(nMonikerCount * sizeof(IMoniker*));
62 memcpy(pemi->ppMoniker, ppMoniker, nMonikerCount*sizeof(IMoniker*));
63 pemi->nMonikerCount = nMonikerCount;
64 pemi->index = 0;
66 *ppEnum = (IEnumMoniker *)pemi;
68 return S_OK;
71 /**********************************************************************
72 * IEnumMoniker_QueryInterface (also IUnknown)
74 static HRESULT WINAPI EnumMonikerImpl_QueryInterface(
75 LPENUMMONIKER iface,
76 REFIID riid,
77 LPVOID *ppvObj)
79 EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
80 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
82 if (This == NULL || ppvObj == NULL) return E_POINTER;
84 if (IsEqualGUID(riid, &IID_IUnknown) ||
85 IsEqualGUID(riid, &IID_IEnumMoniker))
87 *ppvObj = (LPVOID)iface;
88 EnumMonikerImpl_AddRef(iface);
89 return S_OK;
92 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
93 return E_NOINTERFACE;
96 /**********************************************************************
97 * IEnumMoniker_AddRef (also IUnknown)
99 static ULONG WINAPI EnumMonikerImpl_AddRef(LPENUMMONIKER iface)
101 EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
102 ULONG ref;
104 if (This == NULL) return E_POINTER;
106 ref = InterlockedIncrement(&This->ref);
108 TRACE("(%p)->() AddRef from %d\n", iface, ref - 1);
110 return ref;
113 /**********************************************************************
114 * IEnumMoniker_Release (also IUnknown)
116 static ULONG WINAPI EnumMonikerImpl_Release(LPENUMMONIKER iface)
118 EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
119 ULONG ref = InterlockedDecrement(&This->ref);
121 TRACE("(%p)->() Release from %d\n", iface, ref + 1);
123 if (!ref)
125 CoTaskMemFree(This->ppMoniker);
126 This->ppMoniker = NULL;
127 CoTaskMemFree(This);
128 return 0;
130 return ref;
133 static HRESULT WINAPI EnumMonikerImpl_Next(LPENUMMONIKER iface, ULONG celt, IMoniker ** rgelt, ULONG * pceltFetched)
135 ULONG fetched;
136 EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
138 TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
140 for (fetched = 0; (This->index + fetched < This->nMonikerCount) && (fetched < celt); fetched++)
142 rgelt[fetched] = This->ppMoniker[This->index + fetched];
143 IMoniker_AddRef(rgelt[fetched]);
146 This->index += fetched;
148 TRACE("-- fetched %d\n", fetched);
150 if (pceltFetched)
151 *pceltFetched = fetched;
153 if (fetched != celt)
154 return S_FALSE;
155 else
156 return S_OK;
159 static HRESULT WINAPI EnumMonikerImpl_Skip(LPENUMMONIKER iface, ULONG celt)
161 EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
163 TRACE("(%p)->(%d)\n", iface, celt);
165 This->index += celt;
167 return S_OK;
170 static HRESULT WINAPI EnumMonikerImpl_Reset(LPENUMMONIKER iface)
172 EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
174 TRACE("(%p)->()\n", iface);
176 This->index = 0;
178 return S_OK;
181 static HRESULT WINAPI EnumMonikerImpl_Clone(LPENUMMONIKER iface, IEnumMoniker ** ppenum)
183 FIXME("(%p)->(%p): stub\n", iface, ppenum);
185 return E_NOTIMPL;
188 /**********************************************************************
189 * IEnumMoniker_Vtbl
191 static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl =
193 EnumMonikerImpl_QueryInterface,
194 EnumMonikerImpl_AddRef,
195 EnumMonikerImpl_Release,
196 EnumMonikerImpl_Next,
197 EnumMonikerImpl_Skip,
198 EnumMonikerImpl_Reset,
199 EnumMonikerImpl_Clone