ReactOS  0.4.13-dev-241-g63286c6
array.c File Reference
#include "config.h"
#include "wine/port.h"
#include <math.h>
#include <assert.h>
#include "jscript.h"
#include "wine/debug.h"
Include dependency graph for array.c:

Go to the source code of this file.

Classes

struct  ArrayInstance
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (jscript)
 
static ArrayInstancearray_from_jsdisp (jsdisp_t *jsdisp)
 
static ArrayInstancearray_from_vdisp (vdisp_t *vdisp)
 
static ArrayInstancearray_this (vdisp_t *jsthis)
 
unsigned array_get_length (jsdisp_t *array)
 
static HRESULT get_length (script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
 
static HRESULT set_length (jsdisp_t *obj, DWORD length)
 
static WCHARidx_to_str (DWORD idx, WCHAR *ptr)
 
static HRESULT Array_get_length (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static HRESULT Array_set_length (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t value)
 
static HRESULT concat_array (jsdisp_t *array, ArrayInstance *obj, DWORD *len)
 
static HRESULT concat_obj (jsdisp_t *array, IDispatch *obj, DWORD *len)
 
static HRESULT Array_concat (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT array_join (script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, unsigned seplen, jsval_t *r)
 
static HRESULT Array_join (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_pop (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_push (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_reverse (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_shift (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_slice (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT sort_cmp (script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval_t v2, INT *cmp)
 
static HRESULT Array_sort (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_splice (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_toString (script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_toLocaleString (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_forEach (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_indexOf (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_unshift (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT Array_get_value (script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
 
static void Array_destructor (jsdisp_t *dispex)
 
static void Array_on_put (jsdisp_t *dispex, const WCHAR *name)
 
static HRESULT ArrayConstr_isArray (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT ArrayConstr_value (script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
 
static HRESULT alloc_array (script_ctx_t *ctx, jsdisp_t *object_prototype, ArrayInstance **ret)
 
HRESULT create_array_constr (script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
 
HRESULT create_array (script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
 

Variables

static const WCHAR lengthW [] = {'l','e','n','g','t','h',0}
 
static const WCHAR concatW [] = {'c','o','n','c','a','t',0}
 
static const WCHAR forEachW [] = {'f','o','r','E','a','c','h',0}
 
static const WCHAR joinW [] = {'j','o','i','n',0}
 
static const WCHAR popW [] = {'p','o','p',0}
 
static const WCHAR pushW [] = {'p','u','s','h',0}
 
static const WCHAR reverseW [] = {'r','e','v','e','r','s','e',0}
 
static const WCHAR shiftW [] = {'s','h','i','f','t',0}
 
static const WCHAR sliceW [] = {'s','l','i','c','e',0}
 
static const WCHAR sortW [] = {'s','o','r','t',0}
 
static const WCHAR spliceW [] = {'s','p','l','i','c','e',0}
 
static const WCHAR toStringW [] = {'t','o','S','t','r','i','n','g',0}
 
static const WCHAR toLocaleStringW [] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0}
 
static const WCHAR unshiftW [] = {'u','n','s','h','i','f','t',0}
 
static const WCHAR indexOfW [] = {'i','n','d','e','x','O','f',0}
 
static const WCHAR default_separatorW [] = {',',0}
 
static const builtin_prop_t Array_props []
 
static const builtin_info_t Array_info
 
static const builtin_prop_t ArrayInst_props []
 
static const builtin_info_t ArrayInst_info
 
static const WCHAR isArrayW [] = {'i','s','A','r','r','a','y',0}
 
static const builtin_prop_t ArrayConstr_props []
 
static const builtin_info_t ArrayConstr_info
 

Function Documentation

◆ alloc_array()

static HRESULT alloc_array ( script_ctx_t ctx,
jsdisp_t object_prototype,
ArrayInstance **  ret 
)
static

Definition at line 1255 of file array.c.

1256 {
1258  HRESULT hres;
1259 
1260  array = heap_alloc_zero(sizeof(ArrayInstance));
1261  if(!array)
1262  return E_OUTOFMEMORY;
1263 
1264  if(object_prototype)
1265  hres = init_dispex(&array->dispex, ctx, &Array_info, object_prototype);
1266  else
1268 
1269  if(FAILED(hres)) {
1270  heap_free(array);
1271  return hres;
1272  }
1273 
1274  *ret = array;
1275  return S_OK;
1276 }
jsdisp_t * array_constr
Definition: jscript.h:438
static const builtin_info_t ArrayInst_info
Definition: array.c:1177
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const builtin_info_t Array_info
Definition: array.c:1164
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
int ret
#define S_OK
Definition: intsafe.h:59
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:940
HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *constr)
Definition: dispex.c:1051
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by create_array(), and create_array_constr().

◆ Array_concat()

static HRESULT Array_concat ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 206 of file array.c.

208 {
209  jsdisp_t *ret;
210  DWORD len = 0;
211  HRESULT hres;
212 
213  TRACE("\n");
214 
215  hres = create_array(ctx, 0, &ret);
216  if(FAILED(hres))
217  return hres;
218 
219  hres = concat_obj(ret, jsthis->u.disp, &len);
220  if(SUCCEEDED(hres)) {
221  DWORD i;
222 
223  for(i=0; i < argc; i++) {
226  else
228  if(FAILED(hres))
229  break;
230  }
231  }
232 
233  if(FAILED(hres))
234  return hres;
235 
236  if(r)
237  *r = jsval_obj(ret);
238  else
240  return S_OK;
241 }
static int argc
Definition: ServiceArgs.c:12
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
union vdisp_t::@418 u
#define argv
Definition: mplay32.c:18
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
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
IDispatch * disp
Definition: jscript.h:138
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
HRESULT create_array(script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
Definition: array.c:1310
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len)
Definition: array.c:188
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ Array_destructor()

static void Array_destructor ( jsdisp_t dispex)
static

Definition at line 1120 of file array.c.

1121 {
1122  heap_free(dispex);
1123 }
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ Array_forEach()

static HRESULT Array_forEach ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 954 of file array.c.

956 {
957  jsval_t value, args[3], res;
958  jsdisp_t *jsthis;
959  unsigned length, i;
960  HRESULT hres;
961 
962  TRACE("\n");
963 
964  /* FIXME: Check IsCallable */
965  if(argc != 1 || !is_object_instance(argv[0])) {
966  FIXME("Unsupported arguments\n");
967  return E_NOTIMPL;
968  }
969 
970  hres = get_length(ctx, vthis, &jsthis, &length);
971  if(FAILED(hres))
972  return hres;
973 
974  for(i = 0; i < length; i++) {
975  hres = jsdisp_get_idx(jsthis, i, &value);
976  if(hres == DISP_E_UNKNOWNNAME)
977  continue;
978  if(FAILED(hres))
979  return hres;
980 
981  args[0] = value;
982  args[1] = jsval_number(i);
983  args[2] = jsval_obj(jsthis);
986  if(FAILED(hres))
987  return hres;
989  }
990 
991  if(r) *r = jsval_undefined();
992  return S_OK;
993 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:189
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
Definition: match.c:390
#define DISPATCH_METHOD
Definition: oleauto.h:1006
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
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLsizei const GLfloat * value
Definition: glext.h:6069
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
#define ARRAY_SIZE(a)
Definition: main.h:24
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
#define E_NOTIMPL
Definition: ddrawi.h:99
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: dispex.c:1249
GLuint res
Definition: glext.h:9613
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ array_from_jsdisp()

static ArrayInstance* array_from_jsdisp ( jsdisp_t jsdisp)
inlinestatic

Definition at line 55 of file array.c.

56 {
57  return CONTAINING_RECORD(jsdisp, ArrayInstance, dispex);
58 }
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 array_from_vdisp(), Array_get_length(), array_get_length(), Array_get_value(), Array_on_put(), Array_set_length(), concat_obj(), and set_length().

◆ array_from_vdisp()

static ArrayInstance* array_from_vdisp ( vdisp_t vdisp)
inlinestatic

Definition at line 60 of file array.c.

61 {
62  return array_from_jsdisp(vdisp->u.jsdisp);
63 }
union vdisp_t::@418 u
jsdisp_t * jsdisp
Definition: jscript.h:140
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55

Referenced by array_this().

◆ array_get_length()

unsigned array_get_length ( jsdisp_t array)

Definition at line 70 of file array.c.

71 {
74 }
#define assert(x)
Definition: debug.h:53
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55
DWORD length
Definition: array.c:34

Referenced by stringify_array().

◆ Array_get_length()

static HRESULT Array_get_length ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 130 of file array.c.

131 {
132  TRACE("%p\n", jsthis);
133 
134  *r = jsval_number(array_from_jsdisp(jsthis)->length);
135  return S_OK;
136 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55
#define S_OK
Definition: intsafe.h:59
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Array_get_value()

static HRESULT Array_get_value ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t r 
)
static

Definition at line 1110 of file array.c.

1111 {
1113 
1114  TRACE("\n");
1115 
1116  return array_join(ctx, &array->dispex, array->length, default_separatorW,
1118 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static const WCHAR default_separatorW[]
Definition: array.c:53
static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, unsigned seplen, jsval_t *r)
Definition: array.c:243
#define TRACE(s)
Definition: solgame.cpp:4
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55

◆ Array_indexOf()

static HRESULT Array_indexOf ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 995 of file array.c.

997 {
998  jsdisp_t *jsthis;
999  unsigned length, i, from = 0;
1000  jsval_t search, value;
1001  BOOL eq;
1002  HRESULT hres;
1003 
1004  TRACE("\n");
1005 
1006  hres = get_length(ctx, vthis, &jsthis, &length);
1007  if(FAILED(hres))
1008  return hres;
1009  if(!length) {
1010  if(r) *r = jsval_number(-1);
1011  return S_OK;
1012  }
1013 
1014  search = argc ? argv[0] : jsval_undefined();
1015 
1016  if(argc > 1) {
1017  double from_arg;
1018 
1019  hres = to_integer(ctx, argv[1], &from_arg);
1020  if(FAILED(hres))
1021  return hres;
1022 
1023  if(from_arg >= 0)
1024  from = min(from_arg, length);
1025  else
1026  from = max(from_arg + length, 0);
1027  }
1028 
1029  for(i = from; i < length; i++) {
1030  hres = jsdisp_get_idx(jsthis, i, &value);
1031  if(hres == DISP_E_UNKNOWNNAME)
1032  continue;
1033  if(FAILED(hres))
1034  return hres;
1035 
1038  if(FAILED(hres))
1039  return hres;
1040  if(eq) {
1041  if(r) *r = jsval_number(i);
1042  return S_OK;
1043  }
1044  }
1045 
1046  if(r) *r = jsval_number(-1);
1047  return S_OK;
1048 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static short search(int val, const short *table, int size)
Definition: msg711.c:255
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:189
#define max(a, b)
Definition: svc.c:63
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
#define eq(received, expected, label, type)
Definition: locale.c:144
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 int BOOL
Definition: ntddk_ex.h:94
HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:529
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLsizei const GLfloat * value
Definition: glext.h:6069
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
#define min(a, b)
Definition: monoChain.cc:55
CardRegion * from
Definition: spigame.cpp:19
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ array_join()

static HRESULT array_join ( script_ctx_t ctx,
jsdisp_t array,
DWORD  length,
const WCHAR sep,
unsigned  seplen,
jsval_t r 
)
static

Definition at line 243 of file array.c.

245 {
246  jsstr_t **str_tab, *ret = NULL;
247  jsval_t val;
248  DWORD i;
249  HRESULT hres = E_FAIL;
250 
251  if(!length) {
252  if(r)
253  *r = jsval_string(jsstr_empty());
254  return S_OK;
255  }
256 
257  str_tab = heap_alloc_zero(length * sizeof(*str_tab));
258  if(!str_tab)
259  return E_OUTOFMEMORY;
260 
261  for(i=0; i < length; i++) {
262  hres = jsdisp_get_idx(array, i, &val);
263  if(hres == DISP_E_UNKNOWNNAME) {
264  hres = S_OK;
265  continue;
266  } else if(FAILED(hres))
267  break;
268 
269  if(!is_undefined(val) && !is_null(val)) {
270  hres = to_string(ctx, val, str_tab+i);
272  if(FAILED(hres))
273  break;
274  }
275  }
276 
277  if(SUCCEEDED(hres)) {
278  DWORD len = 0;
279 
280  if(str_tab[0])
281  len = jsstr_length(str_tab[0]);
282  for(i=1; i < length; i++) {
283  len += seplen;
284  if(str_tab[i])
285  len += jsstr_length(str_tab[i]);
286  if(len > JSSTR_MAX_LENGTH) {
288  break;
289  }
290  }
291 
292  if(SUCCEEDED(hres)) {
293  WCHAR *ptr = NULL;
294 
295  ret = jsstr_alloc_buf(len, &ptr);
296  if(ret) {
297  if(str_tab[0])
298  ptr += jsstr_flush(str_tab[0], ptr);
299 
300  for(i=1; i < length; i++) {
301  if(seplen) {
302  memcpy(ptr, sep, seplen*sizeof(WCHAR));
303  ptr += seplen;
304  }
305 
306  if(str_tab[i])
307  ptr += jsstr_flush(str_tab[i], ptr);
308  }
309  }else {
311  }
312  }
313  }
314 
315  for(i=0; i < length; i++) {
316  if(str_tab[i])
317  jsstr_release(str_tab[i]);
318  }
319  heap_free(str_tab);
320  if(FAILED(hres))
321  return hres;
322 
323  TRACE("= %s\n", debugstr_jsstr(ret));
324 
325  if(r)
326  *r = jsval_string(ret);
327  else
329  return S_OK;
330 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
#define JSSTR_MAX_LENGTH
Definition: jsstr.h:45
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define E_FAIL
Definition: ddrawi.h:102
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static PVOID ptr
Definition: dispmode.c:27
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
jsstr_t * jsstr_empty(void)
Definition: jsstr.c:288
smooth NULL
Definition: ftsmooth.c:416
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
const char * debugstr_jsstr(jsstr_t *str)
Definition: jsstr.c:37
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL is_null(jsval_t v)
Definition: jsval.h:176
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by Array_get_value(), Array_join(), and Array_toString().

◆ Array_join()

static HRESULT Array_join ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 333 of file array.c.

335 {
336  jsdisp_t *jsthis;
337  DWORD length;
338  HRESULT hres;
339 
340  TRACE("\n");
341 
342  hres = get_length(ctx, vthis, &jsthis, &length);
343  if(FAILED(hres))
344  return hres;
345 
346  if(argc) {
347  const WCHAR *sep;
348  jsstr_t *sep_str;
349 
350  hres = to_flat_string(ctx, argv[0], &sep_str, &sep);
351  if(FAILED(hres))
352  return hres;
353 
354  hres = array_join(ctx, jsthis, length, sep, jsstr_length(sep_str), r);
355 
356  jsstr_release(sep_str);
357  }else {
359  }
360 
361  return hres;
362 }
static int argc
Definition: ServiceArgs.c:12
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
Definition: jsstr.h:39
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static const WCHAR default_separatorW[]
Definition: array.c:53
static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, unsigned seplen, jsval_t *r)
Definition: array.c:243
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define argv
Definition: mplay32.c:18
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76

◆ Array_on_put()

static void Array_on_put ( jsdisp_t dispex,
const WCHAR name 
)
static

Definition at line 1125 of file array.c.

1126 {
1128  const WCHAR *ptr = name;
1129  DWORD id = 0;
1130 
1131  if(!isdigitW(*ptr))
1132  return;
1133 
1134  while(*ptr && isdigitW(*ptr)) {
1135  id = id*10 + (*ptr-'0');
1136  ptr++;
1137  }
1138 
1139  if(*ptr)
1140  return;
1141 
1142  if(id >= array->length)
1143  array->length = id+1;
1144 }
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
GLuint const GLchar * name
Definition: glext.h:6031

◆ Array_pop()

static HRESULT Array_pop ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 364 of file array.c.

366 {
367  jsdisp_t *jsthis;
368  jsval_t val;
369  DWORD length;
370  HRESULT hres;
371 
372  TRACE("\n");
373 
374  hres = get_length(ctx, vthis, &jsthis, &length);
375  if(FAILED(hres))
376  return hres;
377 
378  if(!length) {
379  hres = set_length(jsthis, 0);
380  if(FAILED(hres))
381  return hres;
382 
383  if(r)
384  *r = jsval_undefined();
385  return S_OK;
386  }
387 
388  length--;
389  hres = jsdisp_get_idx(jsthis, length, &val);
390  if(SUCCEEDED(hres))
391  hres = jsdisp_delete_idx(jsthis, length);
392  else if(hres == DISP_E_UNKNOWNNAME) {
393  val = jsval_undefined();
394  hres = S_OK;
395  }else
396  return hres;
397 
398  if(SUCCEEDED(hres))
399  hres = set_length(jsthis, length);
400 
401  if(FAILED(hres)) {
403  return hres;
404  }
405 
406  if(r)
407  *r = val;
408  else
410  return hres;
411 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
Definition: dispex.c:1515
unsigned long DWORD
Definition: ntddk_ex.h:95
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
static HRESULT set_length(jsdisp_t *obj, DWORD length)
Definition: array.c:105
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76

◆ Array_push()

static HRESULT Array_push ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 414 of file array.c.

416 {
417  jsdisp_t *jsthis;
418  DWORD length = 0;
419  unsigned i;
420  HRESULT hres;
421 
422  TRACE("\n");
423 
424  hres = get_length(ctx, vthis, &jsthis, &length);
425  if(FAILED(hres))
426  return hres;
427 
428  for(i=0; i < argc; i++) {
429  hres = jsdisp_propput_idx(jsthis, length+i, argv[i]);
430  if(FAILED(hres))
431  return hres;
432  }
433 
434  hres = set_length(jsthis, length+argc);
435  if(FAILED(hres))
436  return hres;
437 
438  if(r)
440  return S_OK;
441 }
static int argc
Definition: ServiceArgs.c:12
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
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
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
static HRESULT set_length(jsdisp_t *obj, DWORD length)
Definition: array.c:105
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ Array_reverse()

static HRESULT Array_reverse ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 443 of file array.c.

445 {
446  jsdisp_t *jsthis;
447  DWORD length, k, l;
448  jsval_t v1, v2;
449  HRESULT hres1, hres2;
450 
451  TRACE("\n");
452 
453  hres1 = get_length(ctx, vthis, &jsthis, &length);
454  if(FAILED(hres1))
455  return hres1;
456 
457  for(k=0; k<length/2; k++) {
458  l = length-k-1;
459 
460  hres1 = jsdisp_get_idx(jsthis, k, &v1);
461  if(FAILED(hres1) && hres1!=DISP_E_UNKNOWNNAME)
462  return hres1;
463 
464  hres2 = jsdisp_get_idx(jsthis, l, &v2);
465  if(FAILED(hres2) && hres2!=DISP_E_UNKNOWNNAME) {
466  jsval_release(v1);
467  return hres2;
468  }
469 
470  if(hres1 == DISP_E_UNKNOWNNAME)
471  hres1 = jsdisp_delete_idx(jsthis, l);
472  else
473  hres1 = jsdisp_propput_idx(jsthis, l, v1);
474 
475  if(FAILED(hres1)) {
476  jsval_release(v1);
477  jsval_release(v2);
478  return hres1;
479  }
480 
481  if(hres2 == DISP_E_UNKNOWNNAME)
482  hres2 = jsdisp_delete_idx(jsthis, k);
483  else
484  hres2 = jsdisp_propput_idx(jsthis, k, v2);
485 
486  if(FAILED(hres2)) {
487  jsval_release(v2);
488  return hres2;
489  }
490  }
491 
492  if(r)
493  *r = jsval_obj(jsdisp_addref(jsthis));
494  return S_OK;
495 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
r l[0]
Definition: byte_order.h:167
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
Definition: dispex.c:1515
unsigned long DWORD
Definition: ntddk_ex.h:95
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:258
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
GLfloat GLfloat v1
Definition: glext.h:6062
int k
Definition: mpi.c:3369
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76

◆ Array_set_length()

static HRESULT Array_set_length ( script_ctx_t ctx,
jsdisp_t jsthis,
jsval_t  value 
)
static

Definition at line 138 of file array.c.

139 {
141  DOUBLE len = -1;
142  DWORD i;
143  HRESULT hres;
144 
145  TRACE("%p %d\n", This, This->length);
146 
147  hres = to_number(ctx, value, &len);
148  if(FAILED(hres))
149  return hres;
150 
151  len = floor(len);
152  if(len!=(DWORD)len)
154 
155  for(i=len; i < This->length; i++) {
156  hres = jsdisp_delete_idx(&This->dispex, i);
157  if(FAILED(hres))
158  return hres;
159  }
160 
161  This->length = len;
162  return S_OK;
163 }
HRESULT throw_range_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:418
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
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
Definition: dispex.c:1515
unsigned long DWORD
Definition: ntddk_ex.h:95
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59
#define JS_E_INVALID_LENGTH
Definition: jscript.h:568
double DOUBLE
Definition: typedefs.h:68
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)

◆ Array_shift()

static HRESULT Array_shift ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 498 of file array.c.

500 {
501  jsdisp_t *jsthis;
502  DWORD length = 0, i;
503  jsval_t v, ret;
504  HRESULT hres;
505 
506  TRACE("\n");
507 
508  hres = get_length(ctx, vthis, &jsthis, &length);
509  if(FAILED(hres))
510  return hres;
511 
512  if(!length) {
513  hres = set_length(jsthis, 0);
514  if(FAILED(hres))
515  return hres;
516 
517  if(r)
518  *r = jsval_undefined();
519  return S_OK;
520  }
521 
522  hres = jsdisp_get_idx(jsthis, 0, &ret);
523  if(hres == DISP_E_UNKNOWNNAME) {
524  ret = jsval_undefined();
525  hres = S_OK;
526  }
527 
528  for(i=1; SUCCEEDED(hres) && i<length; i++) {
529  hres = jsdisp_get_idx(jsthis, i, &v);
530  if(hres == DISP_E_UNKNOWNNAME)
531  hres = jsdisp_delete_idx(jsthis, i-1);
532  else if(SUCCEEDED(hres))
533  hres = jsdisp_propput_idx(jsthis, i-1, v);
534  }
535 
536  if(SUCCEEDED(hres)) {
537  hres = jsdisp_delete_idx(jsthis, length-1);
538  if(SUCCEEDED(hres))
539  hres = set_length(jsthis, length-1);
540  }
541 
542  if(FAILED(hres))
543  return hres;
544 
545  if(r)
546  *r = ret;
547  else
549  return hres;
550 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
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
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
Definition: dispex.c:1515
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
static HRESULT set_length(jsdisp_t *obj, DWORD length)
Definition: array.c:105
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76

◆ Array_slice()

static HRESULT Array_slice ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 553 of file array.c.

554 {
555  jsdisp_t *arr, *jsthis;
556  DOUBLE range;
557  DWORD length, start, end, idx;
558  HRESULT hres;
559 
560  TRACE("\n");
561 
562  hres = get_length(ctx, vthis, &jsthis, &length);
563  if(FAILED(hres))
564  return hres;
565 
566  if(argc) {
567  hres = to_number(ctx, argv[0], &range);
568  if(FAILED(hres))
569  return hres;
570 
571  range = floor(range);
572  if(-range>length || isnan(range)) start = 0;
573  else if(range < 0) start = range+length;
574  else if(range <= length) start = range;
575  else start = length;
576  }
577  else start = 0;
578 
579  if(argc > 1) {
580  hres = to_number(ctx, argv[1], &range);
581  if(FAILED(hres))
582  return hres;
583 
584  range = floor(range);
585  if(-range>length) end = 0;
586  else if(range < 0) end = range+length;
587  else if(range <= length) end = range;
588  else end = length;
589  }
590  else end = length;
591 
592  hres = create_array(ctx, (end>start)?end-start:0, &arr);
593  if(FAILED(hres))
594  return hres;
595 
596  for(idx=start; idx<end; idx++) {
597  jsval_t v;
598 
599  hres = jsdisp_get_idx(jsthis, idx, &v);
600  if(hres == DISP_E_UNKNOWNNAME)
601  continue;
602 
603  if(SUCCEEDED(hres)) {
604  hres = jsdisp_propput_idx(arr, idx-start, v);
605  jsval_release(v);
606  }
607 
608  if(FAILED(hres)) {
609  jsdisp_release(arr);
610  return hres;
611  }
612  }
613 
614  if(r)
615  *r = jsval_obj(arr);
616  else
617  jsdisp_release(arr);
618 
619  return S_OK;
620 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:189
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint end
Definition: gl.h:1545
#define argv
Definition: mplay32.c:18
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
unsigned int idx
Definition: utils.c:41
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLint * range
Definition: glext.h:7539
int isnan(double x)
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
const GLdouble * v
Definition: gl.h:2040
GLuint start
Definition: gl.h:1545
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
HRESULT create_array(script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
Definition: array.c:1310
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
double DOUBLE
Definition: typedefs.h:68
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76

◆ Array_sort()

static HRESULT Array_sort ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 677 of file array.c.

679 {
680  jsdisp_t *jsthis, *cmp_func = NULL;
681  jsval_t *vtab, **sorttab = NULL;
682  DWORD length;
683  DWORD i;
684  HRESULT hres = S_OK;
685 
686  TRACE("\n");
687 
688  hres = get_length(ctx, vthis, &jsthis, &length);
689  if(FAILED(hres))
690  return hres;
691 
692  if(argc > 1) {
693  WARN("invalid arg_cnt %d\n", argc);
694  return E_FAIL;
695  }
696 
697  if(argc == 1) {
698  if(!is_object_instance(argv[0])) {
699  WARN("arg is not dispatch\n");
700  return E_FAIL;
701  }
702 
705  WARN("cmp_func is not a function\n");
706  if(cmp_func)
708  return E_FAIL;
709  }
710  }
711 
712  if(!length) {
713  if(cmp_func)
715  if(r)
716  *r = jsval_obj(jsdisp_addref(jsthis));
717  return S_OK;
718  }
719 
720  vtab = heap_alloc_zero(length * sizeof(*vtab));
721  if(vtab) {
722  for(i=0; i<length; i++) {
723  hres = jsdisp_get_idx(jsthis, i, vtab+i);
724  if(hres == DISP_E_UNKNOWNNAME) {
725  vtab[i] = jsval_undefined();
726  hres = S_OK;
727  } else if(FAILED(hres)) {
728  WARN("Could not get elem %d: %08x\n", i, hres);
729  break;
730  }
731  }
732  }else {
734  }
735 
736  if(SUCCEEDED(hres)) {
737  sorttab = heap_alloc(length*2*sizeof(*sorttab));
738  if(!sorttab)
740  }
741 
742  /* merge-sort */
743  if(SUCCEEDED(hres)) {
744  jsval_t *tmpv, **tmpbuf;
745  INT cmp;
746 
747  tmpbuf = sorttab + length;
748  for(i=0; i < length; i++)
749  sorttab[i] = vtab+i;
750 
751  for(i=0; i < length/2; i++) {
752  hres = sort_cmp(ctx, cmp_func, *sorttab[2*i+1], *sorttab[2*i], &cmp);
753  if(FAILED(hres))
754  break;
755 
756  if(cmp < 0) {
757  tmpv = sorttab[2*i];
758  sorttab[2*i] = sorttab[2*i+1];
759  sorttab[2*i+1] = tmpv;
760  }
761  }
762 
763  if(SUCCEEDED(hres)) {
764  DWORD k, a, b, bend;
765 
766  for(k=2; k < length; k *= 2) {
767  for(i=0; i+k < length; i += 2*k) {
768  a = b = 0;
769  if(i+2*k <= length)
770  bend = k;
771  else
772  bend = length - (i+k);
773 
774  memcpy(tmpbuf, sorttab+i, k*sizeof(jsval_t*));
775 
776  while(a < k && b < bend) {
777  hres = sort_cmp(ctx, cmp_func, *tmpbuf[a], *sorttab[i+k+b], &cmp);
778  if(FAILED(hres))
779  break;
780 
781  if(cmp < 0) {
782  sorttab[i+a+b] = tmpbuf[a];
783  a++;
784  }else {
785  sorttab[i+a+b] = sorttab[i+k+b];
786  b++;
787  }
788  }
789 
790  if(FAILED(hres))
791  break;
792 
793  if(a < k)
794  memcpy(sorttab+i+a+b, tmpbuf+a, (k-a)*sizeof(jsval_t*));
795  }
796 
797  if(FAILED(hres))
798  break;
799  }
800  }
801 
802  for(i=0; SUCCEEDED(hres) && i < length; i++)
803  hres = jsdisp_propput_idx(jsthis, i, *sorttab[i]);
804  }
805 
806  if(vtab) {
807  for(i=0; i < length; i++)
808  jsval_release(vtab[i]);
809  heap_free(vtab);
810  }
811  heap_free(sorttab);
812  if(cmp_func)
814 
815  if(FAILED(hres))
816  return hres;
817 
818  if(r)
819  *r = jsval_obj(jsdisp_addref(jsthis));
820  return S_OK;
821 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:189
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
#define cmp(status, error)
Definition: error.c:114
#define argv
Definition: mplay32.c:18
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:56
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
#define a
Definition: ke_i.h:78
smooth NULL
Definition: ftsmooth.c:416
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
#define b
Definition: ke_i.h:79
int(* cmp_func)(const void *ptr1, const void *ptr2)
Definition: btrfs.c:36
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:258
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval_t v2, INT *cmp)
Definition: array.c:622
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
int k
Definition: mpi.c:3369
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ Array_splice()

static HRESULT Array_splice ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 824 of file array.c.

826 {
827  DWORD length, start=0, delete_cnt=0, i, add_args = 0;
828  jsdisp_t *ret_array = NULL, *jsthis;
829  jsval_t val;
830  double d;
831  int n;
832  HRESULT hres = S_OK;
833 
834  TRACE("\n");
835 
836  hres = get_length(ctx, vthis, &jsthis, &length);
837  if(FAILED(hres))
838  return hres;
839 
840  if(argc) {
841  hres = to_integer(ctx, argv[0], &d);
842  if(FAILED(hres))
843  return hres;
844 
845  if(is_int32(d)) {
846  if((n = d) >= 0)
847  start = min(n, length);
848  else
849  start = -n > length ? 0 : length + n;
850  }else {
851  start = d < 0.0 ? 0 : length;
852  }
853  }
854 
855  if(argc >= 2) {
856  hres = to_integer(ctx, argv[1], &d);
857  if(FAILED(hres))
858  return hres;
859 
860  if(is_int32(d)) {
861  if((n = d) > 0)
862  delete_cnt = min(n, length-start);
863  }else if(d > 0.0) {
864  delete_cnt = length-start;
865  }
866 
867  add_args = argc-2;
868  }
869 
870  if(r) {
871  hres = create_array(ctx, 0, &ret_array);
872  if(FAILED(hres))
873  return hres;
874 
875  for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) {
876  hres = jsdisp_get_idx(jsthis, start+i, &val);
877  if(hres == DISP_E_UNKNOWNNAME) {
878  hres = S_OK;
879  }else if(SUCCEEDED(hres)) {
880  hres = jsdisp_propput_idx(ret_array, i, val);
882  }
883  }
884 
885  if(SUCCEEDED(hres))
886  hres = jsdisp_propput_name(ret_array, lengthW, jsval_number(delete_cnt));
887  }
888 
889  if(add_args < delete_cnt) {
890  for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) {
891  hres = jsdisp_get_idx(jsthis, i+delete_cnt, &val);
892  if(hres == DISP_E_UNKNOWNNAME) {
893  hres = jsdisp_delete_idx(jsthis, i+add_args);
894  }else if(SUCCEEDED(hres)) {
895  hres = jsdisp_propput_idx(jsthis, i+add_args, val);
897  }
898  }
899 
900  for(i=length; SUCCEEDED(hres) && i != length-delete_cnt+add_args; i--)
901  hres = jsdisp_delete_idx(jsthis, i-1);
902  }else if(add_args > delete_cnt) {
903  for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) {
904  hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &val);
905  if(hres == DISP_E_UNKNOWNNAME) {
906  hres = jsdisp_delete_idx(jsthis, i+add_args-1);
907  }else if(SUCCEEDED(hres)) {
908  hres = jsdisp_propput_idx(jsthis, i+add_args-1, val);
910  }
911  }
912  }
913 
914  for(i=0; SUCCEEDED(hres) && i < add_args; i++)
915  hres = jsdisp_propput_idx(jsthis, start+i, argv[i+2]);
916 
917  if(SUCCEEDED(hres))
918  hres = jsdisp_propput_name(jsthis, lengthW, jsval_number(length-delete_cnt+add_args));
919 
920  if(FAILED(hres)) {
921  if(ret_array)
922  jsdisp_release(ret_array);
923  return hres;
924  }
925 
926  if(r)
927  *r = jsval_obj(ret_array);
928  return S_OK;
929 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:189
static const WCHAR lengthW[]
Definition: array.c:37
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
#define argv
Definition: mplay32.c:18
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
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
Definition: dispex.c:1515
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
GLuint start
Definition: gl.h:1545
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
HRESULT create_array(script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
Definition: array.c:1310
#define min(a, b)
Definition: monoChain.cc:55
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1365
static BOOL is_int32(double d)
Definition: jscript.h:515
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ array_this()

static ArrayInstance* array_this ( vdisp_t jsthis)
inlinestatic

Definition at line 65 of file array.c.

66 {
67  return is_vclass(jsthis, JSCLASS_ARRAY) ? array_from_vdisp(jsthis) : NULL;
68 }
smooth NULL
Definition: ftsmooth.c:416
static ArrayInstance * array_from_vdisp(vdisp_t *vdisp)
Definition: array.c:60
static BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
Definition: jscript.h:502

Referenced by Array_toString(), and get_length().

◆ Array_toLocaleString()

static HRESULT Array_toLocaleString ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 947 of file array.c.

949 {
950  FIXME("\n");
951  return E_NOTIMPL;
952 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Array_toString()

static HRESULT Array_toString ( script_ctx_t ctx,
vdisp_t jsthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 932 of file array.c.

934 {
936 
937  TRACE("\n");
938 
939  array = array_this(jsthis);
940  if(!array)
942 
943  return array_join(ctx, &array->dispex, array->length, default_separatorW,
945 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define JS_E_ARRAY_EXPECTED
Definition: jscript.h:569
static const WCHAR default_separatorW[]
Definition: array.c:53
static HRESULT array_join(script_ctx_t *ctx, jsdisp_t *array, DWORD length, const WCHAR *sep, unsigned seplen, jsval_t *r)
Definition: array.c:243
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static ArrayInstance * array_this(vdisp_t *jsthis)
Definition: array.c:65
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320

◆ Array_unshift()

static HRESULT Array_unshift ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1051 of file array.c.

1053 {
1054  jsdisp_t *jsthis;
1055  WCHAR buf[14], *buf_end, *str;
1056  DWORD i, length;
1057  jsval_t val;
1058  DISPID id;
1059  HRESULT hres;
1060 
1061  TRACE("\n");
1062 
1063  hres = get_length(ctx, vthis, &jsthis, &length);
1064  if(FAILED(hres))
1065  return hres;
1066 
1067  if(argc) {
1068  buf_end = buf + ARRAY_SIZE(buf)-1;
1069  *buf_end-- = 0;
1070  i = length;
1071 
1072  while(i--) {
1073  str = idx_to_str(i, buf_end);
1074 
1075  hres = jsdisp_get_id(jsthis, str, 0, &id);
1076  if(SUCCEEDED(hres)) {
1077  hres = jsdisp_propget(jsthis, id, &val);
1078  if(FAILED(hres))
1079  return hres;
1080 
1081  hres = jsdisp_propput_idx(jsthis, i+argc, val);
1082  jsval_release(val);
1083  }else if(hres == DISP_E_UNKNOWNNAME) {
1084  hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id);
1085  }
1086  }
1087 
1088  if(FAILED(hres))
1089  return hres;
1090  }
1091 
1092  for(i=0; i<argc; i++) {
1093  hres = jsdisp_propput_idx(jsthis, i, argv[i]);
1094  if(FAILED(hres))
1095  return hres;
1096  }
1097 
1098  if(argc) {
1099  length += argc;
1100  hres = set_length(jsthis, length);
1101  if(FAILED(hres))
1102  return hres;
1103  }
1104 
1105  if(r)
1106  *r = ctx->version < 2 ? jsval_undefined() : jsval_number(length);
1107  return S_OK;
1108 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
static int argc
Definition: ServiceArgs.c:12
void jsval_release(jsval_t val)
Definition: jsutils.c:189
HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val)
Definition: dispex.c:1468
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
union vdisp_t::@418 u
#define argv
Definition: mplay32.c:18
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
const WCHAR * str
DWORD version
Definition: jscript.h:415
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
IDispatchEx * dispex
Definition: jscript.h:139
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
static WCHAR * idx_to_str(DWORD idx, WCHAR *ptr)
Definition: array.c:115
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1088
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
static jsval_t jsval_undefined(void)
Definition: jsval.h:137
#define S_OK
Definition: intsafe.h:59
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define ARRAY_SIZE(a)
Definition: main.h:24
static HRESULT set_length(jsdisp_t *obj, DWORD length)
Definition: array.c:105
GLenum GLuint id
Definition: glext.h:5579
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
Definition: array.c:76
static jsval_t jsval_number(double n)
Definition: jsval.h:144

◆ ArrayConstr_isArray()

static HRESULT ArrayConstr_isArray ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1187 of file array.c.

1188 {
1189  jsdisp_t *obj;
1190 
1191  TRACE("\n");
1192 
1193  if(!argc || !is_object_instance(argv[0])) {
1194  if(r) *r = jsval_bool(FALSE);
1195  return S_OK;
1196  }
1197 
1199  if(r) *r = jsval_bool(obj && is_class(obj, JSCLASS_ARRAY));
1200  if(obj) jsdisp_release(obj);
1201  return S_OK;
1202 }
static int argc
Definition: ServiceArgs.c:12
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define argv
Definition: mplay32.c:18
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
#define TRACE(s)
Definition: solgame.cpp:4
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
#define S_OK
Definition: intsafe.h:59
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101

◆ ArrayConstr_value()

static HRESULT ArrayConstr_value ( script_ctx_t ctx,
vdisp_t vthis,
WORD  flags,
unsigned  argc,
jsval_t argv,
jsval_t r 
)
static

Definition at line 1204 of file array.c.

1206 {
1207  jsdisp_t *obj;
1208  DWORD i;
1209  HRESULT hres;
1210 
1211  TRACE("\n");
1212 
1213  switch(flags) {
1214  case DISPATCH_METHOD:
1215  case DISPATCH_CONSTRUCT: {
1216  if(argc == 1 && is_number(argv[0])) {
1217  double n = get_number(argv[0]);
1218 
1219  if(n < 0 || !is_int32(n))
1221 
1222  hres = create_array(ctx, n, &obj);
1223  if(FAILED(hres))
1224  return hres;
1225 
1226  *r = jsval_obj(obj);
1227  return S_OK;
1228  }
1229 
1230  hres = create_array(ctx, argc, &obj);
1231  if(FAILED(hres))
1232  return hres;
1233 
1234  for(i=0; i < argc; i++) {
1236  if(FAILED(hres))
1237  break;
1238  }
1239  if(FAILED(hres)) {
1241  return hres;
1242  }
1243 
1244  *r = jsval_obj(obj);
1245  break;
1246  }
1247  default:
1248  FIXME("unimplemented flags: %x\n", flags);
1249  return E_NOTIMPL;
1250  }
1251 
1252  return S_OK;
1253 }
static int argc
Definition: ServiceArgs.c:12
HRESULT throw_range_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:418
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
#define argv
Definition: mplay32.c:18
static BOOL is_number(jsval_t v)
Definition: jsval.h:191
#define DISPATCH_METHOD
Definition: oleauto.h:1006
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
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
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
static double get_number(jsval_t v)
Definition: jsval.h:224
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT create_array(script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
Definition: array.c:1310
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
#define JS_E_INVALID_LENGTH
Definition: jscript.h:568
static BOOL is_int32(double d)
Definition: jscript.h:515

Referenced by create_array_constr().

◆ concat_array()

static HRESULT concat_array ( jsdisp_t array,
ArrayInstance obj,
DWORD len 
)
static

Definition at line 165 of file array.c.

166 {
167  jsval_t val;
168  DWORD i;
169  HRESULT hres;
170 
171  for(i=0; i < obj->length; i++) {
172  hres = jsdisp_get_idx(&obj->dispex, i, &val);
173  if(hres == DISP_E_UNKNOWNNAME)
174  continue;
175  if(FAILED(hres))
176  return hres;
177 
180  if(FAILED(hres))
181  return hres;
182  }
183 
184  *len += obj->length;
185  return S_OK;
186 }
Definition: jsval.h:54
#define DISP_E_UNKNOWNNAME
Definition: winerror.h:2515
void jsval_release(jsval_t val)
Definition: jsutils.c:189
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
GLuint GLfloat * val
Definition: glext.h:7180
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446

Referenced by concat_obj().

◆ concat_obj()

static HRESULT concat_obj ( jsdisp_t array,
IDispatch obj,
DWORD len 
)
static

Definition at line 188 of file array.c.

189 {
190  jsdisp_t *jsobj;
191  HRESULT hres;
192 
193  jsobj = iface_to_jsdisp(obj);
194  if(jsobj) {
195  if(is_class(jsobj, JSCLASS_ARRAY)) {
197  jsdisp_release(jsobj);
198  return hres;
199  }
200  jsdisp_release(jsobj);
201  }
202 
203  return jsdisp_propput_idx(array, (*len)++, jsval_disp(obj));
204 }
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55
GLenum GLsizei len
Definition: glext.h:6722
jsdisp_t * iface_to_jsdisp(IDispatch *iface)
Definition: dispex.c:1081
HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val)
Definition: dispex.c:1370
static HRESULT concat_array(jsdisp_t *array, ArrayInstance *obj, DWORD *len)
Definition: array.c:165
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264

Referenced by Array_concat().

◆ create_array()

HRESULT create_array ( script_ctx_t ctx,
DWORD  length,
jsdisp_t **  ret 
)

Definition at line 1310 of file array.c.

1311 {
1313  HRESULT hres;
1314 
1315  hres = alloc_array(ctx, NULL, &array);
1316  if(FAILED(hres))
1317  return hres;
1318 
1319  array->length = length;
1320 
1321  *ret = &array->dispex;
1322  return S_OK;
1323 }
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
int ret
static HRESULT alloc_array(script_ctx_t *ctx, jsdisp_t *object_prototype, ArrayInstance **ret)
Definition: array.c:1255
#define S_OK
Definition: intsafe.h:59
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320

Referenced by Array_concat(), Array_slice(), Array_splice(), ArrayConstr_value(), create_match_array(), interp_carray(), parse_json_value(), regexp_string_match(), String_split(), and VBArray_toArray().

◆ create_array_constr()

HRESULT create_array_constr ( script_ctx_t ctx,
jsdisp_t object_prototype,
jsdisp_t **  ret 
)

Definition at line 1293 of file array.c.

1294 {
1296  HRESULT hres;
1297 
1298  static const WCHAR ArrayW[] = {'A','r','r','a','y',0};
1299 
1300  hres = alloc_array(ctx, object_prototype, &array);
1301  if(FAILED(hres))
1302  return hres;
1303 
1305 
1306  jsdisp_release(&array->dispex);
1307  return hres;
1308 }
#define PROPF_CONSTR
Definition: jscript.h:95
HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
Definition: function.c:679
static const builtin_info_t ArrayConstr_info
Definition: array.c:1284
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static HRESULT ArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:1204
static const WCHAR ArrayW[]
Definition: global.c:34
int ret
static HRESULT alloc_array(script_ctx_t *ctx, jsdisp_t *object_prototype, ArrayInstance **ret)
Definition: array.c:1255
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:264
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320

Referenced by init_constructors().

◆ get_length()

static HRESULT get_length ( script_ctx_t ctx,
vdisp_t vdisp,
jsdisp_t **  jsthis,
DWORD ret 
)
static

Definition at line 76 of file array.c.

77 {
79  jsval_t val;
80  HRESULT hres;
81 
82  array = array_this(vdisp);
83  if(array) {
84  *jsthis = &array->dispex;
85  *ret = array->length;
86  return S_OK;
87  }
88 
89  if(!is_jsdisp(vdisp))
91 
93  if(FAILED(hres))
94  return hres;
95 
96  hres = to_uint32(ctx, val, ret);
98  if(FAILED(hres))
99  return hres;
100 
101  *jsthis = vdisp->u.jsdisp;
102  return S_OK;
103 }
HRESULT to_uint32(script_ctx_t *, jsval_t, UINT32 *) DECLSPEC_HIDDEN
Definition: jsutils.c:678
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
static const WCHAR lengthW[]
Definition: array.c:37
union vdisp_t::@418 u
smooth NULL
Definition: ftsmooth.c:416
jsdisp_t * jsdisp
Definition: jscript.h:140
GLuint GLfloat * val
Definition: glext.h:7180
HRESULT hres
Definition: protocol.c:465
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1429
LONG HRESULT
Definition: typedefs.h:77
static ArrayInstance * array_this(vdisp_t *jsthis)
Definition: array.c:65
int ret
#define S_OK
Definition: intsafe.h:59
#define JS_E_JSCRIPT_EXPECTED
Definition: jscript.h:562
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
static BOOL is_jsdisp(vdisp_t *vdisp)
Definition: jscript.h:153
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 GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum GLdouble GLenum GLint GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLenum GLfloat GLenum GLfloat GLenum GLushort const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLenum GLint GLenum GLint GLenum GLint GLuint GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble const GLfloat GLenum const GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble GLint GLint GLsizei GLsizei GLenum GLuint GLenum array
Definition: glfuncs.h:320

Referenced by Array_forEach(), Array_indexOf(), Array_join(), Array_pop(), Array_push(), Array_reverse(), Array_shift(), Array_slice(), Array_sort(), Array_splice(), and Array_unshift().

◆ idx_to_str()

static WCHAR* idx_to_str ( DWORD  idx,
WCHAR ptr 
)
static

Definition at line 115 of file array.c.

116 {
117  if(!idx) {
118  *ptr = '0';
119  return ptr;
120  }
121 
122  while(idx) {
123  *ptr-- = '0' + (idx%10);
124  idx /= 10;
125  }
126 
127  return ptr+1;
128 }
static PVOID ptr
Definition: dispmode.c:27
unsigned int idx
Definition: utils.c:41

Referenced by Array_unshift().

◆ set_length()

static HRESULT set_length ( jsdisp_t obj,
DWORD  length 
)
static

Definition at line 105 of file array.c.

106 {
107  if(is_class(obj, JSCLASS_ARRAY)) {
109  return S_OK;
110  }
111 
113 }
static const WCHAR lengthW[]
Definition: array.c:37
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:497
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55
DWORD length
Definition: array.c:34
#define S_OK
Definition: intsafe.h:59
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1365
static jsval_t jsval_number(double n)
Definition: jsval.h:144

Referenced by Array_pop(), Array_push(), Array_shift(), and Array_unshift().

◆ sort_cmp()

static HRESULT sort_cmp ( script_ctx_t ctx,
jsdisp_t cmp_func,
jsval_t  v1,
jsval_t  v2,
INT cmp 
)
static

Definition at line 622 of file array.c.

623 {
624  HRESULT hres;
625 
626  if(cmp_func) {
627  jsval_t args[2];
628  jsval_t res;
629  double n;
630 
631  args[0] = v1;
632  args[1] = v2;
633 
635  if(FAILED(hres))
636  return hres;
637 
638  hres = to_number(ctx, res, &n);
640  if(FAILED(hres))
641  return hres;
642 
643  if(n == 0)
644  *cmp = 0;
645  *cmp = n > 0.0 ? 1 : -1;
646  }else if(is_undefined(v1)) {
647  *cmp = is_undefined(v2) ? 0 : 1;
648  }else if(is_undefined(v2)) {
649  *cmp = -1;
650  }else if(is_number(v1) && is_number(v2)) {
651  double d = get_number(v1)-get_number(v2);
652  if(d > 0.0)
653  *cmp = 1;
654  else
655  *cmp = d < -0.0 ? -1 : 0;
656  }else {
657  jsstr_t *x, *y;
658 
659  hres = to_string(ctx, v1, &x);
660  if(FAILED(hres))
661  return hres;
662 
663  hres = to_string(ctx, v2, &y);
664  if(SUCCEEDED(hres)) {
665  *cmp = jsstr_cmp(x, y);
666  jsstr_release(y);
667  }
668  jsstr_release(x);
669  if(FAILED(hres))
670  return hres;
671  }
672 
673  return S_OK;
674 }
Definition: jsval.h:54
void jsval_release(jsval_t val)
Definition: jsutils.c:189
Definition: jsstr.h:39
GLdouble n
Definition: glext.h:7729
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define cmp(status, error)
Definition: error.c:114
static BOOL is_number(jsval_t v)
Definition: jsval.h:191
Definition: match.c:390
#define DISPATCH_METHOD
Definition: oleauto.h:1006
int jsstr_cmp(jsstr_t *str1, jsstr_t *str2)
Definition: jsstr.c:189
HRESULT to_number(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:601
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
smooth NULL
Definition: ftsmooth.c:416
int(* cmp_func)(const void *ptr1, const void *ptr2)
Definition: btrfs.c:36
HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: dispex.c:1110
HRESULT hres
Definition: protocol.c:465
#define d
Definition: ke_i.h:81
LONG HRESULT
Definition: typedefs.h:77
static double get_number(jsval_t v)
Definition: jsval.h:224
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
#define S_OK
Definition: intsafe.h:59
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint res
Definition: glext.h:9613
GLfloat GLfloat v1
Definition: glext.h:6062
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by Array_sort().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( jscript  )

Variable Documentation

◆ Array_info

const builtin_info_t Array_info
static
Initial value:
= {
}
static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
Definition: array.c:1125
static HRESULT Array_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: array.c:1110
smooth NULL
Definition: ftsmooth.c:416
static void Array_destructor(jsdisp_t *dispex)
Definition: array.c:1120
#define ARRAY_SIZE(a)
Definition: main.h:24
static const builtin_prop_t Array_props[]
Definition: array.c:1146

Definition at line 1164 of file array.c.

Referenced by alloc_array().

◆ Array_props

const builtin_prop_t Array_props[]
static
Initial value:
= {
}
#define PROPF_ES5
Definition: jscript.h:105
static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:947
static const WCHAR lengthW[]
Definition: array.c:37
static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:932
static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:443
static HRESULT Array_set_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t value)
Definition: array.c:138
static const WCHAR sliceW[]
Definition: array.c:45
static const WCHAR toStringW[]
Definition: array.c:48
static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:333
static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:498
static const WCHAR popW[]
Definition: array.c:41
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR shiftW[]
Definition: array.c:44
static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:364
static const WCHAR unshiftW[]
Definition: array.c:50
static HRESULT Array_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: array.c:130
static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:824
static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:414
static HRESULT Array_slice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:553
static const WCHAR reverseW[]
Definition: array.c:43
static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:677
static const WCHAR sortW[]
Definition: array.c:46
static const WCHAR joinW[]
Definition: array.c:40
static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:1051
static const WCHAR forEachW[]
Definition: array.c:39
#define PROPF_METHOD
Definition: jscript.h:94
static const WCHAR toLocaleStringW[]
Definition: array.c:49
static const WCHAR pushW[]
Definition: array.c:42
static HRESULT Array_forEach(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:954
static const WCHAR spliceW[]
Definition: array.c:47
static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:206
static const WCHAR concatW[]
Definition: array.c:38
static HRESULT Array_indexOf(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:995
static const WCHAR indexOfW[]
Definition: array.c:51

Definition at line 1146 of file array.c.

◆ ArrayConstr_info

const builtin_info_t ArrayConstr_info
static
Initial value:
= {
}
smooth NULL
Definition: ftsmooth.c:416
#define DEFAULT_FUNCTION_VALUE
Definition: jscript.h:310
static const builtin_prop_t ArrayConstr_props[]
Definition: array.c:1280
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 1284 of file array.c.

Referenced by create_array_constr().

◆ ArrayConstr_props

const builtin_prop_t ArrayConstr_props[]
static
Initial value:
= {
}
#define PROPF_ES5
Definition: jscript.h:105
static HRESULT ArrayConstr_isArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
Definition: array.c:1187
static const WCHAR isArrayW[]
Definition: array.c:1278
#define PROPF_METHOD
Definition: jscript.h:94

Definition at line 1280 of file array.c.

◆ ArrayInst_info

const builtin_info_t ArrayInst_info
static
Initial value:
= {
}
static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
Definition: array.c:1125
static HRESULT Array_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: array.c:1110
static const builtin_prop_t ArrayInst_props[]
Definition: array.c:1173
smooth NULL
Definition: ftsmooth.c:416
static void Array_destructor(jsdisp_t *dispex)
Definition: array.c:1120
#define ARRAY_SIZE(a)
Definition: main.h:24

Definition at line 1177 of file array.c.

Referenced by alloc_array().

◆ ArrayInst_props

const builtin_prop_t ArrayInst_props[]
static
Initial value:
= {
}
static const WCHAR lengthW[]
Definition: array.c:37
static HRESULT Array_set_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t value)
Definition: array.c:138
smooth NULL
Definition: ftsmooth.c:416
static HRESULT Array_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: array.c:130

Definition at line 1173 of file array.c.

◆ concatW

const WCHAR concatW[] = {'c','o','n','c','a','t',0}
static

Definition at line 38 of file array.c.

◆ default_separatorW

const WCHAR default_separatorW[] = {',',0}
static

Definition at line 53 of file array.c.

Referenced by Array_get_value(), Array_join(), and Array_toString().

◆ forEachW

const WCHAR forEachW[] = {'f','o','r','E','a','c','h',0}
static

Definition at line 39 of file array.c.

◆ indexOfW

const WCHAR indexOfW[] = {'i','n','d','e','x','O','f',0}
static

Definition at line 51 of file array.c.

◆ isArrayW

const WCHAR isArrayW[] = {'i','s','A','r','r','a','y',0}
static

Definition at line 1278 of file array.c.

◆ joinW

const WCHAR joinW[] = {'j','o','i','n',0}
static

Definition at line 40 of file array.c.

◆ lengthW

const WCHAR lengthW[] = {'l','e','n','g','t','h',0}
static

Definition at line 37 of file array.c.

Referenced by Array_splice(), get_length(), read_bitmap_patterns(), and set_length().

◆ popW

const WCHAR popW[] = {'p','o','p',0}
static

Definition at line 41 of file array.c.

◆ pushW

const WCHAR pushW[] = {'p','u','s','h',0}
static

Definition at line 42 of file array.c.

◆ reverseW

const WCHAR reverseW[] = {'r','e','v','e','r','s','e',0}
static

Definition at line 43 of file array.c.

◆ shiftW

const WCHAR shiftW[] = {'s','h','i','f','t',0}
static

Definition at line 44 of file array.c.

◆ sliceW

const WCHAR sliceW[] = {'s','l','i','c','e',0}
static

Definition at line 45 of file array.c.

◆ sortW

const WCHAR sortW[] = {'s','o','r','t',0}
static

Definition at line 46 of file array.c.

◆ spliceW

const WCHAR spliceW[] = {'s','p','l','i','c','e',0}
static

Definition at line 47 of file array.c.

◆ toLocaleStringW

const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0}
static

Definition at line 49 of file array.c.

◆ toStringW

const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}
static

Definition at line 48 of file array.c.

Referenced by to_primitive().

◆ unshiftW

const WCHAR unshiftW[] = {'u','n','s','h','i','f','t',0}
static

Definition at line 50 of file array.c.