ReactOS  0.4.14-dev-1314-gacf135d
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;
166  HRESULT hres;
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) {
178  hres = SafeArrayLock(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 }
ULONG size
Definition: utils.c:31
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static ULONG get_safearray_size(SAFEARRAY *sa)
Definition: utils.c:150
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
static const IEnumVARIANTVtbl safearray_iter_EnumVARIANTVtbl
Definition: utils.c:140
SAFEARRAY * sa
Definition: utils.c:30
HRESULT WINAPI SafeArrayLock(SAFEARRAY *psa)
Definition: safearray.c:795
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:78
LONG ref
Definition: utils.c:28
IEnumVARIANT IEnumVARIANT_iface
Definition: utils.c:26
ULONG i
Definition: utils.c:31
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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
int ret
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
static struct sockaddr_in sa
Definition: adnsresfilter.c:69

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 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

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 }
static safearray_iter * impl_from_IEnumVARIANT(IEnumVARIANT *iface)
Definition: utils.c:34
Definition: send.c:47
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53

◆ 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 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 {
90  HRESULT hres;
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 }
static safearray_iter * impl_from_IEnumVARIANT(IEnumVARIANT *iface)
Definition: utils.c:34
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_FALSE
Definition: winerror.h:2357
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:78
#define V_VT(A)
Definition: oleauto.h:211
unsigned char BYTE
Definition: mem.h:68
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:748

◆ 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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
static safearray_iter * impl_from_IEnumVARIANT(IEnumVARIANT *iface)
Definition: utils.c:34
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ 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)
79  SafeArrayUnlock(This->sa);
80  heap_free(This);
81  }
82 
83  return ref;
84 }
static safearray_iter * impl_from_IEnumVARIANT(IEnumVARIANT *iface)
Definition: utils.c:34
Definition: send.c:47
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
HRESULT WINAPI SafeArrayUnlock(SAFEARRAY *psa)
Definition: safearray.c:831
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ 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 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ 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_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
Definition: utils.c:39
static ULONG WINAPI safearray_iter_IEnumVARIANT_Release(IEnumVARIANT *iface)
Definition: utils.c:70
static ULONG WINAPI safearray_iter_IEnumVARIANT_AddRef(IEnumVARIANT *iface)
Definition: utils.c:60
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Reset(IEnumVARIANT *iface)
Definition: utils.c:127
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Skip(IEnumVARIANT *iface, ULONG celt)
Definition: utils.c:121
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
Definition: utils.c:86
static HRESULT WINAPI safearray_iter_IEnumVARIANT_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
Definition: utils.c:133

Definition at line 140 of file utils.c.

Referenced by create_safearray_iter().