ReactOS  0.4.14-dev-77-gd9e7c48
array.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "config.h"
20 #include "wine/port.h"
21 
22 #include <math.h>
23 #include <assert.h>
24 
25 #include "jscript.h"
26 
27 #include "wine/debug.h"
28 
30 
31 typedef struct {
33 
36 
37 static const WCHAR lengthW[] = {'l','e','n','g','t','h',0};
38 static const WCHAR concatW[] = {'c','o','n','c','a','t',0};
39 static const WCHAR forEachW[] = {'f','o','r','E','a','c','h',0};
40 static const WCHAR joinW[] = {'j','o','i','n',0};
41 static const WCHAR popW[] = {'p','o','p',0};
42 static const WCHAR pushW[] = {'p','u','s','h',0};
43 static const WCHAR reverseW[] = {'r','e','v','e','r','s','e',0};
44 static const WCHAR shiftW[] = {'s','h','i','f','t',0};
45 static const WCHAR sliceW[] = {'s','l','i','c','e',0};
46 static const WCHAR sortW[] = {'s','o','r','t',0};
47 static const WCHAR spliceW[] = {'s','p','l','i','c','e',0};
48 static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
49 static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0};
50 static const WCHAR unshiftW[] = {'u','n','s','h','i','f','t',0};
51 static const WCHAR indexOfW[] = {'i','n','d','e','x','O','f',0};
52 
53 static const WCHAR default_separatorW[] = {',',0};
54 
55 static inline ArrayInstance *array_from_jsdisp(jsdisp_t *jsdisp)
56 {
57  return CONTAINING_RECORD(jsdisp, ArrayInstance, dispex);
58 }
59 
60 static inline ArrayInstance *array_from_vdisp(vdisp_t *vdisp)
61 {
62  return array_from_jsdisp(vdisp->u.jsdisp);
63 }
64 
65 static inline ArrayInstance *array_this(vdisp_t *jsthis)
66 {
67  return is_vclass(jsthis, JSCLASS_ARRAY) ? array_from_vdisp(jsthis) : NULL;
68 }
69 
71 {
74 }
75 
76 static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, DWORD *ret)
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 }
104 
106 {
107  if(is_class(obj, JSCLASS_ARRAY)) {
109  return S_OK;
110  }
111 
113 }
114 
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 }
129 
131 {
132  TRACE("%p\n", jsthis);
133 
134  *r = jsval_number(array_from_jsdisp(jsthis)->length);
135  return S_OK;
136 }
137 
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 }
164 
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 }
187 
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 }
205 
206 static HRESULT Array_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
207  jsval_t *r)
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 }
242 
244  unsigned seplen, jsval_t *r)
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 }
331 
332 /* ECMA-262 3rd Edition 15.4.4.5 */
333 static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
334  jsval_t *r)
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 }
363 
364 static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
365  jsval_t *r)
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 }
412 
413 /* ECMA-262 3rd Edition 15.4.4.7 */
414 static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
415  jsval_t *r)
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 }
442 
444  jsval_t *r)
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 }
496 
497 /* ECMA-262 3rd Edition 15.4.4.9 */
498 static HRESULT Array_shift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
499  jsval_t *r)
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 }
551 
552 /* ECMA-262 3rd Edition 15.4.4.10 */
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 }
621 
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 }
675 
676 /* ECMA-262 3rd Edition 15.4.4.11 */
677 static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
678  jsval_t *r)
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 }
822 
823 /* ECMA-262 3rd Edition 15.4.4.12 */
824 static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
825  jsval_t *r)
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 }
930 
931 /* ECMA-262 3rd Edition 15.4.4.2 */
933  jsval_t *r)
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 }
946 
948  jsval_t *r)
949 {
950  FIXME("\n");
951  return E_NOTIMPL;
952 }
953 
955  jsval_t *r)
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 }
994 
996  jsval_t *r)
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 }
1049 
1050 /* ECMA-262 3rd Edition 15.4.4.13 */
1052  jsval_t *r)
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 }
1109 
1111 {
1113 
1114  TRACE("\n");
1115 
1116  return array_join(ctx, &array->dispex, array->length, default_separatorW,
1118 }
1119 
1120 static void Array_destructor(jsdisp_t *dispex)
1121 {
1122  heap_free(dispex);
1123 }
1124 
1125 static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
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 }
1145 
1146 static const builtin_prop_t Array_props[] = {
1162 };
1163 
1164 static const builtin_info_t Array_info = {
1165  JSCLASS_ARRAY,
1166  {NULL, NULL,0, Array_get_value},
1168  Array_props,
1170  Array_on_put
1171 };
1172 
1175 };
1176 
1178  JSCLASS_ARRAY,
1179  {NULL, NULL,0, Array_get_value},
1183  Array_on_put
1184 };
1185 
1186 /* ECMA-262 5.1 Edition 15.4.3.2 */
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 }
1203 
1205  jsval_t *r)
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 }
1254 
1255 static HRESULT alloc_array(script_ctx_t *ctx, jsdisp_t *object_prototype, ArrayInstance **ret)
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 }
1277 
1278 static const WCHAR isArrayW[] = {'i','s','A','r','r','a','y',0};
1279 
1282 };
1283 
1289  NULL,
1290  NULL
1291 };
1292 
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 }
1309 
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 }
HRESULT to_uint32(script_ctx_t *, jsval_t, UINT32 *) DECLSPEC_HIDDEN
Definition: jsutils.c:678
#define PROPF_ES5
Definition: jscript.h:105
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
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
#define max(a, b)
Definition: svc.c:63
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
HRESULT throw_range_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:418
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
jsdisp_t * array_constr
Definition: jscript.h:439
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
HRESULT jsdisp_propget(jsdisp_t *jsdisp, DISPID id, jsval_t *val)
Definition: dispex.c:1468
HRESULT to_integer(script_ctx_t *, jsval_t, double *) DECLSPEC_HIDDEN
Definition: jsutils.c:640
Definition: jsstr.h:39
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static IDispatch * get_object(jsval_t v)
Definition: jsval.h:219
static HRESULT Array_set_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t value)
Definition: array.c:138
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
#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 WCHAR sliceW[]
Definition: array.c:45
unsigned array_get_length(jsdisp_t *array)
Definition: array.c:70
#define JS_E_ARRAY_EXPECTED
Definition: jscript.h:573
static const WCHAR toStringW[]
Definition: array.c:48
GLdouble n
Definition: glext.h:7729
static const WCHAR default_separatorW[]
Definition: array.c:53
static BOOL is_undefined(jsval_t v)
Definition: jsval.h:171
static const builtin_info_t ArrayInst_info
Definition: array.c:1177
static unsigned jsstr_flush(jsstr_t *str, WCHAR *buf)
Definition: jsstr.h:148
#define assert(x)
Definition: debug.h: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 JSSTR_MAX_LENGTH
Definition: jsstr.h:45
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
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static unsigned jsstr_length(jsstr_t *str)
Definition: jsstr.h:58
GLuint GLuint end
Definition: gl.h:1545
static const builtin_info_t ArrayConstr_info
Definition: array.c:1284
static void jsstr_release(jsstr_t *str)
Definition: jsstr.h:110
#define cmp(status, error)
Definition: error.c:114
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
#define argv
Definition: mplay32.c:18
static BOOL is_number(jsval_t v)
Definition: jsval.h:191
#define E_FAIL
Definition: ddrawi.h:102
Definition: match.c:390
#define eq(received, expected, label, type)
Definition: locale.c:144
int32_t INT
Definition: typedefs.h:56
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define DISPATCH_METHOD
Definition: oleauto.h:1006
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
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
Definition: array.c:1125
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int 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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
static HRESULT Array_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
Definition: array.c:1110
static BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
Definition: jscript.h:500
#define a
Definition: ke_i.h:78
static const WCHAR popW[]
Definition: array.c:41
static const builtin_prop_t ArrayInst_props[]
Definition: array.c:1173
jsdisp_t dispex
Definition: array.c:32
#define FIXME(fmt,...)
Definition: debug.h:110
static PVOID ptr
Definition: dispmode.c:27
static HRESULT to_string(VARIANT *src, BSTR *dst)
Definition: host.c:48
unsigned int idx
Definition: utils.c:41
const WCHAR * str
jsstr_t * jsstr_empty(void)
Definition: jsstr.c:288
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
DWORD version
Definition: jscript.h:416
static const WCHAR unshiftW[]
Definition: array.c:50
jsdisp_t * jsdisp
Definition: jscript.h:141
static BOOL is_object_instance(jsval_t v)
Definition: jsval.h:166
static ArrayInstance * array_from_vdisp(vdisp_t *vdisp)
Definition: array.c:60
static void Array_destructor(jsdisp_t *dispex)
Definition: array.c:1120
static jsval_t jsval_string(jsstr_t *str)
Definition: jsval.h:109
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
#define b
Definition: ke_i.h:79
GLuint GLfloat * val
Definition: glext.h:7180
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
r l[0]
Definition: byte_order.h:167
HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
Definition: engine.c:529
static const builtin_info_t Array_info
Definition: array.c:1164
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
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
const char * debugstr_jsstr(jsstr_t *str)
Definition: jsstr.c:37
static jsval_t jsval_disp(IDispatch *obj)
Definition: jsval.h:117
HRESULT hres
Definition: protocol.c:465
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
#define d
Definition: ke_i.h:81
IDispatch * disp
Definition: jscript.h:139
HRESULT jsdisp_propget_name(jsdisp_t *obj, const WCHAR *name, jsval_t *val)
Definition: dispex.c:1429
__wchar_t WCHAR
Definition: xmlstorage.h:180
IDispatchEx * dispex
Definition: jscript.h:140
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
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR reverseW[]
Definition: array.c:43
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
static BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
Definition: jscript.h:505
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
HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
Definition: dispex.c:1515
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
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL is_null(jsval_t v)
Definition: jsval.h:176
static const WCHAR sortW[]
Definition: array.c:46
static jsdisp_t * jsdisp_addref(jsdisp_t *jsdisp)
Definition: jscript.h:259
static const WCHAR ArrayW[]
Definition: global.c:34
GLbitfield flags
Definition: glext.h:7161
static const WCHAR isArrayW[]
Definition: array.c:1278
static ArrayInstance * array_this(vdisp_t *jsthis)
Definition: array.c:65
static double get_number(jsval_t v)
Definition: jsval.h:224
static WCHAR * idx_to_str(DWORD idx, WCHAR *ptr)
Definition: array.c:115
int ret
static ArrayInstance * array_from_jsdisp(jsdisp_t *jsdisp)
Definition: array.c:55
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
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *id)
Definition: dispex.c:1088
static const WCHAR forEachW[]
Definition: array.c:39
GLsizei const GLfloat * value
Definition: glext.h:6069
#define DEFAULT_FUNCTION_VALUE
Definition: jscript.h:311
DWORD length
Definition: array.c:34
GLenum GLint * range
Definition: glext.h:7539
static HRESULT alloc_array(script_ctx_t *ctx, jsdisp_t *object_prototype, ArrayInstance **ret)
Definition: array.c:1255
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
int isnan(double x)
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
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define S_OK
Definition: intsafe.h:59
static const builtin_prop_t ArrayConstr_props[]
Definition: array.c:1280
const GLdouble * v
Definition: gl.h:2040
#define PROPF_METHOD
Definition: jscript.h:94
static HRESULT concat_array(jsdisp_t *array, ArrayInstance *obj, DWORD *len)
Definition: array.c:165
GLuint start
Definition: gl.h:1545
#define ARRAY_SIZE(a)
Definition: main.h:24
WINE_DEFAULT_DEBUG_CHANNEL(jscript)
HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r)
Definition: dispex.c:1446
#define E_NOTIMPL
Definition: ddrawi.h:99
#define JS_E_JSCRIPT_EXPECTED
Definition: jscript.h:565
HRESULT create_array(script_ctx_t *ctx, DWORD length, jsdisp_t **ret)
Definition: array.c:1310
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
#define min(a, b)
Definition: monoChain.cc:55
static void jsdisp_release(jsdisp_t *jsdisp)
Definition: jscript.h:265
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:940
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static jsval_t jsval_obj(jsdisp_t *obj)
Definition: jsval.h:125
static const WCHAR toLocaleStringW[]
Definition: array.c:49
static HRESULT set_length(jsdisp_t *obj, DWORD length)
Definition: array.c:105
jsstr_t * jsstr_alloc_buf(unsigned len, WCHAR **buf)
Definition: jsstr.c:69
#define JS_E_INVALID_LENGTH
Definition: jscript.h:572
static const WCHAR pushW[]
Definition: array.c:42
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
Definition: name.c:36
GLuint res
Definition: glext.h:9613
HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val)
Definition: dispex.c:1365
GLenum GLuint id
Definition: glext.h:5579
double DOUBLE
Definition: typedefs.h:68
HRESULT throw_type_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str)
Definition: error.c:438
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 builtin_prop_t Array_props[]
Definition: array.c:1146
static jsval_t jsval_bool(BOOL b)
Definition: jsval.h:101
HRESULT create_array_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp_t **ret)
Definition: array.c:1293
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP double __cdecl floor(_In_ double x)
CardRegion * from
Definition: spigame.cpp:19
union vdisp_t::@420 u
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
static const WCHAR spliceW[]
Definition: array.c:47
static BOOL is_int32(double d)
Definition: jscript.h:518
GLfloat GLfloat v1
Definition: glext.h:6062
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 HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len)
Definition: array.c:188
int k
Definition: mpi.c:3369
static const WCHAR concatW[]
Definition: array.c:38
HRESULT to_flat_string(script_ctx_t *, jsval_t, jsstr_t **, const WCHAR **) DECLSPEC_HIDDEN
Definition: jsutils.c:790
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 BOOL is_jsdisp(vdisp_t *vdisp)
Definition: jscript.h:154
#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
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 jsval_t jsval_number(double n)
Definition: jsval.h:144
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static const WCHAR indexOfW[]
Definition: array.c:51
GLuint const GLchar * name
Definition: glext.h:6031