ReactOS 0.4.17-dev-357-ga8f14ff
global.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 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 <assert.h>
20#include <math.h>
21
22#include "vbscript.h"
23#include "vbscript_defs.h"
24
25#include "mshtmhst.h"
26#include "objsafe.h"
27#include "wchar.h"
28
29#include "wine/debug.h"
30
31#ifdef __REACTOS__
32#include <wingdi.h>
33#include <winnls.h>
34#endif
35
37
38#define VB_E_CANNOT_CREATE_OBJ 0x800a01ad
39#define VB_E_MK_PARSE_ERROR 0x800a01b0
40
41/* Defined as extern in urlmon.idl, but not exported by uuid.lib */
43 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
44
45#define BP_GET 1
46#define BP_GETPUT 2
47
48typedef struct {
52
54 const WCHAR *name;
57 unsigned min_args;
59};
60
62{
63 return CONTAINING_RECORD(iface, BuiltinDisp, IDispatch_iface);
64}
65
67{
69
71 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
72 *ppv = &This->IDispatch_iface;
73 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
74 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
75 *ppv = &This->IDispatch_iface;
76 }else {
77 if(!IsEqualGUID(riid, &IID_IDispatchEx))
78 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
79 *ppv = NULL;
80 return E_NOINTERFACE;
81 }
82
83 IUnknown_AddRef((IUnknown*)*ppv);
84 return S_OK;
85}
86
88{
91
92 TRACE("(%p) ref=%ld\n", This, ref);
93
94 return ref;
95}
96
98{
101
102 TRACE("(%p) ref=%ld\n", This, ref);
103
104 if(!ref) {
105 assert(!This->ctx);
106 free(This);
107 }
108
109 return ref;
110}
111
113{
115 TRACE("(%p)->(%p)\n", This, pctinfo);
116 *pctinfo = 0;
117 return S_OK;
118}
119
121{
123 TRACE("(%p)->(%u %lu %p)\n", This, iTInfo, lcid, ppTInfo);
124 return DISP_E_BADINDEX;
125}
126
128{
129 size_t min = 1, max = disp->member_cnt - 1, i;
130 int r;
131
132 while(min <= max) {
133 i = (min + max) / 2;
134 r = wcsicmp(disp->members[i].name, name);
135 if(!r) {
136 *id = i;
137 return S_OK;
138 }
139 if(r < 0)
140 min = i+1;
141 else
142 max = i-1;
143 }
144
146
147}
148
149static HRESULT WINAPI Builtin_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt,
151{
153 unsigned i;
155
156 TRACE("(%p)->(%s %p %u %lu %p)\n", This, debugstr_guid(riid), names, name_cnt, lcid, ids);
157
158 if(!This->ctx) {
159 FIXME("NULL context\n");
160 return E_UNEXPECTED;
161 }
162
163 for(i = 0; i < name_cnt; i++) {
165 if(FAILED(hres))
166 return hres;
167 }
168
169 return S_OK;
170}
171
173 DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err)
174{
176 const builtin_prop_t *prop;
177 VARIANT args_buf[8], *args;
178 unsigned argn, i;
180
181 TRACE("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, id, debugstr_guid(riid), lcid, flags, dp, res, ei, err);
182
183 if(!This->ctx) {
184 FIXME("NULL context\n");
185 return E_UNEXPECTED;
186 }
187
188 if(id >= This->member_cnt || (!This->members[id].proc && !This->members[id].flags))
190 prop = This->members + id;
191
192 switch(flags) {
194 if(!(prop->flags & (BP_GET|BP_GETPUT))) {
195 FIXME("property does not support DISPATCH_PROPERTYGET\n");
196 return E_FAIL;
197 }
198 break;
200 if(!prop->proc && prop->flags == BP_GET) {
201 const int vt = prop->min_args, val = prop->max_args;
202 switch(vt) {
203 case VT_I2:
204 V_VT(res) = VT_I2;
205 V_I2(res) = val;
206 break;
207 case VT_I4:
208 V_VT(res) = VT_I4;
209 V_I4(res) = val;
210 break;
211 case VT_BSTR: {
212 const string_constant_t *str = (const string_constant_t*)prop->max_args;
213 BSTR ret;
214
215 ret = SysAllocStringLen(str->buf, str->len);
216 if(!ret)
217 return E_OUTOFMEMORY;
218
219 V_VT(res) = VT_BSTR;
220 V_BSTR(res) = ret;
221 break;
222 }
224 }
225 return S_OK;
226 }
227 break;
228 case DISPATCH_METHOD:
229 if(prop->flags & (BP_GET|BP_GETPUT)) {
230 FIXME("Call on property\n");
231 return E_FAIL;
232 }
233 break;
235 if(!(prop->flags & BP_GETPUT)) {
236 FIXME("property does not support DISPATCH_PROPERTYPUT\n");
237 return E_FAIL;
238 }
239
240 FIXME("call put\n");
241 return E_NOTIMPL;
242 default:
243 FIXME("unsupported flags %x\n", flags);
244 return E_NOTIMPL;
245 }
246
247 argn = arg_cnt(dp);
248
249 if(argn < prop->min_args || argn > (prop->max_args ? prop->max_args : prop->min_args)) {
250 WARN("invalid number of arguments\n");
252 }
253
254 if(argn <= ARRAY_SIZE(args_buf)) {
255 args = args_buf;
256 }else {
257 args = malloc(argn * sizeof(*args));
258 if(!args)
259 return E_OUTOFMEMORY;
260 }
261
262 for(i=0; i < argn; i++) {
263 if(V_VT(dp->rgvarg+dp->cArgs-i-1) == (VT_BYREF|VT_VARIANT))
264 args[i] = *V_VARIANTREF(dp->rgvarg+dp->cArgs-i-1);
265 else
266 args[i] = dp->rgvarg[dp->cArgs-i-1];
267 }
268
269 hres = prop->proc(This, args, dp->cArgs, res);
270 if(args != args_buf)
271 free(args);
272 return hres;
273}
274
275static const IDispatchVtbl BuiltinDispVtbl = {
283};
284
285static HRESULT create_builtin_dispatch(script_ctx_t *ctx, const builtin_prop_t *members, size_t member_cnt, BuiltinDisp **ret)
286{
287 BuiltinDisp *disp;
288
289 if(!(disp = malloc(sizeof(*disp))))
290 return E_OUTOFMEMORY;
291
292 disp->IDispatch_iface.lpVtbl = &BuiltinDispVtbl;
293 disp->ref = 1;
294 disp->members = members;
295 disp->member_cnt = member_cnt;
296 disp->ctx = ctx;
297
298 *ret = disp;
299 return S_OK;
300}
301
303{
307
308 if(!ctx->site)
309 return NULL;
310
311 if(ctx->secmgr)
312 return ctx->secmgr;
313
314 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
315 if(FAILED(hres))
316 return NULL;
317
318 hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager, &IID_IInternetHostSecurityManager,
319 (void**)&secmgr);
320 IServiceProvider_Release(sp);
321 if(FAILED(hres))
322 return NULL;
323
324 return ctx->secmgr = secmgr;
325}
326
328{
329 BSTR ret;
330
331 if(!res)
332 return S_OK;
333
335 if(!ret)
336 return E_OUTOFMEMORY;
337
338 V_VT(res) = VT_BSTR;
339 V_BSTR(res) = ret;
340 return S_OK;
341}
342
344{
345 if(res) {
346 V_VT(res) = VT_BSTR;
347 V_BSTR(res) = str;
348 }else {
350 }
351 return S_OK;
352}
353
355{
356 if(res) {
357 V_VT(res) = VT_BOOL;
358 V_BOOL(res) = val ? VARIANT_TRUE : VARIANT_FALSE;
359 }
360 return S_OK;
361}
362
364{
365 if(res) {
366 V_VT(res) = VT_I2;
367 V_I2(res) = val;
368 }
369
370 return S_OK;
371}
372
374{
375 if(res) {
376 V_VT(res) = VT_I4;
377 V_I4(res) = val;
378 }
379
380 return S_OK;
381}
382
383static inline HRESULT return_double(VARIANT *res, double val)
384{
385 if(res) {
386 V_VT(res) = VT_R8;
387 V_R8(res) = val;
388 }
389
390 return S_OK;
391}
392
393static inline HRESULT return_float(VARIANT *res, float val)
394{
395 if(res) {
396 V_VT(res) = VT_R4;
397 V_R4(res) = val;
398 }
399
400 return S_OK;
401}
402
404{
405 if(res)
406 V_VT(res) = VT_NULL;
407 return S_OK;
408}
409
410static inline HRESULT return_date(VARIANT *res, double date)
411{
412 if(res) {
413 V_VT(res) = VT_DATE;
414 V_DATE(res) = date;
415 }
416 return S_OK;
417}
418
420{
421 VARIANT r;
423
424 V_VT(&r) = VT_EMPTY;
425 hres = VariantChangeType(&r, v, 0, VT_I4);
426 if(FAILED(hres))
427 return hres;
428
429 *ret = V_I4(&r);
430 return S_OK;
431}
432
433static HRESULT to_double(VARIANT *v, double *ret)
434{
435 VARIANT dst;
437
438 V_VT(&dst) = VT_EMPTY;
440 if(FAILED(hres))
441 return hres;
442
443 *ret = V_R8(&dst);
444 return S_OK;
445}
446
447static HRESULT to_float(VARIANT *v, float *ret)
448{
449 VARIANT dst;
451
452 V_VT(&dst) = VT_EMPTY;
454 if(FAILED(hres))
455 return hres;
456
457 *ret = V_R4(&dst);
458 return S_OK;
459}
460
462{
463 VARIANT dst;
465
466 V_VT(&dst) = VT_EMPTY;
468 if(FAILED(hres))
469 return hres;
470
471 *ret = V_BSTR(&dst);
472 return S_OK;
473}
474
476{
479
480 V_VT(&date) = VT_EMPTY;
482 if(FAILED(hres))
483 return hres;
484
485 return VariantTimeToSystemTime(V_DATE(&date), st);
486}
487
489{
490 IObjectWithSite *obj_site;
491 IUnknown *ax_site;
493
494 hres = IUnknown_QueryInterface(obj, &IID_IObjectWithSite, (void**)&obj_site);
495 if(FAILED(hres))
496 return S_OK;
497
498 ax_site = create_ax_site(ctx);
499 if(ax_site) {
500 hres = IObjectWithSite_SetSite(obj_site, ax_site);
501 IUnknown_Release(ax_site);
502 }
503 else
505 IObjectWithSite_Release(obj_site);
506 return hres;
507}
508
510{
512 struct CONFIRMSAFETY cs;
513 IClassFactoryEx *cfex;
515 DWORD policy_size;
516 BYTE *bpolicy;
517 IUnknown *obj;
519 GUID guid;
521
523 if(FAILED(hres))
524 return NULL;
525
526 TRACE("GUID %s\n", debugstr_guid(&guid));
527
528 if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
529 secmgr = get_sec_mgr(ctx);
530 if(!secmgr)
531 return NULL;
532
533 policy = 0;
534 hres = IInternetHostSecurityManager_ProcessUrlAction(secmgr, URLACTION_ACTIVEX_RUN,
535 (BYTE*)&policy, sizeof(policy), (BYTE*)&guid, sizeof(GUID), 0, 0);
536 if(FAILED(hres) || policy != URLPOLICY_ALLOW)
537 return NULL;
538 }
539
540 hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf);
541 if(FAILED(hres))
542 return NULL;
543
544 hres = IClassFactory_QueryInterface(cf, &IID_IClassFactoryEx, (void**)&cfex);
545 if(SUCCEEDED(hres)) {
546 FIXME("Use IClassFactoryEx\n");
547 IClassFactoryEx_Release(cfex);
548 }
549
550 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
551 if(FAILED(hres))
552 return NULL;
553
554 if(secmgr) {
555 cs.clsid = guid;
556 cs.pUnk = obj;
557 cs.dwFlags = 0;
558 hres = IInternetHostSecurityManager_QueryCustomPolicy(secmgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
559 &bpolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
560 if(SUCCEEDED(hres)) {
561 policy = policy_size >= sizeof(DWORD) ? *(DWORD*)bpolicy : URLPOLICY_DISALLOW;
562 CoTaskMemFree(bpolicy);
563 }
564
565 if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
566 IUnknown_Release(obj);
567 return NULL;
568 }
569 }
570
572 if(FAILED(hres)) {
573 IUnknown_Release(obj);
574 return NULL;
575 }
576
577 return obj;
578}
579
580static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR orig_title, VARIANT *res)
581{
583 IActiveScriptSiteUIControl *ui_control;
584 IActiveScriptSiteWindow *acts_window;
585 WCHAR *title_buf = NULL;
586 const WCHAR *title;
587 HWND hwnd = NULL;
588 int ret = 0;
590
591 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteUIControl, (void**)&ui_control);
592 if(SUCCEEDED(hres)) {
593 hres = IActiveScriptSiteUIControl_GetUIBehavior(ui_control, SCRIPTUICITEM_MSGBOX, &uic_handling);
594 IActiveScriptSiteUIControl_Release(ui_control);
595 if(FAILED(hres))
597 }
598
599 switch(uic_handling) {
601 break;
603 return return_short(res, 0);
604 default:
605 FIXME("blocked\n");
606 return E_FAIL;
607 }
608
609 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteWindow, (void**)&acts_window);
610 if(FAILED(hres)) {
611 FIXME("No IActiveScriptSiteWindow\n");
612 return hres;
613 }
614
615 if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
616 if(orig_title && *orig_title) {
617 WCHAR *ptr;
618
619 title = title_buf = malloc(sizeof(L"VBScript") + (lstrlenW(orig_title)+2)*sizeof(WCHAR));
620 if(!title)
621 return E_OUTOFMEMORY;
622
623 memcpy(title_buf, L"VBScript", sizeof(L"VBScript"));
624 ptr = title_buf + ARRAY_SIZE(L"VBScript")-1;
625
626 *ptr++ = ':';
627 *ptr++ = ' ';
628 lstrcpyW(ptr, orig_title);
629 }else {
630 title = L"VBScript";
631 }
632 }else {
633 title = orig_title ? orig_title : L"";
634 }
635
636 hres = IActiveScriptSiteWindow_GetWindow(acts_window, &hwnd);
637 if(SUCCEEDED(hres)) {
638 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, FALSE);
639 if(SUCCEEDED(hres)) {
640 ret = MessageBoxW(hwnd, prompt, title, type);
641 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, TRUE);
642 }
643 }
644
645 free(title_buf);
646 IActiveScriptSiteWindow_Release(acts_window);
647 if(FAILED(hres)) {
648 FIXME("failed: %08lx\n", hres);
649 return hres;
650 }
651
652 return return_short(res, ret);
653}
654
655static HRESULT Global_CCur(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
656{
657 VARIANT v;
659
660 TRACE("%s\n", debugstr_variant(arg));
661
662 assert(args_cnt == 1);
663
664 V_VT(&v) = VT_EMPTY;
666 if(FAILED(hres))
667 return hres;
668
669 if(!res) {
670 VariantClear(&v);
671 return DISP_E_BADVARTYPE;
672 }
673
674 *res = v;
675 return S_OK;
676}
677
678static HRESULT Global_CInt(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
679{
680 VARIANT v;
682
683 TRACE("%s\n", debugstr_variant(arg));
684
685 assert(args_cnt == 1);
686
687 V_VT(&v) = VT_EMPTY;
689 if(FAILED(hres))
690 return hres;
691
692 if(!res)
693 return DISP_E_BADVARTYPE;
694 else {
695 *res = v;
696 return S_OK;
697 }
698}
699
700static HRESULT Global_CLng(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
701{
702 int i;
704
705 TRACE("%s\n", debugstr_variant(arg));
706
707 assert(args_cnt == 1);
708
709 hres = to_int(arg, &i);
710 if(FAILED(hres))
711 return hres;
712 if(!res)
713 return DISP_E_BADVARTYPE;
714
715 return return_int(res, i);
716}
717
718static HRESULT Global_CBool(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
719{
720 VARIANT v;
722
723 TRACE("%s\n", debugstr_variant(arg));
724
725 assert(args_cnt == 1);
726
727 V_VT(&v) = VT_EMPTY;
729 if(FAILED(hres))
730 return hres;
731
732 if(res)
733 *res = v;
734 else
735 VariantClear(&v);
736 return S_OK;
737}
738
739static HRESULT Global_CByte(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
740{
741 VARIANT v;
743
744 TRACE("%s\n", debugstr_variant(arg));
745
746 assert(args_cnt == 1);
747
748 V_VT(&v) = VT_EMPTY;
750 if(FAILED(hres))
751 return hres;
752
753 if(!res) {
754 VariantClear(&v);
755 return DISP_E_BADVARTYPE;
756 }
757
758 *res = v;
759 return S_OK;
760}
761
762static HRESULT Global_CDate(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
763{
764 VARIANT v;
766
767 TRACE("%s\n", debugstr_variant(arg));
768
769 assert(args_cnt == 1);
770
771 if(V_VT(arg) == VT_NULL)
773
774 V_VT(&v) = VT_EMPTY;
776 if(FAILED(hres)) {
778 if(FAILED(hres))
779 return hres;
780 hres = VariantChangeType(&v, &v, 0, VT_DATE);
781 if(FAILED(hres))
782 return hres;
783 }
784
785 if(!res)
786 return DISP_E_BADVARTYPE;
787 *res = v;
788 return S_OK;
789}
790
791static HRESULT Global_CDbl(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
792{
793 VARIANT v;
795
796 TRACE("%s\n", debugstr_variant(arg));
797
798 assert(args_cnt == 1);
799
800 V_VT(&v) = VT_EMPTY;
802 if(FAILED(hres))
803 return hres;
804
805 if(!res)
806 return DISP_E_BADVARTYPE;
807 else {
808 *res = v;
809 return S_OK;
810 }
811}
812
813static HRESULT Global_CSng(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
814{
815 VARIANT v;
817
818 TRACE("%s\n", debugstr_variant(arg));
819
820 assert(args_cnt == 1);
821
822 V_VT(&v) = VT_EMPTY;
824 if(FAILED(hres))
825 return hres;
826
827 if(!res)
828 return DISP_E_BADVARTYPE;
829
830 *res = v;
831 return S_OK;
832}
833
834static HRESULT Global_CStr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
835{
836 BSTR str;
838
839 TRACE("%s\n", debugstr_variant(arg));
840
841 if(V_VT(arg) == VT_NULL)
843
844 hres = to_string(arg, &str);
845 if(FAILED(hres))
846 return hres;
847
848 return return_bstr(res, str);
849}
850
851static inline WCHAR hex_char(unsigned n)
852{
853 return n < 10 ? '0'+n : 'A'+n-10;
854}
855
856static HRESULT Global_Hex(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
857{
858 WCHAR buf[17], *ptr;
859 DWORD n;
861 int ret;
862
863 TRACE("%s\n", debugstr_variant(arg));
864
865 switch(V_VT(arg)) {
866 case VT_I2:
867 n = (WORD)V_I2(arg);
868 break;
869 case VT_NULL:
870 return return_null(res);
871 default:
872 hres = to_int(arg, &ret);
873 if(FAILED(hres))
874 return hres;
875 else
876 n = ret;
877 }
878
879 buf[16] = 0;
880 ptr = buf+15;
881
882 if(n) {
883 do {
884 *ptr-- = hex_char(n & 0xf);
885 n >>= 4;
886 }while(n);
887 ptr++;
888 }else {
889 *ptr = '0';
890 }
891
892 return return_string(res, ptr);
893}
894
895static HRESULT Global_Oct(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
896{
898 WCHAR buf[23], *ptr;
899 DWORD n;
900 int ret;
901
902 TRACE("%s\n", debugstr_variant(arg));
903
904 switch(V_VT(arg)) {
905 case VT_I2:
906 n = (WORD)V_I2(arg);
907 break;
908 case VT_NULL:
909 return return_null(res);
910 default:
911 hres = to_int(arg, &ret);
912 if(FAILED(hres))
913 return hres;
914 else
915 n = ret;
916 }
917
918 buf[22] = 0;
919 ptr = buf + 21;
920
921 if(n) {
922 do {
923 *ptr-- = '0' + (n & 0x7);
924 n >>= 3;
925 }while(n);
926 ptr++;
927 }else {
928 *ptr = '0';
929 }
930
931 return return_string(res, ptr);
932}
933
935{
936 VARTYPE vt;
937
938 TRACE("(%s)\n", debugstr_variant(arg));
939
940 assert(args_cnt == 1);
941
942 vt = V_VT(arg) & ~VT_BYREF;
943 if(vt & ~(VT_TYPEMASK | VT_ARRAY)) {
944 FIXME("not supported %s\n", debugstr_variant(arg));
945 return E_NOTIMPL;
946 }
947
948 return return_short(res, vt);
949}
950
952{
953 TRACE("%s\n", debugstr_variant(arg));
954
955 return return_bool(res, V_VT(arg) == VT_DATE);
956}
957
959{
960 TRACE("(%s)\n", debugstr_variant(arg));
961
962 assert(args_cnt == 1);
963 return return_bool(res, V_VT(arg) == VT_EMPTY);
964}
965
967{
968 TRACE("(%s)\n", debugstr_variant(arg));
969
970 assert(args_cnt == 1);
971
972 return return_bool(res, V_VT(arg) == VT_NULL);
973}
974
976{
978 double d;
979
980 TRACE("(%s)\n", debugstr_variant(arg));
981
982 assert(args_cnt == 1);
983
984 hres = to_double(arg, &d);
985
986 return return_bool(res, SUCCEEDED(hres));
987}
988
990{
991 TRACE("(%s)\n", debugstr_variant(arg));
992
993 assert(args_cnt == 1);
994
995 return return_bool(res, V_ISARRAY(arg));
996}
997
999{
1000 TRACE("(%s)\n", debugstr_variant(arg));
1001
1002 assert(args_cnt == 1);
1003
1004 return return_bool(res, V_VT(arg) == VT_DISPATCH);
1005}
1006
1007static HRESULT Global_Atn(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1008{
1009 HRESULT hres;
1010 double d;
1011
1012 hres = to_double(arg, &d);
1013 if(FAILED(hres))
1014 return hres;
1015
1016 return return_double(res, atan(d));
1017}
1018
1019static HRESULT Global_Cos(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1020{
1021 HRESULT hres;
1022 double d;
1023
1024 hres = to_double(arg, &d);
1025 if(FAILED(hres))
1026 return hres;
1027
1028 return return_double(res, cos(d));
1029}
1030
1031static HRESULT Global_Sin(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1032{
1033 HRESULT hres;
1034 double d;
1035
1036 hres = to_double(arg, &d);
1037 if(FAILED(hres))
1038 return hres;
1039
1040 return return_double(res, sin(d));
1041}
1042
1043static HRESULT Global_Tan(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1044{
1045 HRESULT hres;
1046 double d;
1047
1048 hres = to_double(arg, &d);
1049 if(FAILED(hres))
1050 return hres;
1051
1052 return return_double(res, tan(d));
1053}
1054
1055static HRESULT Global_Exp(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1056{
1057 HRESULT hres;
1058 double d;
1059
1060 hres = to_double(arg, &d);
1061 if(FAILED(hres))
1062 return hres;
1063
1064 return return_double(res, exp(d));
1065}
1066
1067static HRESULT Global_Log(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1068{
1069 HRESULT hres;
1070 double d;
1071
1072 hres = to_double(arg, &d);
1073 if(FAILED(hres))
1074 return hres;
1075
1076 if(d <= 0)
1078 else
1079 return return_double(res, log(d));
1080}
1081
1082static HRESULT Global_Sqr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1083{
1084 HRESULT hres;
1085 double d;
1086
1087 hres = to_double(arg, &d);
1088 if(FAILED(hres))
1089 return hres;
1090
1091 if(d < 0)
1093 else
1094 return return_double(res, sqrt(d));
1095}
1096
1097static unsigned int get_next_rnd(int value)
1098{
1099 return (value * 0x43fd43fd + 0xc39ec3) & 0xffffff;
1100}
1101
1103{
1104 union
1105 {
1106 double d;
1107 unsigned int i[2];
1108 } dtoi;
1109 unsigned int seed;
1110 HRESULT hres;
1111
1112 assert(args_cnt == 0 || args_cnt == 1);
1113 if (args_cnt == 1) {
1114 hres = to_double(arg, &dtoi.d);
1115 if (FAILED(hres))
1116 return hres;
1117 }
1118 else
1119 dtoi.d = GetTickCount() * 0.001;
1120
1121 seed = dtoi.i[1];
1122 seed ^= (seed >> 16);
1123 seed = ((seed & 0xffff) << 8) | (This->ctx->script_obj->rnd & 0xff);
1124 This->ctx->script_obj->rnd = seed;
1125
1126 return res ? DISP_E_TYPEMISMATCH : S_OK;
1127}
1128
1129static HRESULT Global_Rnd(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1130{
1131 static const float modulus = 16777216.0f;
1132 unsigned int value;
1133 HRESULT hres;
1134 float f;
1135
1136 assert(args_cnt == 0 || args_cnt == 1);
1137
1138 value = This->ctx->script_obj->rnd;
1139 if (args_cnt == 1)
1140 {
1141 hres = to_float(arg, &f);
1142 if (FAILED(hres))
1143 return hres;
1144
1145 if (f < 0.0f)
1146 {
1147 value = *(unsigned int *)&f;
1148 This->ctx->script_obj->rnd = value = get_next_rnd(value + (value >> 24));
1149 }
1150 else if (f == 0.0f)
1151 value = This->ctx->script_obj->rnd;
1152 else
1153 This->ctx->script_obj->rnd = value = get_next_rnd(value);
1154 }
1155 else
1156 {
1157 This->ctx->script_obj->rnd = value = get_next_rnd(value);
1158 }
1159
1160 return return_float(res, (float)value / modulus);
1161}
1162
1164{
1165 SYSTEMTIME lt;
1166 double sec;
1167
1168 GetLocalTime(&lt);
1169 sec = lt.wHour * 3600 + lt.wMinute * 60 + lt.wSecond + lt.wMilliseconds / 1000.0;
1170 return return_float(res, sec);
1171
1172}
1173
1175{
1176 SAFEARRAY *sa;
1177 HRESULT hres;
1178 LONG lbound;
1179 int dim;
1180
1181 assert(args_cnt == 1 || args_cnt == 2);
1182
1183 TRACE("%s %s\n", debugstr_variant(arg), args_cnt == 2 ? debugstr_variant(arg + 1) : "1");
1184
1185 switch(V_VT(arg)) {
1186 case VT_VARIANT|VT_ARRAY:
1187 sa = V_ARRAY(arg);
1188 break;
1190 sa = *V_ARRAYREF(arg);
1191 break;
1192 case VT_EMPTY:
1193 case VT_NULL:
1195 default:
1196 FIXME("arg %s not supported\n", debugstr_variant(arg));
1197 return E_NOTIMPL;
1198 }
1199
1200 if(args_cnt == 2) {
1201 hres = to_int(arg + 1, &dim);
1202 if(FAILED(hres))
1203 return hres;
1204 }else {
1205 dim = 1;
1206 }
1207
1208 hres = SafeArrayGetLBound(sa, dim, &lbound);
1209 if(FAILED(hres))
1210 return hres;
1211
1212 return return_int(res, lbound);
1213}
1214
1216{
1217 SAFEARRAY *sa;
1218 HRESULT hres;
1219 LONG ubound;
1220 int dim;
1221
1222 assert(args_cnt == 1 || args_cnt == 2);
1223
1224 TRACE("%s %s\n", debugstr_variant(arg), args_cnt == 2 ? debugstr_variant(arg + 1) : "1");
1225
1226 switch(V_VT(arg)) {
1227 case VT_VARIANT|VT_ARRAY:
1228 sa = V_ARRAY(arg);
1229 break;
1231 sa = *V_ARRAYREF(arg);
1232 break;
1233 case VT_EMPTY:
1234 case VT_NULL:
1236 default:
1237 FIXME("arg %s not supported\n", debugstr_variant(arg));
1238 return E_NOTIMPL;
1239 }
1240
1241 if(args_cnt == 2) {
1242 hres = to_int(arg + 1, &dim);
1243 if(FAILED(hres))
1244 return hres;
1245 }else {
1246 dim = 1;
1247 }
1248
1249 hres = SafeArrayGetUBound(sa, dim, &ubound);
1250 if(FAILED(hres))
1251 return hres;
1252
1253 return return_int(res, ubound);
1254}
1255
1256static HRESULT Global_RGB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1257{
1258 HRESULT hres;
1259 int i, color[3];
1260
1262
1263 assert(args_cnt == 3);
1264
1265 for(i = 0; i < 3; i++) {
1266 hres = to_int(arg + i, color + i);
1267 if(FAILED(hres))
1268 return hres;
1269 if(color[i] > 255)
1270 color[i] = 255;
1271 if(color[i] < 0)
1273 }
1274
1275 return return_int(res, RGB(color[0], color[1], color[2]));
1276}
1277
1278static HRESULT Global_Len(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1279{
1280 DWORD len;
1281 HRESULT hres;
1282
1283 TRACE("%s\n", debugstr_variant(arg));
1284
1285 if(V_VT(arg) == VT_NULL)
1286 return return_null(res);
1287
1288 if(V_VT(arg) != VT_BSTR) {
1289 BSTR str;
1290
1291 hres = to_string(arg, &str);
1292 if(FAILED(hres))
1293 return hres;
1294
1295 len = SysStringLen(str);
1297 }else {
1299 }
1300
1301 return return_int(res, len);
1302}
1303
1304static HRESULT Global_LenB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1305{
1306 FIXME("\n");
1307 return E_NOTIMPL;
1308}
1309
1311{
1312 BSTR str, ret, conv_str = NULL;
1313 int len, str_len;
1314 HRESULT hres;
1315
1316 TRACE("(%s %s)\n", debugstr_variant(args+1), debugstr_variant(args));
1317
1318 if(V_VT(args) == VT_BSTR) {
1319 str = V_BSTR(args);
1320 }else {
1321 hres = to_string(args, &conv_str);
1322 if(FAILED(hres))
1323 return hres;
1324 str = conv_str;
1325 }
1326
1327 hres = to_int(args+1, &len);
1328 if(FAILED(hres))
1329 return hres;
1330
1331 if(len < 0) {
1332 FIXME("len = %d\n", len);
1333 return E_FAIL;
1334 }
1335
1337 if(len > str_len)
1338 len = str_len;
1339
1341 SysFreeString(conv_str);
1342 if(!ret)
1343 return E_OUTOFMEMORY;
1344
1345 return return_bstr(res, ret);
1346}
1347
1349{
1350 FIXME("\n");
1351 return E_NOTIMPL;
1352}
1353
1355{
1356 BSTR str, ret, conv_str = NULL;
1357 int len, str_len;
1358 HRESULT hres;
1359
1360 TRACE("(%s %s)\n", debugstr_variant(args), debugstr_variant(args+1));
1361
1362 if(V_VT(args+1) == VT_NULL)
1364
1365 hres = to_int(args+1, &len);
1366 if(FAILED(hres))
1367 return hres;
1368
1369 if(len < 0)
1371
1372 if(V_VT(args) == VT_NULL)
1373 return return_null(res);
1374
1375 if(V_VT(args) == VT_BSTR) {
1376 str = V_BSTR(args);
1377 }else {
1378 hres = to_string(args, &conv_str);
1379 if(FAILED(hres))
1380 return hres;
1381 str = conv_str;
1382 }
1383
1385 if(len > str_len)
1386 len = str_len;
1387
1389 SysFreeString(conv_str);
1390 if(!ret)
1391 return E_OUTOFMEMORY;
1392
1393 return return_bstr(res, ret);
1394}
1395
1397{
1398 FIXME("\n");
1399 return E_NOTIMPL;
1400}
1401
1402static HRESULT Global_Mid(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
1403{
1404 int len = -1, start, str_len;
1405 BSTR str, conv_str = NULL;
1406 HRESULT hres;
1407
1408 TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
1409
1410 assert(args_cnt == 2 || args_cnt == 3);
1411
1412 if(V_VT(args+1) == VT_NULL || (args_cnt == 3 && V_VT(args+2) == VT_NULL))
1414
1415 if(V_VT(args+1) == VT_EMPTY)
1417
1418 hres = to_int(args+1, &start);
1419 if(FAILED(hres))
1420 return hres;
1421
1422 if(start <= 0)
1424
1425 if(args_cnt == 3) {
1426 if(V_VT(args+2) == VT_EMPTY)
1428
1429 hres = to_int(args+2, &len);
1430 if(FAILED(hres))
1431 return hres;
1432
1433 if(len < 0)
1435 }
1436
1437 if(V_VT(args) == VT_EMPTY)
1438 return return_string(res, L"");
1439
1440 if(V_VT(args) == VT_NULL)
1441 return return_null(res);
1442
1443 if(V_VT(args) == VT_BSTR) {
1444 str = V_BSTR(args);
1445 }else {
1446 hres = to_string(args, &conv_str);
1447 if(FAILED(hres))
1448 return hres;
1449 str = conv_str;
1450 }
1451
1453 start--;
1454 if(start > str_len)
1455 start = str_len;
1456
1457 if(len == -1)
1458 len = str_len-start;
1459 else if(len > str_len-start)
1460 len = str_len-start;
1461
1462 if(res) {
1463 V_VT(res) = VT_BSTR;
1465 if(!V_BSTR(res))
1467 }
1468
1469 SysFreeString(conv_str);
1470
1471 return hres;
1472}
1473
1474static HRESULT Global_MidB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1475{
1476 FIXME("\n");
1477 return E_NOTIMPL;
1478}
1479
1481{
1482 BSTR left, right;
1483 int mode, ret;
1484 HRESULT hres;
1485 short val;
1486
1487 TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
1488
1489 assert(args_cnt == 2 || args_cnt == 3);
1490
1491 if (args_cnt == 3) {
1492 hres = to_int(args+2, &mode);
1493 if(FAILED(hres))
1494 return hres;
1495
1496 if (mode != 0 && mode != 1) {
1497 FIXME("unknown compare mode = %d\n", mode);
1498 return E_FAIL;
1499 }
1500 }
1501 else
1502 mode = 0;
1503
1504 hres = to_string(args, &left);
1505 if(FAILED(hres))
1506 return hres;
1507
1508 hres = to_string(args+1, &right);
1509 if(FAILED(hres))
1510 {
1512 return hres;
1513 }
1514
1516 val = ret < 0 ? -1 : (ret > 0 ? 1 : 0);
1517
1520 return return_short(res, val);
1521}
1522
1524{
1525 BSTR str;
1526 HRESULT hres;
1527
1528 TRACE("%s\n", debugstr_variant(arg));
1529
1530 if(V_VT(arg) == VT_NULL) {
1531 return return_null(res);
1532 }
1533
1534 hres = to_string(arg, &str);
1535 if(FAILED(hres))
1536 return hres;
1537
1538 if(res) {
1539 WCHAR *ptr;
1540
1541 for(ptr = str; *ptr; ptr++)
1542 *ptr = towlower(*ptr);
1543
1544 V_VT(res) = VT_BSTR;
1545 V_BSTR(res) = str;
1546 }else {
1548 }
1549 return S_OK;
1550}
1551
1553{
1554 BSTR str;
1555 HRESULT hres;
1556
1557 TRACE("%s\n", debugstr_variant(arg));
1558
1559 if(V_VT(arg) == VT_NULL) {
1560 return return_null(res);
1561 }
1562
1563 hres = to_string(arg, &str);
1564 if(FAILED(hres))
1565 return hres;
1566
1567 if(res) {
1568 WCHAR *ptr;
1569
1570 for(ptr = str; *ptr; ptr++)
1571 *ptr = towupper(*ptr);
1572
1573 V_VT(res) = VT_BSTR;
1574 V_BSTR(res) = str;
1575 }else {
1577 }
1578 return S_OK;
1579}
1580
1582{
1583 BSTR str, conv_str = NULL;
1584 WCHAR *ptr;
1585 HRESULT hres;
1586
1587 TRACE("%s\n", debugstr_variant(arg));
1588
1589 if(V_VT(arg) == VT_BSTR) {
1590 str = V_BSTR(arg);
1591 }else {
1592 hres = to_string(arg, &conv_str);
1593 if(FAILED(hres))
1594 return hres;
1595 str = conv_str;
1596 }
1597
1598 for(ptr = str; *ptr && iswspace(*ptr); ptr++);
1599
1601 SysFreeString(conv_str);
1602 if(!str)
1603 return E_OUTOFMEMORY;
1604
1605 return return_bstr(res, str);
1606}
1607
1609{
1610 BSTR str, conv_str = NULL;
1611 WCHAR *ptr;
1612 HRESULT hres;
1613
1614 TRACE("%s\n", debugstr_variant(arg));
1615
1616 if(V_VT(arg) == VT_BSTR) {
1617 str = V_BSTR(arg);
1618 }else {
1619 hres = to_string(arg, &conv_str);
1620 if(FAILED(hres))
1621 return hres;
1622 str = conv_str;
1623 }
1624
1625 for(ptr = str+SysStringLen(str); ptr-1 > str && iswspace(*(ptr-1)); ptr--);
1626
1628 SysFreeString(conv_str);
1629 if(!str)
1630 return E_OUTOFMEMORY;
1631
1632 return return_bstr(res, str);
1633}
1634
1635static HRESULT Global_Trim(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1636{
1637 BSTR str, conv_str = NULL;
1638 WCHAR *begin_ptr, *end_ptr;
1639 HRESULT hres;
1640
1641 TRACE("%s\n", debugstr_variant(arg));
1642
1643 if(V_VT(arg) == VT_BSTR) {
1644 str = V_BSTR(arg);
1645 }else {
1646 hres = to_string(arg, &conv_str);
1647 if(FAILED(hres))
1648 return hres;
1649 str = conv_str;
1650 }
1651
1652 for(begin_ptr = str; *begin_ptr && iswspace(*begin_ptr); begin_ptr++);
1653 for(end_ptr = str+SysStringLen(str); end_ptr-1 > begin_ptr && iswspace(*(end_ptr-1)); end_ptr--);
1654
1655 str = SysAllocStringLen(begin_ptr, end_ptr-begin_ptr);
1656 SysFreeString(conv_str);
1657 if(!str)
1658 return E_OUTOFMEMORY;
1659
1660 return return_bstr(res, str);
1661}
1662
1664{
1665 BSTR str;
1666 int n, i;
1667 HRESULT hres;
1668
1669 TRACE("%s\n", debugstr_variant(arg));
1670
1671 assert(args_cnt == 1);
1672
1673 if(V_VT(arg) == VT_NULL)
1675
1676 hres = to_int(arg, &n);
1677 if(FAILED(hres))
1678 return hres;
1679
1680 if(n < 0)
1682
1683 if(!res)
1684 return S_OK;
1685
1687 if(!str)
1688 return E_OUTOFMEMORY;
1689
1690 for(i=0; i<n; i++)
1691 str[i] = ' ';
1692
1693 V_VT(res) = VT_BSTR;
1694 V_BSTR(res) = str;
1695 return S_OK;
1696}
1697
1699{
1700 WCHAR ch;
1701 int cnt;
1702 HRESULT hres;
1703
1704 TRACE("%s %s\n", debugstr_variant(args), debugstr_variant(args + 1));
1705
1706 hres = to_int(args, &cnt);
1707 if(FAILED(hres))
1708 return hres;
1709 if(cnt < 0)
1710 return E_INVALIDARG;
1711
1712 if(V_VT(args + 1) != VT_BSTR) {
1713 FIXME("Unsupported argument %s\n", debugstr_variant(args+1));
1714 return E_NOTIMPL;
1715 }
1716 if(!SysStringLen(V_BSTR(args + 1)))
1717 return E_INVALIDARG;
1718 ch = V_BSTR(args + 1)[0];
1719
1720 if(res) {
1722 if(!str)
1723 return E_OUTOFMEMORY;
1724 wmemset(str, ch, cnt);
1725 V_VT(res) = VT_BSTR;
1726 V_BSTR(res) = str;
1727 }
1728 return S_OK;
1729}
1730
1732{
1733 VARIANT *startv, *str1v, *str2v;
1734 BSTR str1, str2;
1735 int ret = -1, start = 0, mode = 0;
1736 HRESULT hres;
1737
1738 TRACE("args_cnt=%u\n", args_cnt);
1739
1740 assert(2 <= args_cnt && args_cnt <= 4);
1741
1742 switch(args_cnt) {
1743 case 2:
1744 startv = NULL;
1745 str1v = args;
1746 str2v = args+1;
1747 break;
1748 case 3:
1749 startv = args;
1750 str1v = args+1;
1751 str2v = args+2;
1752 break;
1753 case 4:
1754 startv = args;
1755 str1v = args+1;
1756 str2v = args+2;
1757
1758 if(V_VT(args+3) == VT_NULL)
1760
1761 hres = to_int(args+3, &mode);
1762 if(FAILED(hres))
1763 return hres;
1764
1765 if (mode != 0 && mode != 1)
1767
1768 break;
1770 }
1771
1772 if(startv) {
1773 if(V_VT(startv) == VT_NULL)
1775
1776 hres = to_int(startv, &start);
1777 if(FAILED(hres))
1778 return hres;
1779 if(--start < 0)
1781 }
1782
1783 if(V_VT(str1v) == VT_NULL || V_VT(str2v) == VT_NULL)
1784 return return_null(res);
1785
1786 if(V_VT(str1v) != VT_BSTR) {
1787 hres = to_string(str1v, &str1);
1788 if(FAILED(hres))
1789 return hres;
1790 }
1791 else
1792 str1 = V_BSTR(str1v);
1793
1794 if(V_VT(str2v) != VT_BSTR) {
1795 hres = to_string(str2v, &str2);
1796 if(FAILED(hres)){
1797 if(V_VT(str1v) != VT_BSTR)
1799 return hres;
1800 }
1801 }
1802 else
1803 str2 = V_BSTR(str2v);
1804
1805 if(start < SysStringLen(str1)) {
1808 }
1809
1810 if(V_VT(str1v) != VT_BSTR)
1812 if(V_VT(str2v) != VT_BSTR)
1814 return return_int(res, ++ret ? ret+start : 0);
1815}
1816
1818{
1819 FIXME("\n");
1820 return E_NOTIMPL;
1821}
1822
1823static HRESULT Global_AscB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1824{
1825 FIXME("\n");
1826 return E_NOTIMPL;
1827}
1828
1829static HRESULT Global_ChrB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1830{
1831 FIXME("\n");
1832 return E_NOTIMPL;
1833}
1834
1835static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1836{
1837 BSTR conv_str = NULL, str;
1838 HRESULT hres = S_OK;
1839
1840 TRACE("(%s)\n", debugstr_variant(arg));
1841
1842 switch(V_VT(arg)) {
1843 case VT_NULL:
1845 case VT_EMPTY:
1847 case VT_BSTR:
1848 str = V_BSTR(arg);
1849 break;
1850 default:
1851 hres = to_string(arg, &conv_str);
1852 if(FAILED(hres))
1853 return hres;
1854 str = conv_str;
1855 }
1856
1857 if(!SysStringLen(str))
1859 else if (This->ctx->codepage == CP_UTF8)
1860 hres = return_short(res, *str);
1861 else {
1862 unsigned char buf[2];
1863 short val = 0;
1864 int n = WideCharToMultiByte(This->ctx->codepage, 0, str, 1, (char*)buf, sizeof(buf), NULL, NULL);
1865 switch(n) {
1866 case 1:
1867 val = buf[0];
1868 break;
1869 case 2:
1870 val = (buf[0] << 8) | buf[1];
1871 break;
1872 default:
1873 WARN("Failed to convert %x\n", *str);
1875 }
1876 if(SUCCEEDED(hres))
1878 }
1879
1880 SysFreeString(conv_str);
1881 return hres;
1882}
1883
1884static HRESULT Global_Chr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1885{
1886 int cp, c, len = 0;
1887 CPINFO cpi;
1888 WCHAR ch;
1889 char buf[2];
1890 HRESULT hres;
1891
1892 TRACE("%s\n", debugstr_variant(arg));
1893
1894 hres = to_int(arg, &c);
1895 if(FAILED(hres))
1896 return hres;
1897
1898 cp = This->ctx->codepage;
1899 if(!GetCPInfo(cp, &cpi))
1900 cpi.MaxCharSize = 1;
1901
1902 if((c!=(short)c && c!=(unsigned short)c) ||
1903 (unsigned short)c>=(cpi.MaxCharSize>1 ? 0x10000 : 0x100)) {
1904 WARN("invalid arg %d\n", c);
1906 }
1907
1908 if (cp == CP_UTF8)
1909 {
1910 ch = c;
1911 }
1912 else
1913 {
1914 if(c>>8)
1915 buf[len++] = c>>8;
1916 if(!len || IsDBCSLeadByteEx(cp, buf[0]))
1917 buf[len++] = c;
1918 if(!MultiByteToWideChar(cp, 0, buf, len, &ch, 1)) {
1919 WARN("invalid arg %d, cp %d\n", c, cp);
1920 return E_FAIL;
1921 }
1922 }
1923
1924 if(res) {
1925 V_VT(res) = VT_BSTR;
1927 if(!V_BSTR(res))
1928 return E_OUTOFMEMORY;
1929 }
1930 return S_OK;
1931}
1932
1933static HRESULT Global_AscW(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1934{
1935 FIXME("\n");
1936 return E_NOTIMPL;
1937}
1938
1939static HRESULT Global_ChrW(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1940{
1941 FIXME("\n");
1942 return E_NOTIMPL;
1943}
1944
1945static HRESULT Global_Abs(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1946{
1947 HRESULT hres;
1948 VARIANT dst;
1949
1950 TRACE("(%s)\n", debugstr_variant(arg));
1951
1952 assert(args_cnt == 1);
1953
1954 hres = VarAbs(arg, &dst);
1955 if(FAILED(hres))
1956 return hres;
1957
1958 if (res)
1959 *res = dst;
1960 else
1961 VariantClear(&dst);
1962
1963 return S_OK;
1964}
1965
1966static HRESULT Global_Fix(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1967{
1968 HRESULT hres;
1969 VARIANT dst;
1970
1971 TRACE("(%s)\n", debugstr_variant(arg));
1972
1973 assert(args_cnt == 1);
1974
1975 hres = VarFix(arg, &dst);
1976 if(FAILED(hres))
1977 return hres;
1978
1979 if (res)
1980 *res = dst;
1981 else
1982 VariantClear(&dst);
1983
1984 return S_OK;
1985}
1986
1987static HRESULT Global_Int(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1988{
1989 HRESULT hres;
1990 VARIANT dst;
1991
1992 TRACE("(%s)\n", debugstr_variant(arg));
1993
1994 assert(args_cnt == 1);
1995
1996 hres = VarInt(arg, &dst);
1997 if(FAILED(hres))
1998 return hres;
1999
2000 if (res)
2001 *res = dst;
2002 else
2003 VariantClear(&dst);
2004
2005 return S_OK;
2006}
2007
2008static HRESULT Global_Sgn(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2009{
2010 double v;
2011 short val;
2012 HRESULT hres;
2013
2014 TRACE("(%s)\n", debugstr_variant(arg));
2015
2016 assert(args_cnt == 1);
2017
2018 if(V_VT(arg) == VT_NULL)
2020
2021 hres = to_double(arg, &v);
2022 if (FAILED(hres))
2023 return hres;
2024
2025 val = v == 0 ? 0 : (v > 0 ? 1 : -1);
2026 return return_short(res, val);
2027}
2028
2029static HRESULT Global_Now(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2030{
2031 SYSTEMTIME lt;
2032 double date;
2033
2034 TRACE("\n");
2035
2036 GetLocalTime(&lt);
2038 return return_date(res, date);
2039}
2040
2041static HRESULT Global_Date(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2042{
2043 SYSTEMTIME lt;
2044 UDATE ud;
2045 DATE date;
2046 HRESULT hres;
2047
2048 TRACE("\n");
2049
2050 GetLocalTime(&lt);
2051 ud.st = lt;
2052 ud.wDayOfYear = 0;
2054 if(FAILED(hres))
2055 return hres;
2056 return return_date(res, date);
2057}
2058
2059static HRESULT Global_Time(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2060{
2061 SYSTEMTIME lt;
2062 UDATE ud;
2063 DATE time;
2064 HRESULT hres;
2065
2066 TRACE("\n");
2067
2068 GetLocalTime(&lt);
2069 ud.st = lt;
2070 ud.wDayOfYear = 0;
2072 if(FAILED(hres))
2073 return hres;
2074 return return_date(res, time);
2075}
2076
2077static HRESULT Global_Day(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2078{
2079 SYSTEMTIME st;
2080 HRESULT hres;
2081
2082 TRACE("(%s)\n", debugstr_variant(arg));
2083
2084 hres = to_system_time(arg, &st);
2085 return FAILED(hres) ? hres : return_short(res, st.wDay);
2086}
2087
2089{
2090 SYSTEMTIME st;
2091 HRESULT hres;
2092
2093 TRACE("(%s)\n", debugstr_variant(arg));
2094
2095 hres = to_system_time(arg, &st);
2096 return FAILED(hres) ? hres : return_short(res, st.wMonth);
2097}
2098
2100{
2101 HRESULT hres = S_OK;
2102 int first_day = 0;
2103 SYSTEMTIME st;
2104
2105 TRACE("(%s)\n", debugstr_variant(args));
2106
2107 assert(args_cnt == 1 || args_cnt == 2);
2108
2109 /* [vbSunday = 1, vbSaturday = 7] -> wDayOfWeek [0, 6] */
2110 if (args_cnt == 2)
2111 {
2112 if (V_VT(args + 1) == VT_NULL)
2114
2115 hres = to_int(args + 1, &first_day);
2116 if (SUCCEEDED(hres))
2117 {
2118 if (!first_day)
2119 {
2120 /* vbUseSystemDayOfWeek */
2121 GetLocaleInfoW(This->ctx->lcid, LOCALE_RETURN_NUMBER | LOCALE_IFIRSTDAYOFWEEK, (LPWSTR)&first_day,
2122 sizeof(first_day) / sizeof(WCHAR));
2123 first_day = (first_day + 1) % 7;
2124 }
2125 else if (first_day >= 1 && first_day <= 7)
2126 {
2127 first_day--;
2128 }
2129 else
2131 }
2132 }
2133
2134 if (FAILED(hres))
2135 return hres;
2136
2137 if (V_VT(args) == VT_NULL)
2138 return return_null(res);
2139
2140 if (FAILED(hres = to_system_time(args, &st))) return hres;
2141
2142 return return_short(res, 1 + (7 - first_day + st.wDayOfWeek) % 7);
2143}
2144
2145static HRESULT Global_Year(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2146{
2147 SYSTEMTIME st;
2148 HRESULT hres;
2149
2150 TRACE("(%s)\n", debugstr_variant(arg));
2151
2152 hres = to_system_time(arg, &st);
2153 return FAILED(hres) ? hres : return_short(res, st.wYear);
2154}
2155
2156static HRESULT Global_Hour(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2157{
2158 SYSTEMTIME st;
2159 HRESULT hres;
2160
2161 TRACE("(%s)\n", debugstr_variant(arg));
2162
2163 hres = to_system_time(arg, &st);
2164 return FAILED(hres) ? hres : return_short(res, st.wHour);
2165}
2166
2168{
2169 SYSTEMTIME st;
2170 HRESULT hres;
2171
2172 TRACE("(%s)\n", debugstr_variant(arg));
2173
2174 hres = to_system_time(arg, &st);
2175 return FAILED(hres) ? hres : return_short(res, st.wMinute);
2176}
2177
2179{
2180 SYSTEMTIME st;
2181 HRESULT hres;
2182
2183 TRACE("(%s)\n", debugstr_variant(arg));
2184
2185 hres = to_system_time(arg, &st);
2186 return FAILED(hres) ? hres : return_short(res, st.wSecond);
2187}
2188
2190{
2191 FIXME("\n");
2192 return E_NOTIMPL;
2193}
2194
2196{
2197 FIXME("\n");
2198 return E_NOTIMPL;
2199}
2200
2202{
2203 FIXME("\n");
2204 return E_NOTIMPL;
2205}
2206
2208{
2209 int year, month, day;
2210 UDATE ud = {{ 0 }};
2211 HRESULT hres;
2212 double date;
2213
2214 TRACE("\n");
2215
2216 assert(args_cnt == 3);
2217
2218 if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL || V_VT(args + 2) == VT_NULL)
2220
2221 hres = to_int(args, &year);
2222 if (SUCCEEDED(hres))
2223 hres = to_int(args + 1, &month);
2224 if (SUCCEEDED(hres))
2225 hres = to_int(args + 2, &day);
2226
2227 if (SUCCEEDED(hres))
2228 {
2229 ud.st.wYear = year;
2230 ud.st.wMonth = month;
2231 ud.st.wDay = day;
2232 hres = VarDateFromUdateEx(&ud, 0, 0, &date);
2233 }
2234
2235 if (SUCCEEDED(hres))
2237
2238 return hres;
2239}
2240
2242{
2243 int hour, minute, second;
2244 UDATE ud = {{ 0 }};
2245 HRESULT hres;
2246 double date;
2247
2248 TRACE("\n");
2249
2250 assert(args_cnt == 3);
2251
2252 if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL || V_VT(args + 2) == VT_NULL)
2254
2255 hres = to_int(args, &hour);
2256 if (SUCCEEDED(hres))
2257 hres = to_int(args + 1, &minute);
2258 if (SUCCEEDED(hres))
2259 hres = to_int(args + 2, &second);
2260
2261 if (SUCCEEDED(hres))
2262 {
2263 ud.st.wYear = 1899;
2264 ud.st.wMonth = 12;
2265 ud.st.wDay = 30;
2266 ud.st.wHour = hour;
2267 ud.st.wMinute = minute;
2268 ud.st.wSecond = second;
2269 hres = VarDateFromUdateEx(&ud, 0, 0, &date);
2270 }
2271
2272 if (SUCCEEDED(hres))
2274
2275 return hres;
2276}
2277
2279{
2280 FIXME("\n");
2281 return E_NOTIMPL;
2282}
2283
2285{
2286 BSTR prompt, title = NULL;
2287 int type = MB_OK;
2288 HRESULT hres;
2289
2290 TRACE("\n");
2291
2292 assert(1 <= args_cnt && args_cnt <= 5);
2293
2294 hres = to_string(args, &prompt);
2295 if(FAILED(hres))
2296 return hres;
2297
2298 if(args_cnt > 1)
2299 hres = to_int(args+1, &type);
2300
2301 if(SUCCEEDED(hres) && args_cnt > 2)
2302 hres = to_string(args+2, &title);
2303
2304 if(SUCCEEDED(hres) && args_cnt > 3) {
2305 FIXME("unsupported arg_cnt %d\n", args_cnt);
2306 hres = E_NOTIMPL;
2307 }
2308
2309 if(SUCCEEDED(hres))
2310 hres = show_msgbox(This->ctx, prompt, type, title, res);
2311
2312 SysFreeString(prompt);
2314 return hres;
2315}
2316
2318{
2319 IUnknown *obj;
2320 HRESULT hres;
2321
2322 TRACE("(%s)\n", debugstr_variant(arg));
2323
2324 if(V_VT(arg) != VT_BSTR) {
2325 FIXME("non-bstr arg\n");
2326 return E_INVALIDARG;
2327 }
2328
2329 obj = create_object(This->ctx, V_BSTR(arg));
2330 if(!obj)
2332
2333 if(res) {
2334 hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&V_DISPATCH(res));
2335 if(FAILED(hres))
2336 return hres;
2337
2338 V_VT(res) = VT_DISPATCH;
2339 }
2340
2341 IUnknown_Release(obj);
2342 return S_OK;
2343}
2344
2346{
2347 IBindCtx *bind_ctx;
2348 IUnknown *obj_unk;
2349 IDispatch *disp;
2350 ULONG eaten = 0;
2351 IMoniker *mon;
2352 HRESULT hres;
2353
2354 TRACE("%s %s\n", args_cnt ? debugstr_variant(args) : "", args_cnt > 1 ? debugstr_variant(args+1) : "");
2355
2356 if(args_cnt != 1 || V_VT(args) != VT_BSTR) {
2357 FIXME("unsupported args\n");
2358 return E_NOTIMPL;
2359 }
2360
2361 if(This->ctx->safeopt & (INTERFACE_USES_SECURITY_MANAGER|INTERFACESAFE_FOR_UNTRUSTED_DATA)) {
2362 WARN("blocked in current safety mode\n");
2364 }
2365
2366 hres = CreateBindCtx(0, &bind_ctx);
2367 if(FAILED(hres))
2368 return hres;
2369
2370 hres = MkParseDisplayName(bind_ctx, V_BSTR(args), &eaten, &mon);
2371 if(SUCCEEDED(hres)) {
2372 hres = IMoniker_BindToObject(mon, bind_ctx, NULL, &IID_IUnknown, (void**)&obj_unk);
2373 IMoniker_Release(mon);
2374 }else {
2375 hres = MK_E_SYNTAX;
2376 }
2377 IBindCtx_Release(bind_ctx);
2378 if(FAILED(hres))
2379 return hres;
2380
2381 hres = set_object_site(This->ctx, obj_unk);
2382 if(FAILED(hres)) {
2383 IUnknown_Release(obj_unk);
2384 return hres;
2385 }
2386
2387 hres = IUnknown_QueryInterface(obj_unk, &IID_IDispatch, (void**)&disp);
2388 if(SUCCEEDED(hres)) {
2389 if(res) {
2390 V_VT(res) = VT_DISPATCH;
2391 V_DISPATCH(res) = disp;
2392 }else {
2393 IDispatch_Release(disp);
2394 }
2395 }else {
2396 FIXME("object does not support IDispatch\n");
2397 }
2398
2399 return hres;
2400}
2401
2403{
2404 BSTR interval = NULL;
2405 UDATE ud = {{ 0 }};
2406 HRESULT hres;
2407 double date;
2408 int count;
2409
2410 TRACE("\n");
2411
2412 assert(args_cnt == 3);
2413
2414 if (V_VT(args) == VT_NULL || V_VT(args + 1) == VT_NULL)
2416
2417 if (V_VT(args + 2) == VT_NULL)
2418 return return_null(res);
2419
2421 if (SUCCEEDED(hres))
2422 hres = to_int(args + 1, &count);
2423 if (SUCCEEDED(hres))
2424 hres = to_system_time(args + 2, &ud.st);
2425 if (SUCCEEDED(hres))
2426 {
2427 if (!wcsicmp(interval, L"yyyy"))
2428 ud.st.wYear += count;
2429 else if (!wcsicmp(interval, L"q"))
2430 ud.st.wMonth += 3 * count;
2431 else if (!wcsicmp(interval, L"m"))
2432 ud.st.wMonth += count;
2433 else if (!wcsicmp(interval, L"y")
2434 || !wcsicmp(interval, L"d")
2435 || !wcsicmp(interval, L"w"))
2436 {
2437 ud.st.wDay += count;
2438 }
2439 else if (!wcsicmp(interval, L"ww"))
2440 ud.st.wDay += 7 * count;
2441 else if (!wcsicmp(interval, L"h"))
2442 ud.st.wHour += count;
2443 else if (!wcsicmp(interval, L"n"))
2444 ud.st.wMinute += count;
2445 else if (!wcsicmp(interval, L"s"))
2446 ud.st.wSecond += count;
2447 else
2448 {
2449 WARN("Unrecognized interval %s.\n", debugstr_w(interval));
2451 }
2452 }
2453
2455
2456 if (SUCCEEDED(hres))
2457 hres = VarDateFromUdateEx(&ud, 0, 0, &date);
2458
2459 if (SUCCEEDED(hres))
2461
2462 return hres;
2463}
2464
2466{
2467 FIXME("\n");
2468 return E_NOTIMPL;
2469}
2470
2472{
2473 FIXME("\n");
2474 return E_NOTIMPL;
2475}
2476
2478{
2480 BSTR name = NULL;
2481 HRESULT hres;
2482
2483 TRACE("(%s)\n", debugstr_variant(arg));
2484
2485 assert(args_cnt == 1);
2486
2487 if (V_ISARRAY(arg))
2488 return return_string(res, L"Variant()");
2489
2490 switch(V_VT(arg)) {
2491 case VT_UI1:
2492 return return_string(res, L"Byte");
2493 case VT_I2:
2494 return return_string(res, L"Integer");
2495 case VT_I4:
2496 return return_string(res, L"Long");
2497 case VT_R4:
2498 return return_string(res, L"Single");
2499 case VT_R8:
2500 return return_string(res, L"Double");
2501 case VT_CY:
2502 return return_string(res, L"Currency");
2503 case VT_DECIMAL:
2504 return return_string(res, L"Decimal");
2505 case VT_DATE:
2506 return return_string(res, L"Date");
2507 case VT_BSTR:
2508 return return_string(res, L"String");
2509 case VT_BOOL:
2510 return return_string(res, L"Boolean");
2511 case VT_EMPTY:
2512 return return_string(res, L"Empty");
2513 case VT_NULL:
2514 return return_string(res, L"Null");
2515 case VT_DISPATCH:
2516 if (!V_DISPATCH(arg))
2517 return return_string(res, L"Nothing");
2518 if (SUCCEEDED(IDispatch_GetTypeInfo(V_DISPATCH(arg), 0, GetUserDefaultLCID(), &typeinfo)))
2519 {
2520 hres = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &name, NULL, NULL, NULL);
2521 ITypeInfo_Release(typeinfo);
2522
2523 if (SUCCEEDED(hres) && name && *name)
2524 return return_bstr(res, name);
2525
2527 }
2528 return return_string(res, L"Object");
2529 default:
2530 FIXME("arg %s not supported\n", debugstr_variant(arg));
2531 return E_NOTIMPL;
2532 }
2533}
2534
2536{
2537 SAFEARRAYBOUND bounds;
2538 SAFEARRAY *sa;
2539 VARIANT *data;
2540 HRESULT hres;
2541 unsigned i;
2542
2543 TRACE("arg_cnt=%u\n", args_cnt);
2544
2545 bounds.lLbound = 0;
2546 bounds.cElements = args_cnt;
2547 sa = SafeArrayCreate(VT_VARIANT, 1, &bounds);
2548 if(!sa)
2549 return E_OUTOFMEMORY;
2550
2551 hres = SafeArrayAccessData(sa, (void**)&data);
2552 if(FAILED(hres)) {
2554 return hres;
2555 }
2556
2557 for(i=0; i<args_cnt; i++) {
2559 if(FAILED(hres)) {
2562 return hres;
2563 }
2564 }
2566
2567 if(res) {
2569 V_ARRAY(res) = sa;
2570 }else {
2572 }
2573
2574 return S_OK;
2575}
2576
2578{
2579 FIXME("\n");
2580 return E_NOTIMPL;
2581}
2582
2584{
2585 FIXME("\n");
2586 return E_NOTIMPL;
2587}
2588
2589static HRESULT Global_Join(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
2590{
2591 FIXME("\n");
2592 return E_NOTIMPL;
2593}
2594
2596{
2598 int count, max, mode, len, start, end, ret, delimiterlen = 1;
2599 int i, *indices = NULL, *new_indices, indices_max = 8;
2600 SAFEARRAYBOUND bounds;
2601 SAFEARRAY *sa = NULL;
2602 VARIANT *data;
2603 HRESULT hres = S_OK;
2604
2605 TRACE("%s %u...\n", debugstr_variant(args), args_cnt);
2606
2607 assert(1 <= args_cnt && args_cnt <= 4);
2608
2609 if(V_VT(args) == VT_NULL || (args_cnt > 1 && V_VT(args+1) == VT_NULL) || (args_cnt > 2 && V_VT(args+2) == VT_NULL)
2610 || (args_cnt == 4 && V_VT(args+3) == VT_NULL))
2612
2613 if(V_VT(args) != VT_BSTR) {
2614 hres = to_string(args, &string);
2615 if(FAILED(hres))
2616 return hres;
2617 }else {
2618 string = V_BSTR(args);
2619 }
2620
2621 if(args_cnt > 1) {
2622 if(V_VT(args+1) != VT_BSTR) {
2624 if(FAILED(hres))
2625 goto error;
2626 }else {
2627 delimiter = V_BSTR(args+1);
2628 }
2629 delimiterlen = SysStringLen(delimiter);
2630 }
2631
2632 if(args_cnt > 2) {
2633 hres = to_int(args+2, &max);
2634 if(FAILED(hres))
2635 goto error;
2636 if (max < -1) {
2638 goto error;
2639 }
2640 }else {
2641 max = -1;
2642 }
2643
2644 if(args_cnt == 4) {
2645 hres = to_int(args+3, &mode);
2646 if(FAILED(hres))
2647 goto error;
2648 if (mode != 0 && mode != 1) {
2650 goto error;
2651 }
2652 }else {
2653 mode = 0;
2654 }
2655
2656 start = 0;
2657
2658 len = SysStringLen(string);
2659 count = 0;
2660
2661 indices = malloc( indices_max * sizeof(int));
2662 if(!indices) {
2664 goto error;
2665 }
2666
2667 while(1) {
2668 ret = -1;
2669 if (delimiterlen) {
2671 delimiter ? delimiter : L" ", delimiterlen, mode);
2672 }
2673
2674 if (ret == -1) {
2675 end = len;
2676 }else {
2677 end = start + ret;
2678 }
2679
2680 if (count == indices_max) {
2681 new_indices = realloc(indices, indices_max * 2 * sizeof(int));
2682 if(!new_indices) {
2684 goto error;
2685 }
2686 indices = new_indices;
2687 indices_max *= 2;
2688 }
2689 indices[count++] = end;
2690
2691 if (ret == -1 || count == max) break;
2692 start = start + ret + delimiterlen;
2693 if (start > len) break;
2694 }
2695
2696 bounds.lLbound = 0;
2697 bounds.cElements = count;
2698 sa = SafeArrayCreate( VT_VARIANT, 1, &bounds);
2699 if (!sa) {
2701 goto error;
2702 }
2703 hres = SafeArrayAccessData(sa, (void**)&data);
2704 if(FAILED(hres)) {
2705 goto error;
2706 }
2707
2708 start = 0;
2709 for (i = 0; i < count; i++) {
2710 V_VT(&data[i]) = VT_BSTR;
2711 V_BSTR(&data[i]) = SysAllocStringLen(string + start, indices[i] - start);
2712
2713 if (!V_BSTR(&data[i])) {
2715 break;
2716 }
2717 start = indices[i]+delimiterlen;
2718 }
2720
2721error:
2722 if(SUCCEEDED(hres) && res) {
2724 V_ARRAY(res) = sa;
2725 }else {
2727 }
2728
2729 free(indices);
2730 if(V_VT(args) != VT_BSTR)
2731 SysFreeString(string);
2732 if(args_cnt > 1 && V_VT(args+1) != VT_BSTR)
2734 return hres;
2735}
2736
2738{
2740 int from = 1, cnt = -1, mode = 0;
2741 HRESULT hres = S_OK;
2742
2743 TRACE("%s %s %s %u...\n", debugstr_variant(args), debugstr_variant(args+1), debugstr_variant(args+2), args_cnt);
2744
2745 assert(3 <= args_cnt && args_cnt <= 6);
2746
2747 if(V_VT(args) == VT_NULL || V_VT(args+1) == VT_NULL || (V_VT(args+2) == VT_NULL)
2748 || (args_cnt >= 4 && V_VT(args+3) == VT_NULL) || (args_cnt >= 5 && V_VT(args+4) == VT_NULL)
2749 || (args_cnt == 6 && V_VT(args+5) == VT_NULL))
2751
2752
2753 if(V_VT(args) != VT_BSTR) {
2754 hres = to_string(args, &string);
2755 if(FAILED(hres))
2756 return hres;
2757 }else {
2758 string = V_BSTR(args);
2759 }
2760
2761 if(V_VT(args+1) != VT_BSTR) {
2762 hres = to_string(args+1, &find);
2763 if(FAILED(hres))
2764 goto error;
2765 }else {
2766 find = V_BSTR(args+1);
2767 }
2768
2769 if(V_VT(args+2) != VT_BSTR) {
2770 hres = to_string(args+2, &replace);
2771 if(FAILED(hres))
2772 goto error;
2773 }else {
2774 replace = V_BSTR(args+2);
2775 }
2776
2777 if(args_cnt >= 4) {
2778 hres = to_int(args+3, &from);
2779 if(FAILED(hres))
2780 goto error;
2781 if(from < 1) {
2783 goto error;
2784 }
2785 }
2786
2787 if(args_cnt >= 5) {
2788 hres = to_int(args+4, &cnt);
2789 if(FAILED(hres))
2790 goto error;
2791 if(cnt < -1) {
2793 goto error;
2794 }
2795 }
2796
2797 if(args_cnt == 6) {
2798 hres = to_int(args+5, &mode);
2799 if(FAILED(hres))
2800 goto error;
2801 if (mode != 0 && mode != 1) {
2803 goto error;
2804 }
2805 }
2806
2807 ret = string_replace(string, find, replace, from - 1, cnt, mode);
2808 if(!ret) {
2810 }else if(res) {
2811 V_VT(res) = VT_BSTR;
2812 V_BSTR(res) = ret;
2813 }else {
2815 }
2816
2817error:
2818 if(V_VT(args) != VT_BSTR)
2819 SysFreeString(string);
2820 if(V_VT(args+1) != VT_BSTR)
2822 if(V_VT(args+2) != VT_BSTR)
2824 return hres;
2825}
2826
2828{
2829 WCHAR *ptr1, *ptr2, ch;
2830 BSTR ret;
2831 HRESULT hres;
2832
2833 TRACE("%s\n", debugstr_variant(arg));
2834
2835 hres = to_string(arg, &ret);
2836 if(FAILED(hres))
2837 return hres;
2838
2839 ptr1 = ret;
2840 ptr2 = ret + SysStringLen(ret)-1;
2841 while(ptr1 < ptr2) {
2842 ch = *ptr1;
2843 *ptr1++ = *ptr2;
2844 *ptr2-- = ch;
2845 }
2846
2847 return return_bstr(res, ret);
2848}
2849
2851{
2852 int start = -1, ret = -1, mode = 0;
2853 BSTR str1, str2;
2854 size_t len1, len2;
2855 HRESULT hres;
2856
2857 TRACE("%s %s arg_cnt=%u\n", debugstr_variant(args), debugstr_variant(args+1), args_cnt);
2858
2859 assert(2 <= args_cnt && args_cnt <= 4);
2860
2861 if(V_VT(args) == VT_NULL || V_VT(args+1) == VT_NULL || (args_cnt > 2 && V_VT(args+2) == VT_NULL)
2862 || (args_cnt == 4 && V_VT(args+3) == VT_NULL))
2864
2865 if(args_cnt == 4) {
2866 hres = to_int(args+3, &mode);
2867 if(FAILED(hres))
2868 return hres;
2869 if (mode != 0 && mode != 1)
2871 }
2872
2873 if(args_cnt >= 3) {
2874 hres = to_int(args+2, &start);
2875 if(FAILED(hres))
2876 return hres;
2877 if(!start || start < -1)
2879 }
2880
2881 if(V_VT(args) != VT_BSTR) {
2882 hres = to_string(args, &str1);
2883 if(FAILED(hres))
2884 return hres;
2885 }
2886 else
2887 str1 = V_BSTR(args);
2888
2889 if(V_VT(args+1) != VT_BSTR) {
2890 hres = to_string(args+1, &str2);
2891 if(FAILED(hres)) {
2892 if(V_VT(args) != VT_BSTR)
2894 return hres;
2895 }
2896 }
2897 else
2898 str2 = V_BSTR(args+1);
2899
2900 len1 = SysStringLen(str1);
2901 if(!len1) {
2902 ret = 0;
2903 goto end;
2904 }
2905
2906 if(start == -1)
2907 start = len1;
2908
2909 len2 = SysStringLen(str2);
2910 if(!len2) {
2911 ret = start;
2912 goto end;
2913 }
2914
2915 if(start >= len2 && start <= len1) {
2917 str2, len2, mode);
2918 }
2919 ret++;
2920
2921end:
2922 if(V_VT(args) != VT_BSTR)
2924 if(V_VT(args+1) != VT_BSTR)
2926 return return_int(res, ret);
2927}
2928
2930{
2931 FIXME("\n");
2932 return E_NOTIMPL;
2933}
2934
2936{
2937 TRACE("%s\n", debugstr_variant(arg));
2938
2939 assert(args_cnt == 0);
2940
2941 return return_string(res, L"VBScript");
2942}
2943
2945{
2946 TRACE("%s\n", debugstr_variant(arg));
2947
2948 assert(args_cnt == 0);
2949
2951}
2952
2954{
2955 TRACE("%s\n", debugstr_variant(arg));
2956
2957 assert(args_cnt == 0);
2958
2960}
2961
2963{
2964 TRACE("%s\n", debugstr_variant(arg));
2965
2966 assert(args_cnt == 0);
2967
2969}
2970
2972{
2973 union
2974 {
2975 struct
2976 {
2977 int num_dig, inc_lead, use_parens, group;
2978 } s;
2979 int val[4];
2980 } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 };
2981 HRESULT hres;
2982 BSTR str;
2983 int i;
2984
2985 TRACE("\n");
2986
2987 assert(1 <= args_cnt && args_cnt <= 5);
2988
2989 for (i = 1; i < args_cnt; ++i)
2990 {
2991 if (V_VT(args+i) == VT_ERROR) continue;
2993 if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres;
2994 }
2995
2996 hres = VarFormatNumber(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens,
2997 int_args.s.group, 0, &str);
2998 if (FAILED(hres)) return hres;
2999
3000 return return_bstr(res, str);
3001}
3002
3004{
3005 union
3006 {
3007 struct
3008 {
3009 int num_dig, inc_lead, use_parens, group;
3010 } s;
3011 int val[4];
3012 } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 };
3013 HRESULT hres;
3014 BSTR str;
3015 int i;
3016
3017 TRACE("\n");
3018
3019 assert(1 <= args_cnt && args_cnt <= 5);
3020
3021 for (i = 1; i < args_cnt; ++i)
3022 {
3023 if (V_VT(args+i) == VT_ERROR) continue;
3025 if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres;
3026 }
3027
3028 hres = VarFormatCurrency(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens,
3029 int_args.s.group, 0, &str);
3030 if (FAILED(hres)) return hres;
3031
3032 return return_bstr(res, str);
3033}
3034
3036{
3037 union
3038 {
3039 struct
3040 {
3041 int num_dig, inc_lead, use_parens, group;
3042 } s;
3043 int val[4];
3044 } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 };
3045 HRESULT hres;
3046 BSTR str;
3047 int i;
3048
3049 TRACE("\n");
3050
3051 assert(1 <= args_cnt && args_cnt <= 5);
3052
3053 for (i = 1; i < args_cnt; ++i)
3054 {
3055 if (V_VT(args+i) == VT_ERROR) continue;
3057 if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres;
3058 }
3059
3060 hres = VarFormatPercent(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens,
3061 int_args.s.group, 0, &str);
3062 if (FAILED(hres)) return hres;
3063
3064 return return_bstr(res, str);
3065}
3066
3068{
3069 FIXME("\n");
3070 return E_NOTIMPL;
3071}
3072
3074{
3075 int format = 0;
3076 HRESULT hres;
3077 BSTR str;
3078
3079 TRACE("\n");
3080
3081 assert(1 <= args_cnt && args_cnt <= 2);
3082
3083 if (V_VT(args) == VT_NULL)
3085
3086 if (args_cnt == 2)
3087 {
3089 if (V_VT(args+1) != VT_ERROR)
3090 {
3091 if (FAILED(hres = to_int(args+1, &format))) return hres;
3092 }
3093 }
3094
3096 if (FAILED(hres)) return hres;
3097
3098 return return_bstr(res, str);
3099}
3100
3102{
3103 int weekday, first_day = 1, abbrev = 0;
3104 BSTR ret;
3105 HRESULT hres;
3106
3107 TRACE("\n");
3108
3109 assert(1 <= args_cnt && args_cnt <= 3);
3110
3111 hres = to_int(args, &weekday);
3112 if(FAILED(hres))
3113 return hres;
3114
3115 if(args_cnt > 1) {
3116 hres = to_int(args+1, &abbrev);
3117 if(FAILED(hres))
3118 return hres;
3119
3120 if(args_cnt == 3) {
3121 hres = to_int(args+2, &first_day);
3122 if(FAILED(hres))
3123 return hres;
3124 }
3125 }
3126
3127 hres = VarWeekdayName(weekday, abbrev, first_day, 0, &ret);
3128 if(FAILED(hres))
3129 return hres;
3130
3131 return return_bstr(res, ret);
3132}
3133
3135{
3136 int month, abbrev = 0;
3137 BSTR ret;
3138 HRESULT hres;
3139
3140 TRACE("\n");
3141
3142 assert(args_cnt == 1 || args_cnt == 2);
3143
3144 if(V_VT(args) == VT_NULL || (args_cnt == 2 && V_VT(args+1) == VT_NULL))
3146
3147 hres = to_int(args, &month);
3148 if(FAILED(hres))
3149 return hres;
3150
3151 if(args_cnt == 2) {
3152 hres = to_int(args+1, &abbrev);
3153 if(FAILED(hres))
3154 return hres;
3155 }
3156
3157 hres = VarMonthName(month, abbrev, 0, &ret);
3158 if(FAILED(hres))
3159 return hres;
3160
3161 return return_bstr(res, ret);
3162}
3163
3165{
3166 int decimal_places = 0;
3167 double d;
3168 HRESULT hres;
3169
3170 TRACE("%s %s\n", debugstr_variant(args), args_cnt == 2 ? debugstr_variant(args + 1) : "0");
3171
3172 assert(args_cnt == 1 || args_cnt == 2);
3173
3174 if(!res)
3175 return S_OK;
3176
3177 if(args_cnt == 2) {
3178 if (V_VT(args + 1) != VT_ERROR) {
3179 hres = to_int(args + 1, &decimal_places);
3180 if (FAILED(hres))
3181 return hres;
3182 }
3183 }
3184
3185 switch(V_VT(args)) {
3186 case VT_I2:
3187 case VT_I4:
3188 case VT_BOOL:
3189 *res = *args;
3190 return S_OK;
3191 case VT_R8:
3192 d = V_R8(args);
3193 break;
3194 default:
3195 hres = to_double(args, &d);
3196 if(FAILED(hres))
3197 return hres;
3198 }
3199
3200 hres = VarR8Round(d, decimal_places, &d);
3201 if(FAILED(hres))
3202 return hres;
3203
3204 return return_double(res, d);
3205}
3206
3208{
3209 FIXME("\n");
3210 return E_NOTIMPL;
3211}
3212
3214{
3215 FIXME("\n");
3216 return E_NOTIMPL;
3217}
3218
3219static HRESULT Global_Eval(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
3220{
3221 FIXME("\n");
3222 return E_NOTIMPL;
3223}
3224
3226{
3227 FIXME("\n");
3228 return E_NOTIMPL;
3229}
3230
3232{
3233 FIXME("\n");
3234 return E_NOTIMPL;
3235}
3236
3238{
3239 FIXME("\n");
3240 return E_NOTIMPL;
3241}
3242
3243static HRESULT Global_Err(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
3244{
3245 TRACE("\n");
3246
3247 if(args_cnt) {
3248 FIXME("Setter not supported\n");
3249 return E_NOTIMPL;
3250 }
3251
3252 V_VT(res) = VT_DISPATCH;
3253 V_DISPATCH(res) = &This->ctx->err_obj->IDispatch_iface;
3254 IDispatch_AddRef(V_DISPATCH(res));
3255 return S_OK;
3256}
3257
3258static const string_constant_t vbCr = {1, {'\r'}};
3259static const string_constant_t vbCrLf = {2, {'\r','\n'}};
3260static const string_constant_t vbNewLine = {2, {'\r','\n'}};
3261static const string_constant_t vbFormFeed = {1, {0xc}};
3262static const string_constant_t vbLf = {1, {'\n'}};
3265static const string_constant_t vbTab = {1, {'\t'}};
3266static const string_constant_t vbVerticalTab = {1, {0xb}};
3267
3269 {NULL}, /* no default value */
3270 {L"Abs", Global_Abs, 0, 1},
3271 {L"Array", Global_Array, 0, 0, MAXDWORD},
3272 {L"Asc", Global_Asc, 0, 1},
3273 {L"AscB", Global_AscB, 0, 1},
3274 {L"AscW", Global_AscW, 0, 1},
3275 {L"Atn", Global_Atn, 0, 1},
3276 {L"CBool", Global_CBool, 0, 1},
3277 {L"CByte", Global_CByte, 0, 1},
3278 {L"CCur", Global_CCur, 0, 1},
3279 {L"CDate", Global_CDate, 0, 1},
3280 {L"CDbl", Global_CDbl, 0, 1},
3281 {L"Chr", Global_Chr, 0, 1},
3282 {L"ChrB", Global_ChrB, 0, 1},
3283 {L"ChrW", Global_ChrW, 0, 1},
3284 {L"CInt", Global_CInt, 0, 1},
3285 {L"CLng", Global_CLng, 0, 1},
3286 {L"Cos", Global_Cos, 0, 1},
3287 {L"CreateObject", Global_CreateObject, 0, 1},
3288 {L"CSng", Global_CSng, 0, 1},
3289 {L"CStr", Global_CStr, 0, 1},
3290 {L"Date", Global_Date, 0, 0},
3291 {L"DateAdd", Global_DateAdd, 0, 3},
3292 {L"DateDiff", Global_DateDiff, 0, 3, 5},
3293 {L"DatePart", Global_DatePart, 0, 2, 4},
3294 {L"DateSerial", Global_DateSerial, 0, 3},
3295 {L"DateValue", Global_DateValue, 0, 1},
3296 {L"Day", Global_Day, 0, 1},
3297 {L"Erase", Global_Erase, 0, 1},
3298 {L"Err", Global_Err, BP_GETPUT},
3299 {L"Escape", Global_Escape, 0, 1},
3300 {L"Eval", Global_Eval, 0, 1},
3301 {L"Execute", Global_Execute, 0, 1},
3302 {L"ExecuteGlobal", Global_ExecuteGlobal, 0, 1},
3303 {L"Exp", Global_Exp, 0, 1},
3304 {L"Filter", Global_Filter, 0, 2, 4},
3305 {L"Fix", Global_Fix, 0, 1},
3306 {L"FormatCurrency", Global_FormatCurrency, 0, 1, 5},
3307 {L"FormatDateTime", Global_FormatDateTime, 0, 1, 2},
3308 {L"FormatNumber", Global_FormatNumber, 0, 1, 5},
3309 {L"FormatPercent", Global_FormatPercent, 0, 1, 5},
3310 {L"GetLocale", Global_GetLocale, 0, 0},
3311 {L"GetObject", Global_GetObject, 0, 0, 2},
3312 {L"GetRef", Global_GetRef, 0, 1},
3313 {L"Hex", Global_Hex, 0, 1},
3314 {L"Hour", Global_Hour, 0, 1},
3315 {L"InputBox", Global_InputBox, 0, 1, 7},
3316 {L"InStr", Global_InStr, 0, 2, 4},
3317 {L"InStrB", Global_InStrB, 0, 3, 4},
3318 {L"InStrRev", Global_InStrRev, 0, 2, 4},
3319 {L"Int", Global_Int, 0, 1},
3320 {L"IsArray", Global_IsArray, 0, 1},
3321 {L"IsDate", Global_IsDate, 0, 1},
3322 {L"IsEmpty", Global_IsEmpty, 0, 1},
3323 {L"IsNull", Global_IsNull, 0, 1},
3324 {L"IsNumeric", Global_IsNumeric, 0, 1},
3325 {L"IsObject", Global_IsObject, 0, 1},
3326 {L"Join", Global_Join, 0, 1, 2},
3327 {L"LBound", Global_LBound, 0, 1, 2},
3328 {L"LCase", Global_LCase, 0, 1},
3329 {L"Left", Global_Left, 0, 2},
3330 {L"LeftB", Global_LeftB, 0, 2},
3331 {L"Len", Global_Len, 0, 1},
3332 {L"LenB", Global_LenB, 0, 1},
3333 {L"LoadPicture", Global_LoadPicture, 0, 1},
3334 {L"Log", Global_Log, 0, 1},
3335 {L"LTrim", Global_LTrim, 0, 1},
3336 {L"Mid", Global_Mid, 0, 2, 3},
3337 {L"MidB", Global_MidB, 0, 2, 3},
3338 {L"Minute", Global_Minute, 0, 1},
3339 {L"Month", Global_Month, 0, 1},
3340 {L"MonthName", Global_MonthName, 0, 1, 2},
3341 {L"MsgBox", Global_MsgBox, 0, 1, 5},
3342 {L"Now", Global_Now, 0, 0},
3343 {L"Oct", Global_Oct, 0, 1},
3344 {L"Randomize", Global_Randomize, 0, 0, 1},
3345 {L"Replace", Global_Replace, 0, 3, 6},
3346 {L"RGB", Global_RGB, 0, 3},
3347 {L"Right", Global_Right, 0, 2},
3348 {L"RightB", Global_RightB, 0, 2},
3349 {L"Rnd", Global_Rnd, 0, 0, 1},
3350 {L"Round", Global_Round, 0, 1, 2},
3351 {L"RTrim", Global_RTrim, 0, 1},
3352 {L"ScriptEngine", Global_ScriptEngine, 0, 0},
3353 {L"ScriptEngineBuildVersion", Global_ScriptEngineBuildVersion, 0, 0},
3354 {L"ScriptEngineMajorVersion", Global_ScriptEngineMajorVersion, 0, 0},
3355 {L"ScriptEngineMinorVersion", Global_ScriptEngineMinorVersion, 0, 0},
3356 {L"Second", Global_Second, 0, 1},
3357 {L"SetLocale", Global_SetLocale, 0, 0, 1},
3358 {L"Sgn", Global_Sgn, 0, 1},
3359 {L"Sin", Global_Sin, 0, 1},
3360 {L"Space", Global_Space, 0, 1},
3361 {L"Split", Global_Split, 0, 1, 4},
3362 {L"Sqr", Global_Sqr, 0, 1},
3363 {L"StrComp", Global_StrComp, 0, 2, 3},
3364 {L"String", Global_String, 0, 0, 2},
3365 {L"StrReverse", Global_StrReverse, 0, 1},
3366 {L"Tan", Global_Tan, 0, 1},
3367 {L"Time", Global_Time, 0, 0},
3368 {L"Timer", Global_Timer, 0, 0},
3369 {L"TimeSerial", Global_TimeSerial, 0, 3},
3370 {L"TimeValue", Global_TimeValue, 0, 1},
3371 {L"Trim", Global_Trim, 0, 1},
3372 {L"TypeName", Global_TypeName, 0, 1},
3373 {L"UBound", Global_UBound, 0, 1, 2},
3374 {L"UCase", Global_UCase, 0, 1},
3375 {L"Unescape", Global_Unescape, 0, 1},
3376 {L"VarType", Global_VarType, 0, 1},
3377 {L"vbAbort", NULL, BP_GET, VT_I2, IDABORT},
3378 {L"vbAbortRetryIgnore", NULL, BP_GET, VT_I2, MB_ABORTRETRYIGNORE},
3379 {L"vbApplicationModal", NULL, BP_GET, VT_I2, MB_APPLMODAL},
3380 {L"vbArray", NULL, BP_GET, VT_I2, VT_ARRAY},
3381 {L"vbBinaryCompare", NULL, BP_GET, VT_I2, 0},
3382 {L"vbBlack", NULL, BP_GET, VT_I4, 0x000000},
3383 {L"vbBlue", NULL, BP_GET, VT_I4, 0xff0000},
3384 {L"vbBoolean", NULL, BP_GET, VT_I2, VT_BOOL},
3385 {L"vbByte", NULL, BP_GET, VT_I2, VT_UI1},
3386 {L"vbCancel", NULL, BP_GET, VT_I2, IDCANCEL},
3387 {L"vbCr", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbCr},
3388 {L"vbCritical", NULL, BP_GET, VT_I2, MB_ICONHAND},
3389 {L"vbCrLf", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbCrLf},
3390 {L"vbCurrency", NULL, BP_GET, VT_I2, VT_CY},
3391 {L"vbCyan", NULL, BP_GET, VT_I4, 0xffff00},
3392 {L"vbDatabaseCompare", NULL, BP_GET, VT_I2, 2},
3393 {L"vbDataObject", NULL, BP_GET, VT_I2, VT_UNKNOWN},
3394 {L"vbDate", NULL, BP_GET, VT_I2, VT_DATE},
3395 {L"vbDecimal", NULL, BP_GET, VT_I2, VT_DECIMAL},
3396 {L"vbDefaultButton1", NULL, BP_GET, VT_I2, MB_DEFBUTTON1},
3397 {L"vbDefaultButton2", NULL, BP_GET, VT_I2, MB_DEFBUTTON2},
3398 {L"vbDefaultButton3", NULL, BP_GET, VT_I2, MB_DEFBUTTON3},
3399 {L"vbDefaultButton4", NULL, BP_GET, VT_I2, MB_DEFBUTTON4},
3400 {L"vbDouble", NULL, BP_GET, VT_I2, VT_R8},
3401 {L"vbEmpty", NULL, BP_GET, VT_I2, VT_EMPTY},
3402 {L"vbError", NULL, BP_GET, VT_I2, VT_ERROR},
3403 {L"vbExclamation", NULL, BP_GET, VT_I2, MB_ICONEXCLAMATION},
3404 {L"vbFalse", NULL, BP_GET, VT_I2, VARIANT_FALSE},
3405 {L"vbFirstFourDays", NULL, BP_GET, VT_I2, 2},
3406 {L"vbFirstFullWeek", NULL, BP_GET, VT_I2, 3},
3407 {L"vbFirstJan1", NULL, BP_GET, VT_I2, 1},
3408 {L"vbFormFeed", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbFormFeed},
3409 {L"vbFriday", NULL, BP_GET, VT_I2, 6},
3410 {L"vbGeneralDate", NULL, BP_GET, VT_I2, 0},
3411 {L"vbGreen", NULL, BP_GET, VT_I4, 0x00ff00},
3412 {L"vbIgnore", NULL, BP_GET, VT_I2, IDIGNORE},
3413 {L"vbInformation", NULL, BP_GET, VT_I2, MB_ICONASTERISK},
3414 {L"vbInteger", NULL, BP_GET, VT_I2, VT_I2},
3415 {L"vbLf", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbLf},
3416 {L"vbLong", NULL, BP_GET, VT_I2, VT_I4},
3417 {L"vbLongDate", NULL, BP_GET, VT_I2, 1},
3418 {L"vbLongTime", NULL, BP_GET, VT_I2, 3},
3419 {L"vbMagenta", NULL, BP_GET, VT_I4, 0xff00ff},
3420 {L"vbMonday", NULL, BP_GET, VT_I2, 2},
3421 {L"vbMsgBoxHelpButton", NULL, BP_GET, VT_I4, MB_HELP},
3422 {L"vbMsgBoxRight", NULL, BP_GET, VT_I4, MB_RIGHT},
3423 {L"vbMsgBoxRtlReading", NULL, BP_GET, VT_I4, MB_RTLREADING},
3424 {L"vbMsgBoxSetForeground", NULL, BP_GET, VT_I4, MB_SETFOREGROUND},
3425 {L"vbNewLine", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbNewLine},
3426 {L"vbNo", NULL, BP_GET, VT_I2, IDNO},
3427 {L"vbNull", NULL, BP_GET, VT_I2, VT_NULL},
3428 {L"vbNullChar", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbNullChar},
3429 {L"vbNullString", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbNullString},
3430 {L"vbObject", NULL, BP_GET, VT_I2, VT_DISPATCH},
3431 {L"vbObjectError", NULL, BP_GET, VT_I4, 0x80040000},
3432 {L"vbOK", NULL, BP_GET, VT_I2, IDOK},
3433 {L"vbOKCancel", NULL, BP_GET, VT_I2, MB_OKCANCEL},
3434 {L"vbOKOnly", NULL, BP_GET, VT_I2, MB_OK},
3435 {L"vbQuestion", NULL, BP_GET, VT_I2, MB_ICONQUESTION},
3436 {L"vbRed", NULL, BP_GET, VT_I4, 0x0000ff},
3437 {L"vbRetry", NULL, BP_GET, VT_I2, IDRETRY},
3438 {L"vbRetryCancel", NULL, BP_GET, VT_I2, MB_RETRYCANCEL},
3439 {L"vbSaturday", NULL, BP_GET, VT_I2, 7},
3440 {L"vbShortDate", NULL, BP_GET, VT_I2, 2},
3441 {L"vbShortTime", NULL, BP_GET, VT_I2, 4},
3442 {L"vbSingle", NULL, BP_GET, VT_I2, VT_R4},
3443 {L"vbString", NULL, BP_GET, VT_I2, VT_BSTR},
3444 {L"vbSunday", NULL, BP_GET, VT_I2, 1},
3445 {L"vbSystemModal", NULL, BP_GET, VT_I2, MB_SYSTEMMODAL},
3446 {L"vbTab", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbTab},
3447 {L"vbTextCompare", NULL, BP_GET, VT_I2, 1},
3448 {L"vbThursday", NULL, BP_GET, VT_I2, 5},
3449 {L"vbTrue", NULL, BP_GET, VT_I2, VARIANT_TRUE},
3450 {L"vbTuesday", NULL, BP_GET, VT_I2, 3},
3451 {L"vbUseDefault", NULL, BP_GET, VT_I2, -2},
3452 {L"vbUseSystem", NULL, BP_GET, VT_I2, 0},
3453 {L"vbUseSystemDayOfWeek", NULL, BP_GET, VT_I2, 0},
3454 {L"vbVariant", NULL, BP_GET, VT_I2, VT_VARIANT},
3455 {L"vbVerticalTab", NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbVerticalTab},
3456 {L"vbWednesday", NULL, BP_GET, VT_I2, 4},
3457 {L"vbWhite", NULL, BP_GET, VT_I4, 0xffffff},
3458 {L"vbYellow", NULL, BP_GET, VT_I4, 0x00ffff},
3459 {L"vbYes", NULL, BP_GET, VT_I2, IDYES},
3460 {L"vbYesNo", NULL, BP_GET, VT_I2, MB_YESNO},
3461 {L"vbYesNoCancel", NULL, BP_GET, VT_I2, MB_YESNOCANCEL},
3462 {L"Weekday", Global_Weekday, 0, 1, 2},
3463 {L"WeekdayName", Global_WeekdayName, 0, 1, 3},
3464 {L"Year", Global_Year, 0, 1}
3465};
3466
3467static HRESULT err_string_prop(BSTR *prop, VARIANT *args, unsigned args_cnt, VARIANT *res)
3468{
3469 BSTR str;
3470 HRESULT hres;
3471
3472 if(!args_cnt)
3473 return return_string(res, *prop ? *prop : L"");
3474
3475 hres = to_string(args, &str);
3476 if(FAILED(hres))
3477 return hres;
3478
3479 SysFreeString(*prop);
3480 *prop = str;
3481 return S_OK;
3482}
3483
3485{
3486 TRACE("\n");
3487 return err_string_prop(&This->ctx->ei.bstrDescription, args, args_cnt, res);
3488}
3489
3491{
3492 TRACE("\n");
3493
3494 if(args_cnt) {
3495 FIXME("setter not implemented\n");
3496 return E_NOTIMPL;
3497 }
3498
3499 return return_int(res, This->ctx->ei.dwHelpContext);
3500}
3501
3503{
3504 TRACE("\n");
3505 return err_string_prop(&This->ctx->ei.bstrHelpFile, args, args_cnt, res);
3506}
3507
3508static HRESULT Err_Number(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
3509{
3510 HRESULT hres;
3511
3512 TRACE("\n");
3513
3514 if(args_cnt) {
3515 FIXME("setter not implemented\n");
3516 return E_NOTIMPL;
3517 }
3518
3519 hres = This->ctx->ei.scode;
3521}
3522
3523static HRESULT Err_Source(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
3524{
3525 TRACE("\n");
3526 return err_string_prop(&This->ctx->ei.bstrSource, args, args_cnt, res);
3527}
3528
3529static HRESULT Err_Clear(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
3530{
3531 TRACE("\n");
3532
3533 clear_ei(&This->ctx->ei);
3534 return S_OK;
3535}
3536
3537static HRESULT Err_Raise(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
3538{
3540 int code, helpcontext = 0;
3541 HRESULT hres;
3542
3543 TRACE("%s %u...\n", debugstr_variant(args), args_cnt);
3544
3545 hres = to_int(args, &code);
3546 if(FAILED(hres))
3547 return hres;
3548 if(code == 0 || code > 0xffff)
3549 return E_INVALIDARG;
3550
3551 if(args_cnt >= 2)
3552 hres = to_string(args + 1, &source);
3553 if(args_cnt >= 3 && SUCCEEDED(hres))
3554 hres = to_string(args + 2, &description);
3555 if(args_cnt >= 4 && SUCCEEDED(hres))
3556 hres = to_string(args + 3, &helpfile);
3557 if(args_cnt >= 5 && SUCCEEDED(hres))
3558 hres = to_int(args + 4, &helpcontext);
3559
3560 if(SUCCEEDED(hres)) {
3561 script_ctx_t *ctx = This->ctx;
3562
3563 if(source) {
3564 SysFreeString(ctx->ei.bstrSource);
3565 ctx->ei.bstrSource = source;
3566 }
3567 if(description) {
3568 SysFreeString(ctx->ei.bstrDescription);
3569 ctx->ei.bstrDescription = description;
3570 }
3571 if(helpfile) {
3572 SysFreeString(ctx->ei.bstrHelpFile);
3573 ctx->ei.bstrHelpFile = helpfile;
3574 }
3575 if(args_cnt >= 5)
3576 ctx->ei.dwHelpContext = helpcontext;
3577
3578 ctx->ei.scode = (code & ~0xffff) ? code : MAKE_VBSERROR(code);
3579 map_vbs_exception(&ctx->ei);
3580
3581 hres = SCRIPT_E_RECORDED;
3582 }else {
3586 }
3587
3588 return hres;
3589}
3590
3591static const builtin_prop_t err_props[] = {
3593 {L"Clear", Err_Clear},
3594 {L"Description", Err_Description, BP_GETPUT},
3595 {L"HelpContext", Err_HelpContext, BP_GETPUT},
3596 {L"HelpFile", Err_HelpFile, BP_GETPUT},
3597 {L"Number", Err_Number, BP_GETPUT},
3598 {L"Raise", Err_Raise, 0, 1, 5},
3599 {L"Source", Err_Source, BP_GETPUT}
3600};
3601
3603{
3604 if(ctx->err_obj) {
3605 ctx->err_obj->ctx = NULL;
3606 IDispatch_Release(&ctx->err_obj->IDispatch_iface);
3607 ctx->err_obj = NULL;
3608 }
3609
3610 if(ctx->global_obj) {
3611 ctx->global_obj->ctx = NULL;
3612 IDispatch_Release(&ctx->global_obj->IDispatch_iface);
3613 ctx->global_obj = NULL;
3614 }
3615}
3616
3618{
3619 HRESULT hres;
3620
3622 if(FAILED(hres))
3623 return hres;
3624
3626}
enum tagSCRIPTUICHANDLING SCRIPTUICHANDLING
@ SCRIPTUICITEM_MSGBOX
Definition: activscp.idl:72
@ SCRIPTUICHANDLING_ALLOW
Definition: activscp.idl:76
@ SCRIPTUICHANDLING_NOUIDEFAULT
Definition: activscp.idl:78
unsigned short UINT16
Definition: actypes.h:129
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:73
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static const TCHAR helpfile[]
Definition: dialog.c:19
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const GUID IID_IClassFactory
static TAGID TAGID find
Definition: db.cpp:156
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CLSIDFromProgID(LPCOLESTR progid, CLSID *clsid)
Definition: combase.c:1437
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscontext, COSERVERINFO *server_info, REFIID riid, void **obj)
Definition: combase.c:1925
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
double DATE
Definition: compat.h:2253
OLECHAR * BSTR
Definition: compat.h:2293
unsigned short VARTYPE
Definition: compat.h:2254
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
@ VT_BSTR
Definition: compat.h:2303
@ VT_R4
Definition: compat.h:2299
@ VT_NULL
Definition: compat.h:2296
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_TYPEMASK
Definition: compat.h:2346
@ VT_BYREF
Definition: compat.h:2342
@ VT_DECIMAL
Definition: compat.h:2309
@ VT_ERROR
Definition: compat.h:2305
@ VT_ARRAY
Definition: compat.h:2341
@ VT_R8
Definition: compat.h:2300
@ VT_CY
Definition: compat.h:2301
@ VT_VARIANT
Definition: compat.h:2307
@ VT_I4
Definition: compat.h:2298
@ VT_DATE
Definition: compat.h:2302
@ VT_BOOL
Definition: compat.h:2306
@ VT_I2
Definition: compat.h:2297
@ VT_EMPTY
Definition: compat.h:2295
@ VT_DISPATCH
Definition: compat.h:2304
@ VT_UI1
Definition: compat.h:2311
#define wcsicmp
Definition: compat.h:15
#define lstrlenW
Definition: compat.h:750
static DOUBLE day(DOUBLE time)
Definition: date.c:75
IUnknown * create_ax_site(script_ctx_t *ctx)
Definition: jscript.c:614
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:272
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2146
BOOL WINAPI IsDBCSLeadByteEx(UINT codepage, BYTE testchar)
Definition: locale.c:2106
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1216
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
LCID lcid
Definition: locale.c:5660
INT WINAPI DECLSPEC_HOTPATCH FindStringOrdinal(DWORD flag, const WCHAR *src, INT src_size, const WCHAR *val, INT val_size, BOOL ignore_case)
Definition: locale.c:5257
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
GUID guid
Definition: version.c:147
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
unsigned char ch[4][2]
Definition: console.c:118
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
_ACRTIMP double __cdecl sqrt(double)
Definition: sqrt.c:5
_ACRTIMP double __cdecl atan(double)
Definition: atan.c:44
_ACRTIMP double __cdecl sin(double)
Definition: sin.c:21
_ACRTIMP double __cdecl tan(double)
Definition: tan.c:122
_ACRTIMP double __cdecl cos(double)
Definition: cos.c:21
static wchar_t *__cdecl wmemset(wchar_t *s, wchar_t c, size_t n)
Definition: wchar.h:77
HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szDisplayName, LPDWORD pchEaten, LPMONIKER *ppmk)
Definition: moniker.c:838
HRESULT WINAPI SafeArrayGetUBound(SAFEARRAY *psa, UINT nDim, LONG *plUbound)
Definition: safearray.c:1033
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1137
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1168
HRESULT WINAPI SafeArrayGetLBound(SAFEARRAY *psa, UINT nDim, LONG *plLbound)
Definition: safearray.c:1066
HRESULT WINAPI SafeArrayDestroy(SAFEARRAY *psa)
Definition: safearray.c:1347
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:600
HRESULT WINAPI VarFormatPercent(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT nParens, INT nGrouping, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2345
HRESULT WINAPI VarWeekdayName(INT iWeekday, INT fAbbrev, INT iFirstDay, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2568
HRESULT WINAPI VarFormatDateTime(LPVARIANT pVarIn, INT nFormat, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2190
HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT nParens, INT nGrouping, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2241
HRESULT WINAPI VarMonthName(INT iMonth, INT fAbbrev, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2517
HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT nParens, INT nGrouping, ULONG dwFlags, BSTR *pbstrOut)
Definition: varformat.c:2420
HRESULT WINAPI VarR8Round(double dblIn, int nDig, double *pDblOut)
Definition: vartype.c:3368
#define VBSE_ILLEGAL_FUNC_CALL
#define VBSE_FUNC_ARITY_MISMATCH
#define VBSE_ILLEGAL_NULL_USE
#define VBSE_TYPE_MISMATCH
static const WCHAR month[12][4]
Definition: session.c:2528
static const char * debugstr_variant(const VARIANT *var)
Definition: dom.c:505
#define RGB(r, g, b)
Definition: precomp.h:67
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define progid(str)
Definition: exdisp.idl:31
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint start
Definition: gl.h:1545
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei GLenum const GLvoid * indices
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint * ids
Definition: glext.h:5907
GLuint GLuint * names
Definition: glext.h:11545
GLuint color
Definition: glext.h:6243
const GLubyte * c
Definition: glext.h:8905
GLdouble GLdouble right
Definition: glext.h:10859
GLfloat f
Definition: glext.h:7540
GLenum mode
Definition: glext.h:6217
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLint left
Definition: glext.h:7726
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
GLboolean GLuint group
Definition: glext.h:11120
GLuint GLfloat * val
Definition: glext.h:7180
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
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 cs
Definition: i386-dis.c:442
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
void clear_ei(EXCEPINFO *ei)
Definition: interp.c:288
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT init_global(script_ctx_t *ctx)
Definition: global.c:1091
#define d
Definition: ke_i.h:81
#define f
Definition: ke_i.h:83
#define c
Definition: ke_i.h:80
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
POINT cp
Definition: magnifier.c:59
__u16 date
Definition: mkdosfs.c:8
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char string[160]
Definition: util.h:11
static PVOID ptr
Definition: dispmode.c:27
const IID IID_IObjectWithSite
HRESULT hres
Definition: protocol.c:465
static const WCHAR sp[]
Definition: suminfo.c:287
const char * delimiter
Definition: string.c:1779
static unsigned(__cdecl *hash_bstr)(bstr_t s)
static VARIANTARG static DISPID
Definition: ordinal.c:49
DWORD exp
Definition: msg.c:18625
static SCRIPTUICHANDLING uic_handling
Definition: run.c:166
#define min(a, b)
Definition: monoChain.cc:55
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define DEFAULT_UNREACHABLE
#define MAXDWORD
HRESULT WINAPI CreateBindCtx(DWORD reserved, IBindCtx **bind_context)
Definition: bindctx.c:491
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define V_BOOL(A)
Definition: oleauto.h:224
#define V_ARRAY(A)
Definition: oleauto.h:222
#define V_ARRAYREF(A)
Definition: oleauto.h:223
#define VAR_DATEVALUEONLY
Definition: oleauto.h:327
#define DISPATCH_PROPERTYPUT
Definition: oleauto.h:1008
#define DISPATCH_METHOD
Definition: oleauto.h:1006
#define MEMBERID_NIL
Definition: oleauto.h:1003
#define V_VARIANTREF(A)
Definition: oleauto.h:283
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
#define V_ISARRAY(A)
Definition: oleauto.h:218
#define V_R4(A)
Definition: oleauto.h:260
#define V_DISPATCH(A)
Definition: oleauto.h:239
#define V_R8(A)
Definition: oleauto.h:262
#define DISPATCH_PROPERTYGET
Definition: oleauto.h:1007
#define VAR_TIMEVALUEONLY
Definition: oleauto.h:326
#define V_DATE(A)
Definition: oleauto.h:231
#define VARIANT_LOCALBOOL
Definition: oleauto.h:314
#define V_I2(A)
Definition: oleauto.h:245
const GUID IID_IDispatch
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
static char title[]
Definition: ps.c:92
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define err(...)
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:38
const WCHAR * str
#define iswspace(_c)
Definition: ctype.h:669
DWORD LCID
Definition: nls.h:13
#define CP_UTF8
Definition: nls.h:20
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
#define log(outFile, fmt,...)
Definition: util.h:15
#define towlower(c)
Definition: wctype.h:97
#define towupper(c)
Definition: wctype.h:99
#define args
Definition: format.c:66
#define TRACE(s)
Definition: solgame.cpp:4
CardRegion * from
Definition: spigame.cpp:19
size_t member_cnt
Definition: vbscript.h:149
LONG ref
Definition: vbscript.h:148
const builtin_prop_t * members
Definition: vbscript.h:150
IDispatch IDispatch_iface
Definition: vbscript.h:147
script_ctx_t * ctx
Definition: vbscript.h:151
Definition: oleauto.h:720
SYSTEMTIME st
Definition: oleauto.h:721
USHORT wDayOfYear
Definition: oleauto.h:722
WORD wMilliseconds
Definition: minwinbase.h:263
WORD wSecond
Definition: minwinbase.h:262
WORD wMinute
Definition: minwinbase.h:261
WORD wDayOfWeek
Definition: minwinbase.h:258
const WCHAR * name
Definition: global.c:54
DWORD flags
Definition: global.c:56
HRESULT(* proc)(BuiltinDisp *, VARIANT *, unsigned, VARIANT *)
Definition: global.c:55
UINT_PTR max_args
Definition: global.c:58
unsigned min_args
Definition: global.c:57
UINT MaxCharSize
Definition: winnls.h:662
Definition: match.c:390
DWORD flags
Definition: jscript.h:177
Definition: inflate.c:139
Definition: format.c:58
Definition: name.c:39
Definition: send.c:48
UINT16 len
Definition: global.c:49
#define max(a, b)
Definition: svc.c:63
#define str_len
Definition: treelist.c:89
uint16_t * LPWSTR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
CONTEXT ctx
Definition: pdh_main.c:96
INT WINAPI VariantTimeToSystemTime(double dateIn, LPSYSTEMTIME lpSt)
Definition: variant.c:1317
HRESULT WINAPI VarDateFromUdateEx(UDATE *pUdateIn, LCID lcid, ULONG dwFlags, DATE *pDateOut)
Definition: variant.c:1345
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
Definition: variant.c:962
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
HRESULT WINAPI VarFix(LPVARIANT pVarIn, LPVARIANT pVarOut)
Definition: variant.c:4367
HRESULT WINAPI VarAbs(LPVARIANT pVarIn, LPVARIANT pVarOut)
Definition: variant.c:4263
INT WINAPI SystemTimeToVariantTime(LPSYSTEMTIME lpSt, double *pDateOut)
Definition: variant.c:1286
HRESULT WINAPI VarInt(LPVARIANT pVarIn, LPVARIANT pVarOut)
Definition: variant.c:4473
HRESULT WINAPI VariantCopyInd(VARIANT *pvargDest, VARIANTARG *pvargSrc)
Definition: variant.c:847
void map_vbs_exception(EXCEPINFO *ei)
Definition: vbdisp.c:1605
BSTR string_replace(BSTR string, BSTR find, BSTR replace, int from, int cnt, int mode)
Definition: vbregexp.c:1635
static HRESULT Global_InStrRev(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2850
static HRESULT Global_CStr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:834
static HRESULT Global_LeftB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1348
static HRESULT Global_TimeSerial(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2241
static HRESULT set_object_site(script_ctx_t *ctx, IUnknown *obj)
Definition: global.c:488
static HRESULT WINAPI Builtin_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
Definition: global.c:66
static HRESULT Global_IsNull(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:966
static HRESULT Global_IsNumeric(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:975
static HRESULT Err_Number(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3508
static IInternetHostSecurityManager * get_sec_mgr(script_ctx_t *ctx)
Definition: global.c:302
static HRESULT Global_Left(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:1310
static HRESULT Global_CreateObject(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2317
static HRESULT Global_LenB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1304
static WCHAR hex_char(unsigned n)
Definition: global.c:851
static HRESULT Global_UCase(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1552
static HRESULT Err_HelpFile(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3502
static HRESULT return_short(VARIANT *res, short val)
Definition: global.c:363
static HRESULT Global_CSng(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:813
static HRESULT Err_HelpContext(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3490
static HRESULT Global_Randomize(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1102
static HRESULT Global_Exp(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1055
static HRESULT Global_InputBox(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2278
static HRESULT Global_GetLocale(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3067
static HRESULT Global_Cos(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1019
static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR orig_title, VARIANT *res)
Definition: global.c:580
#define VB_E_CANNOT_CREATE_OBJ
Definition: global.c:38
static const string_constant_t vbTab
Definition: global.c:3265
static HRESULT Global_CDate(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:762
static HRESULT return_date(VARIANT *res, double date)
Definition: global.c:410
static HRESULT Global_Year(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2145
static HRESULT Global_Minute(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2167
static HRESULT Global_Unescape(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:3213
static HRESULT Global_UBound(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1215
static HRESULT Global_InStrB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1817
static HRESULT return_int(VARIANT *res, int val)
Definition: global.c:373
static const string_constant_t vbNullString
Definition: global.c:3264
static HRESULT Global_Err(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:3243
static HRESULT Global_TypeName(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2477
static HRESULT Global_FormatCurrency(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3003
static HRESULT Global_ScriptEngineBuildVersion(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2962
HRESULT get_builtin_id(BuiltinDisp *disp, const WCHAR *name, DISPID *id)
Definition: global.c:127
static HRESULT err_string_prop(BSTR *prop, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3467
static HRESULT Global_DatePart(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2471
static HRESULT WINAPI Builtin_Invoke(IDispatch *iface, DISPID id, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, UINT *err)
Definition: global.c:172
static HRESULT WINAPI Builtin_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
Definition: global.c:112
static HRESULT Global_Trim(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1635
static HRESULT Err_Description(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3484
static HRESULT Global_Weekday(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2099
static HRESULT Global_LoadPicture(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2929
static HRESULT Global_IsArray(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:989
static HRESULT Global_MidB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1474
static HRESULT Global_GetRef(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:3237
static HRESULT return_null(VARIANT *res)
Definition: global.c:403
static HRESULT Global_CByte(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:739
static HRESULT to_double(VARIANT *v, double *ret)
Definition: global.c:433
static HRESULT Global_Log(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1067
static HRESULT Err_Raise(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3537
static const IDispatchVtbl BuiltinDispVtbl
Definition: global.c:275
static HRESULT Global_Month(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2088
static HRESULT Global_Tan(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1043
static HRESULT Global_LCase(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1523
static const string_constant_t vbNullChar
Definition: global.c:3263
static HRESULT Global_Chr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1884
static HRESULT create_builtin_dispatch(script_ctx_t *ctx, const builtin_prop_t *members, size_t member_cnt, BuiltinDisp **ret)
Definition: global.c:285
static HRESULT Global_DateValue(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2195
static HRESULT Global_Split(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2595
static HRESULT Global_Atn(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1007
static HRESULT Global_ScriptEngine(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2935
#define BP_GETPUT
Definition: global.c:46
static const string_constant_t vbFormFeed
Definition: global.c:3261
static HRESULT to_float(VARIANT *v, float *ret)
Definition: global.c:447
static HRESULT Global_WeekdayName(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3101
static ULONG WINAPI Builtin_Release(IDispatch *iface)
Definition: global.c:97
static HRESULT Global_MsgBox(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2284
static HRESULT Global_Timer(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1163
static HRESULT Global_Sqr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1082
static HRESULT Global_CCur(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:655
static const string_constant_t vbVerticalTab
Definition: global.c:3266
static HRESULT Global_Fix(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1966
static HRESULT WINAPI Builtin_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: global.c:120
static HRESULT Global_InStr(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:1731
#define BP_GET
Definition: global.c:45
static HRESULT Global_FormatDateTime(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3073
static HRESULT Global_Right(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:1354
static HRESULT Global_RTrim(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1608
static HRESULT Global_CLng(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:700
void detach_global_objects(script_ctx_t *ctx)
Definition: global.c:3602
static const string_constant_t vbNewLine
Definition: global.c:3260
static HRESULT Global_AscB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1823
static HRESULT Global_Eval(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:3219
static HRESULT to_system_time(VARIANT *v, SYSTEMTIME *st)
Definition: global.c:475
static HRESULT Global_Hex(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:856
static HRESULT Global_ChrW(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1939
static HRESULT Global_Space(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1663
static HRESULT Global_CDbl(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:791
static HRESULT Global_Date(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2041
static const builtin_prop_t global_props[]
Definition: global.c:3268
const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
Definition: global.c:42
static HRESULT Global_RightB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1396
static HRESULT Global_FormatPercent(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3035
static HRESULT Global_VarType(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:934
static HRESULT Global_IsEmpty(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:958
static HRESULT Global_Hour(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2156
static HRESULT Global_Day(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2077
static HRESULT return_bool(VARIANT *res, BOOL val)
Definition: global.c:354
HRESULT to_int(VARIANT *v, int *ret)
Definition: global.c:419
static HRESULT Global_DateAdd(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2402
static HRESULT Global_DateDiff(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2465
static HRESULT Global_ScriptEngineMajorVersion(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2944
static IUnknown * create_object(script_ctx_t *ctx, const WCHAR *progid)
Definition: global.c:509
static HRESULT return_bstr(VARIANT *res, BSTR str)
Definition: global.c:343
static HRESULT Global_Now(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2029
static HRESULT Global_Array(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2535
static HRESULT Global_Time(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2059
static HRESULT Err_Source(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3523
static HRESULT Global_TimeValue(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2201
static HRESULT Global_StrComp(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:1480
static HRESULT Global_Execute(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:3225
static HRESULT Global_ChrB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1829
static HRESULT Global_MonthName(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3134
static HRESULT Global_IsObject(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:998
static const builtin_prop_t err_props[]
Definition: global.c:3591
static HRESULT return_string(VARIANT *res, const WCHAR *str)
Definition: global.c:327
static HRESULT Global_AscW(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1933
static HRESULT Global_SetLocale(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2189
static HRESULT Global_Oct(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:895
static HRESULT Global_GetObject(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2345
static HRESULT WINAPI Builtin_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *names, UINT name_cnt, LCID lcid, DISPID *ids)
Definition: global.c:149
static HRESULT Global_ScriptEngineMinorVersion(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2953
static HRESULT Global_CInt(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:678
static HRESULT Global_IsDate(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:951
static HRESULT Err_Clear(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3529
static HRESULT Global_Round(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:3164
static HRESULT Global_Sin(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1031
static HRESULT Global_DateSerial(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2207
static HRESULT Global_Erase(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2577
static HRESULT return_float(VARIANT *res, float val)
Definition: global.c:393
static const string_constant_t vbCr
Definition: global.c:3258
static HRESULT Global_Escape(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:3207
static HRESULT Global_String(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:1698
static HRESULT Global_RGB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1256
static HRESULT to_string(VARIANT *v, BSTR *ret)
Definition: global.c:461
static HRESULT Global_ExecuteGlobal(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:3231
static unsigned int get_next_rnd(int value)
Definition: global.c:1097
static HRESULT Global_Rnd(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1129
static BuiltinDisp * impl_from_IDispatch(IDispatch *iface)
Definition: global.c:61
static HRESULT Global_Join(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2589
static HRESULT Global_Int(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1987
static HRESULT Global_Filter(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2583
static HRESULT Global_CBool(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:718
static HRESULT Global_FormatNumber(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2971
static HRESULT Global_Len(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1278
static const string_constant_t vbLf
Definition: global.c:3262
static HRESULT return_double(VARIANT *res, double val)
Definition: global.c:383
static HRESULT Global_Sgn(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2008
static ULONG WINAPI Builtin_AddRef(IDispatch *iface)
Definition: global.c:87
static HRESULT Global_Mid(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:1402
static HRESULT Global_Abs(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1945
static HRESULT Global_StrReverse(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2827
static HRESULT Global_Replace(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
Definition: global.c:2737
static HRESULT Global_LBound(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1174
static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1835
static HRESULT Global_LTrim(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:1581
static HRESULT Global_Second(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
Definition: global.c:2178
static const string_constant_t vbCrLf
Definition: global.c:3259
#define VBSCRIPT_BUILD_VERSION
Definition: vbscript.h:432
#define FACILITY_VBS
Definition: vbscript.h:424
static unsigned arg_cnt(const DISPPARAMS *dp)
Definition: vbscript.h:175
#define VBSCRIPT_MAJOR_VERSION
Definition: vbscript.h:433
#define VBSCRIPT_MINOR_VERSION
Definition: vbscript.h:434
#define MAKE_VBSERROR(code)
Definition: vbscript.h:425
_In_ size_t cnt
Definition: wcstombs.cpp:43
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
const char * description
Definition: directx.c:2497
#define E_NOINTERFACE
Definition: winerror.h:3479
#define HRESULT_FACILITY(hr)
Definition: winerror.h:191
#define DISP_E_BADVARTYPE
Definition: winerror.h:3620
#define DISP_E_MEMBERNOTFOUND
Definition: winerror.h:3615
#define MK_E_SYNTAX
Definition: winerror.h:3896
#define E_UNEXPECTED
Definition: winerror.h:3528
#define DISP_E_BADINDEX
Definition: winerror.h:3623
#define HRESULT_CODE(hr)
Definition: winerror.h:188
#define DISP_E_TYPEMISMATCH
Definition: winerror.h:3617
#define FIND_FROMEND
Definition: winnls.h:231
#define FIND_FROMSTART
Definition: winnls.h:230
#define LOCALE_IFIRSTDAYOFWEEK
Definition: winnls.h:85
#define MB_SETFOREGROUND
Definition: winuser.h:825
#define MB_RIGHT
Definition: winuser.h:806
#define IDCANCEL
Definition: winuser.h:842
#define MB_ICONHAND
Definition: winuser.h:799
#define MB_SYSTEMMODAL
Definition: winuser.h:826
#define MB_DEFBUTTON4
Definition: winuser.h:812
#define MB_DEFBUTTON3
Definition: winuser.h:811
#define MB_HELP
Definition: winuser.h:805
#define MB_RETRYCANCEL
Definition: winuser.h:816
#define MB_YESNO
Definition: winuser.h:828
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define IDOK
Definition: winuser.h:841
#define IDIGNORE
Definition: winuser.h:845
#define MB_DEFBUTTON1
Definition: winuser.h:809
#define MB_OKCANCEL
Definition: winuser.h:815
#define MB_RTLREADING
Definition: winuser.h:807
#define IDNO
Definition: winuser.h:847
#define MB_ABORTRETRYIGNORE
Definition: winuser.h:802
#define MB_ICONEXCLAMATION
Definition: winuser.h:796
#define MB_OK
Definition: winuser.h:801
#define IDABORT
Definition: winuser.h:843
#define MB_ICONQUESTION
Definition: winuser.h:800
#define MB_DEFBUTTON2
Definition: winuser.h:810
#define IDYES
Definition: winuser.h:846
#define IDRETRY
Definition: winuser.h:844
#define MB_ICONASTERISK
Definition: winuser.h:795
#define MB_APPLMODAL
Definition: winuser.h:803
#define MB_YESNOCANCEL
Definition: winuser.h:829
unsigned char BYTE
Definition: xxhash.c:193