ReactOS 0.4.16-dev-197-g92996da
utils.c
Go to the documentation of this file.
1/*
2 * Copyright 2017 Piotr Caban for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "vbscript.h"
20
21#include "wine/debug.h"
22
24
25typedef struct {
27
29
33
35{
36 return CONTAINING_RECORD(iface, safearray_iter, IEnumVARIANT_iface);
37}
38
40 IEnumVARIANT *iface, REFIID riid, void **ppv)
41{
43
45 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
46 *ppv = &This->IEnumVARIANT_iface;
47 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
48 TRACE("(%p)->(IID_IEnumVARIANT %p)\n", This, ppv);
49 *ppv = &This->IEnumVARIANT_iface;
50 }else {
51 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
52 *ppv = NULL;
53 return E_NOINTERFACE;
54 }
55
56 IUnknown_AddRef((IUnknown*)*ppv);
57 return S_OK;
58}
59
61{
64
65 TRACE("(%p) ref=%d\n", This, ref);
66
67 return ref;
68}
69
71{
74
75 TRACE("(%p) ref=%d\n", iface, ref);
76
77 if(!ref) {
78 if(This->sa)
81 }
82
83 return ref;
84}
85
87 ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
88{
91 VARIANT *v;
92
93 TRACE("(%p)->(%u %p %p)\n", This, celt, rgVar, pCeltFetched);
94
95 if(celt != 1) {
96 FIXME("celt != 1\n");
97 return E_NOTIMPL;
98 }
99
100 if(This->i >= This->size) {
101 if(pCeltFetched)
102 *pCeltFetched = 0;
103 return S_FALSE;
104 }
105
106 if(!This->sa->cLocks)
107 ERR("SAFEARRAY not locked\n");
108
109 v = (VARIANT*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements);
110 V_VT(rgVar) = VT_EMPTY;
111 hres = VariantCopy(rgVar, v);
112 if(FAILED(hres))
113 return hres;
114
115 This->i++;
116 if(pCeltFetched)
117 *pCeltFetched = 1;
118 return S_OK;
119}
120
122{
123 FIXME("\n");
124 return E_NOTIMPL;
125}
126
128{
129 FIXME("\n");
130 return E_NOTIMPL;
131}
132
134 IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
135{
136 FIXME("\n");
137 return E_NOTIMPL;
138}
139
140static const IEnumVARIANTVtbl safearray_iter_EnumVARIANTVtbl = {
148};
149
151{
152 ULONG ret = 1;
153 USHORT i;
154
155 if(!sa)
156 return 0;
157
158 for(i=0; i<sa->cDims && ret; i++)
159 ret *= sa->rgsabound[i].cElements;
160 return ret;
161}
162
164{
165 safearray_iter *iter;
167
168 if(sa && !(sa->fFeatures & FADF_VARIANT)) {
169 FIXME("enumeration not supported: %x\n", sa->fFeatures);
170 return E_NOTIMPL;
171 }
172
173 iter = heap_alloc(sizeof(*iter));
174 if(!iter)
175 return E_OUTOFMEMORY;
176
177 if(sa) {
179 if(FAILED(hres)) {
180 heap_free(iter);
181 return hres;
182 }
183 }
184
186 iter->ref = 1;
187 iter->sa = sa;
188 iter->i = 0;
189 iter->size = get_safearray_size(sa);
190
191 *ev = &iter->IEnumVARIANT_iface;
192 return S_OK;
193}
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
@ VT_EMPTY
Definition: compat.h:2295
HRESULT WINAPI SafeArrayUnlock(SAFEARRAY *psa)
Definition: safearray.c:831
HRESULT WINAPI SafeArrayLock(SAFEARRAY *psa)
Definition: safearray.c:795
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
Definition: utils.c:133
static ULONG WINAPI safearray_iter_IEnumVARIANT_Release(IEnumVARIANT *iface)
Definition: utils.c:70
static ULONG get_safearray_size(SAFEARRAY *sa)
Definition: utils.c:150
static HRESULT WINAPI safearray_iter_IEnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
Definition: utils.c:39
static const IEnumVARIANTVtbl safearray_iter_EnumVARIANTVtbl
Definition: utils.c:140
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Skip(IEnumVARIANT *iface, ULONG celt)
Definition: utils.c:121
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Reset(IEnumVARIANT *iface)
Definition: utils.c:127
HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev)
Definition: utils.c:163
static safearray_iter * impl_from_IEnumVARIANT(IEnumVARIANT *iface)
Definition: utils.c:34
static ULONG WINAPI safearray_iter_IEnumVARIANT_AddRef(IEnumVARIANT *iface)
Definition: utils.c:60
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
Definition: utils.c:86
const GLdouble * v
Definition: gl.h:2040
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hres
Definition: protocol.c:465
#define V_VT(A)
Definition: oleauto.h:211
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48
LONG ref
Definition: utils.c:28
ULONG size
Definition: utils.c:31
IEnumVARIANT IEnumVARIANT_iface
Definition: utils.c:26
SAFEARRAY * sa
Definition: utils.c:30
ULONG i
Definition: utils.c:31
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:748
int ret
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
unsigned char BYTE
Definition: xxhash.c:193