ReactOS 0.4.15-dev-7942-gd23573b
utils.c File Reference
#include "vbscript.h"
#include "wine/debug.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Classes

struct  safearray_iter
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (vbscript)
 
static safearray_iterimpl_from_IEnumVARIANT (IEnumVARIANT *iface)
 
static HRESULT WINAPI safearray_iter_IEnumVARIANT_QueryInterface (IEnumVARIANT *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI safearray_iter_IEnumVARIANT_AddRef (IEnumVARIANT *iface)
 
static ULONG WINAPI safearray_iter_IEnumVARIANT_Release (IEnumVARIANT *iface)
 
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Next (IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
 
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Skip (IEnumVARIANT *iface, ULONG celt)
 
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Reset (IEnumVARIANT *iface)
 
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Clone (IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
 
static ULONG get_safearray_size (SAFEARRAY *sa)
 
HRESULT create_safearray_iter (SAFEARRAY *sa, IEnumVARIANT **ev)
 

Variables

static const IEnumVARIANTVtbl safearray_iter_EnumVARIANTVtbl
 

Function Documentation

◆ create_safearray_iter()

HRESULT create_safearray_iter ( SAFEARRAY sa,
IEnumVARIANT **  ev 
)

Definition at line 163 of file utils.c.

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 FIXME(fmt,...)
Definition: debug.h:111
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI SafeArrayLock(SAFEARRAY *psa)
Definition: safearray.c:795
static ULONG get_safearray_size(SAFEARRAY *sa)
Definition: utils.c:150
static const IEnumVARIANTVtbl safearray_iter_EnumVARIANTVtbl
Definition: utils.c:140
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hres
Definition: protocol.c:465
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

Referenced by interp_newenum().

◆ get_safearray_size()

static ULONG get_safearray_size ( SAFEARRAY sa)
static

Definition at line 150 of file utils.c.

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}
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
unsigned short USHORT
Definition: pedump.c:61
uint32_t ULONG
Definition: typedefs.h:59
int ret

Referenced by create_safearray_iter().

◆ impl_from_IEnumVARIANT()

static safearray_iter * impl_from_IEnumVARIANT ( IEnumVARIANT iface)
inlinestatic

Definition at line 34 of file utils.c.

35{
36 return CONTAINING_RECORD(iface, safearray_iter, IEnumVARIANT_iface);
37}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by safearray_iter_IEnumVARIANT_AddRef(), safearray_iter_IEnumVARIANT_Next(), safearray_iter_IEnumVARIANT_QueryInterface(), and safearray_iter_IEnumVARIANT_Release().

◆ safearray_iter_IEnumVARIANT_AddRef()

static ULONG WINAPI safearray_iter_IEnumVARIANT_AddRef ( IEnumVARIANT iface)
static

Definition at line 60 of file utils.c.

61{
64
65 TRACE("(%p) ref=%d\n", This, ref);
66
67 return ref;
68}
#define InterlockedIncrement
Definition: armddk.h:53
static safearray_iter * impl_from_IEnumVARIANT(IEnumVARIANT *iface)
Definition: utils.c:34
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
Definition: send.c:48

◆ safearray_iter_IEnumVARIANT_Clone()

static HRESULT WINAPI safearray_iter_IEnumVARIANT_Clone ( IEnumVARIANT iface,
IEnumVARIANT **  ppEnum 
)
static

Definition at line 133 of file utils.c.

135{
136 FIXME("\n");
137 return E_NOTIMPL;
138}

◆ safearray_iter_IEnumVARIANT_Next()

static HRESULT WINAPI safearray_iter_IEnumVARIANT_Next ( IEnumVARIANT iface,
ULONG  celt,
VARIANT rgVar,
ULONG pCeltFetched 
)
static

Definition at line 86 of file utils.c.

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}
#define ERR(fmt,...)
Definition: debug.h:110
@ VT_EMPTY
Definition: compat.h:2295
const GLdouble * v
Definition: gl.h:2040
#define V_VT(A)
Definition: oleauto.h:211
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:748
#define S_FALSE
Definition: winerror.h:2357
unsigned char BYTE
Definition: xxhash.c:193

◆ safearray_iter_IEnumVARIANT_QueryInterface()

static HRESULT WINAPI safearray_iter_IEnumVARIANT_QueryInterface ( IEnumVARIANT iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 39 of file utils.c.

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}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ safearray_iter_IEnumVARIANT_Release()

static ULONG WINAPI safearray_iter_IEnumVARIANT_Release ( IEnumVARIANT iface)
static

Definition at line 70 of file utils.c.

71{
74
75 TRACE("(%p) ref=%d\n", iface, ref);
76
77 if(!ref) {
78 if(This->sa)
81 }
82
83 return ref;
84}
#define InterlockedDecrement
Definition: armddk.h:52
HRESULT WINAPI SafeArrayUnlock(SAFEARRAY *psa)
Definition: safearray.c:831

◆ safearray_iter_IEnumVARIANT_Reset()

static HRESULT WINAPI safearray_iter_IEnumVARIANT_Reset ( IEnumVARIANT iface)
static

Definition at line 127 of file utils.c.

128{
129 FIXME("\n");
130 return E_NOTIMPL;
131}

◆ safearray_iter_IEnumVARIANT_Skip()

static HRESULT WINAPI safearray_iter_IEnumVARIANT_Skip ( IEnumVARIANT iface,
ULONG  celt 
)
static

Definition at line 121 of file utils.c.

122{
123 FIXME("\n");
124 return E_NOTIMPL;
125}

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( vbscript  )

Variable Documentation

◆ safearray_iter_EnumVARIANTVtbl

const IEnumVARIANTVtbl safearray_iter_EnumVARIANTVtbl
static
Initial value:
= {
}
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 HRESULT WINAPI safearray_iter_IEnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
Definition: utils.c:39
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
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

Definition at line 140 of file utils.c.

Referenced by create_safearray_iter().