comctl32: Improve mouse wheel scrolling in treeview control.
[wine.git] / dlls / vbscript / global.c
blob39b75abbb2f46a4f4ef8a807c6c14b2bbc4a6454
1 /*
2 * Copyright 2011 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <assert.h>
20 #include <math.h>
22 #include "vbscript.h"
23 #include "vbscript_defs.h"
25 #include "mshtmhst.h"
26 #include "objsafe.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
32 #define VB_E_CANNOT_CREATE_OBJ 0x800a01ad
33 #define VB_E_MK_PARSE_ERROR 0x800a01b0
35 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
36 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
37 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
39 static const WCHAR emptyW[] = {0};
40 static const WCHAR vbscriptW[] = {'V','B','S','c','r','i','p','t',0};
42 static IInternetHostSecurityManager *get_sec_mgr(script_ctx_t *ctx)
44 IInternetHostSecurityManager *secmgr;
45 IServiceProvider *sp;
46 HRESULT hres;
48 if(!ctx->site)
49 return NULL;
51 if(ctx->secmgr)
52 return ctx->secmgr;
54 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
55 if(FAILED(hres))
56 return NULL;
58 hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager, &IID_IInternetHostSecurityManager,
59 (void**)&secmgr);
60 IServiceProvider_Release(sp);
61 if(FAILED(hres))
62 return NULL;
64 return ctx->secmgr = secmgr;
67 static HRESULT return_string(VARIANT *res, const WCHAR *str)
69 BSTR ret;
71 if(!res)
72 return S_OK;
74 ret = SysAllocString(str);
75 if(!ret)
76 return E_OUTOFMEMORY;
78 V_VT(res) = VT_BSTR;
79 V_BSTR(res) = ret;
80 return S_OK;
83 static HRESULT return_bstr(VARIANT *res, BSTR str)
85 if(res) {
86 V_VT(res) = VT_BSTR;
87 V_BSTR(res) = str;
88 }else {
89 SysFreeString(str);
91 return S_OK;
94 static HRESULT return_short(VARIANT *res, short val)
96 if(res) {
97 V_VT(res) = VT_I2;
98 V_I2(res) = val;
101 return S_OK;
104 static HRESULT return_int(VARIANT *res, int val)
106 if((short)val == val)
107 return return_short(res, val);
109 if(res) {
110 V_VT(res) = VT_I4;
111 V_I4(res) = val;
114 return S_OK;
117 static inline HRESULT return_double(VARIANT *res, double val)
119 if(res) {
120 V_VT(res) = VT_R8;
121 V_R8(res) = val;
124 return S_OK;
127 static inline HRESULT return_null(VARIANT *res)
129 if(res)
130 V_VT(res) = VT_NULL;
131 return S_OK;
134 static inline HRESULT return_date(VARIANT *res, double date)
136 if(res) {
137 V_VT(res) = VT_DATE;
138 V_DATE(res) = date;
140 return S_OK;
143 static HRESULT to_int(VARIANT *v, int *ret)
145 switch(V_VT(v)) {
146 case VT_I2:
147 *ret = V_I2(v);
148 break;
149 case VT_I4:
150 *ret = V_I4(v);
151 break;
152 case VT_R8: {
153 double n = round(V_R8(v));
154 if(!is_int32(n)) {
155 FIXME("%lf is out of int range\n", n);
156 return E_FAIL;
158 *ret = n;
159 break;
161 case VT_BOOL:
162 *ret = V_BOOL(v) ? -1 : 0;
163 break;
164 default:
165 FIXME("not supported %s\n", debugstr_variant(v));
166 return E_NOTIMPL;
169 return S_OK;
172 static HRESULT to_double(VARIANT *v, double *ret)
174 switch(V_VT(v)) {
175 case VT_I2:
176 *ret = V_I2(v);
177 break;
178 case VT_I4:
179 *ret = V_I4(v);
180 break;
181 case VT_R4:
182 *ret = V_R4(v);
183 break;
184 case VT_R8:
185 *ret = V_R8(v);
186 break;
187 case VT_BSTR: {
188 VARIANT dst;
189 HRESULT hres;
191 V_VT(&dst) = VT_EMPTY;
192 hres = VariantChangeType(&dst, v, VARIANT_LOCALBOOL, VT_R8);
193 if(FAILED(hres))
194 return hres;
195 *ret = V_R8(&dst);
196 break;
198 default:
199 FIXME("arg %s not supported\n", debugstr_variant(v));
200 return E_NOTIMPL;
203 return S_OK;
206 static HRESULT to_string(VARIANT *v, BSTR *ret)
208 VARIANT dst;
209 HRESULT hres;
211 V_VT(&dst) = VT_EMPTY;
212 hres = VariantChangeType(&dst, v, VARIANT_LOCALBOOL, VT_BSTR);
213 if(FAILED(hres))
214 return hres;
216 *ret = V_BSTR(&dst);
217 return S_OK;
220 static HRESULT set_object_site(script_ctx_t *ctx, IUnknown *obj)
222 IObjectWithSite *obj_site;
223 IUnknown *ax_site;
224 HRESULT hres;
226 hres = IUnknown_QueryInterface(obj, &IID_IObjectWithSite, (void**)&obj_site);
227 if(FAILED(hres))
228 return S_OK;
230 ax_site = create_ax_site(ctx);
231 if(ax_site)
232 hres = IObjectWithSite_SetSite(obj_site, ax_site);
233 else
234 hres = E_OUTOFMEMORY;
235 IUnknown_Release(ax_site);
236 IObjectWithSite_Release(obj_site);
237 return hres;
240 static IUnknown *create_object(script_ctx_t *ctx, const WCHAR *progid)
242 IInternetHostSecurityManager *secmgr = NULL;
243 struct CONFIRMSAFETY cs;
244 IClassFactoryEx *cfex;
245 IClassFactory *cf;
246 DWORD policy_size;
247 BYTE *bpolicy;
248 IUnknown *obj;
249 DWORD policy;
250 GUID guid;
251 HRESULT hres;
253 hres = CLSIDFromProgID(progid, &guid);
254 if(FAILED(hres))
255 return NULL;
257 TRACE("GUID %s\n", debugstr_guid(&guid));
259 if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
260 secmgr = get_sec_mgr(ctx);
261 if(!secmgr)
262 return NULL;
264 policy = 0;
265 hres = IInternetHostSecurityManager_ProcessUrlAction(secmgr, URLACTION_ACTIVEX_RUN,
266 (BYTE*)&policy, sizeof(policy), (BYTE*)&guid, sizeof(GUID), 0, 0);
267 if(FAILED(hres) || policy != URLPOLICY_ALLOW)
268 return NULL;
271 hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf);
272 if(FAILED(hres))
273 return NULL;
275 hres = IClassFactory_QueryInterface(cf, &IID_IClassFactoryEx, (void**)&cfex);
276 if(SUCCEEDED(hres)) {
277 FIXME("Use IClassFactoryEx\n");
278 IClassFactoryEx_Release(cfex);
281 hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
282 if(FAILED(hres))
283 return NULL;
285 if(secmgr) {
286 cs.clsid = guid;
287 cs.pUnk = obj;
288 cs.dwFlags = 0;
289 hres = IInternetHostSecurityManager_QueryCustomPolicy(secmgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
290 &bpolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
291 if(SUCCEEDED(hres)) {
292 policy = policy_size >= sizeof(DWORD) ? *(DWORD*)bpolicy : URLPOLICY_DISALLOW;
293 CoTaskMemFree(bpolicy);
296 if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
297 IUnknown_Release(obj);
298 return NULL;
302 hres = set_object_site(ctx, obj);
303 if(FAILED(hres)) {
304 IUnknown_Release(obj);
305 return NULL;
308 return obj;
311 static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, VARIANT *res)
313 SCRIPTUICHANDLING uic_handling = SCRIPTUICHANDLING_ALLOW;
314 IActiveScriptSiteUIControl *ui_control;
315 IActiveScriptSiteWindow *acts_window;
316 const WCHAR *title;
317 HWND hwnd = NULL;
318 int ret;
319 HRESULT hres;
321 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteUIControl, (void**)&ui_control);
322 if(SUCCEEDED(hres)) {
323 hres = IActiveScriptSiteUIControl_GetUIBehavior(ui_control, SCRIPTUICITEM_MSGBOX, &uic_handling);
324 IActiveScriptSiteUIControl_Release(ui_control);
325 if(FAILED(hres))
326 uic_handling = SCRIPTUICHANDLING_ALLOW;
329 switch(uic_handling) {
330 case SCRIPTUICHANDLING_ALLOW:
331 break;
332 case SCRIPTUICHANDLING_NOUIDEFAULT:
333 return return_short(res, 0);
334 default:
335 FIXME("blocked\n");
336 return E_FAIL;
339 title = (ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) ? vbscriptW : emptyW;
341 hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteWindow, (void**)&acts_window);
342 if(FAILED(hres)) {
343 FIXME("No IActiveScriptSiteWindow\n");
344 return hres;
347 hres = IActiveScriptSiteWindow_GetWindow(acts_window, &hwnd);
348 if(SUCCEEDED(hres)) {
349 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, FALSE);
350 if(SUCCEEDED(hres)) {
351 ret = MessageBoxW(hwnd, prompt, title, MB_OK);
352 hres = IActiveScriptSiteWindow_EnableModeless(acts_window, TRUE);
356 IActiveScriptSiteWindow_Release(acts_window);
357 if(FAILED(hres)) {
358 FIXME("failed: %08x\n", hres);
359 return hres;
362 return return_short(res, ret);
365 static HRESULT Global_CCur(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
367 FIXME("\n");
368 return E_NOTIMPL;
371 static HRESULT Global_CInt(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
373 FIXME("\n");
374 return E_NOTIMPL;
377 static HRESULT Global_CLng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
379 FIXME("\n");
380 return E_NOTIMPL;
383 static HRESULT Global_CBool(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
385 FIXME("\n");
386 return E_NOTIMPL;
389 static HRESULT Global_CByte(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
391 FIXME("\n");
392 return E_NOTIMPL;
395 static HRESULT Global_CDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
397 FIXME("\n");
398 return E_NOTIMPL;
401 static HRESULT Global_CDbl(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
403 FIXME("\n");
404 return E_NOTIMPL;
407 static HRESULT Global_CSng(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
409 FIXME("\n");
410 return E_NOTIMPL;
413 static HRESULT Global_CStr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
415 BSTR str;
416 HRESULT hres;
418 TRACE("%s\n", debugstr_variant(arg));
420 hres = to_string(arg, &str);
421 if(FAILED(hres))
422 return hres;
424 return return_bstr(res, str);
427 static inline WCHAR hex_char(unsigned n)
429 return n < 10 ? '0'+n : 'A'+n-10;
432 static HRESULT Global_Hex(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
434 WCHAR buf[17], *ptr;
435 DWORD n;
437 TRACE("%s\n", debugstr_variant(arg));
439 switch(V_VT(arg)) {
440 case VT_I2:
441 n = (WORD)V_I2(arg);
442 break;
443 case VT_I4:
444 n = V_I4(arg);
445 break;
446 case VT_EMPTY:
447 n = 0;
448 break;
449 case VT_NULL:
450 if(res)
451 V_VT(res) = VT_NULL;
452 return S_OK;
453 default:
454 FIXME("unsupported type %s\n", debugstr_variant(arg));
455 return E_NOTIMPL;
458 buf[16] = 0;
459 ptr = buf+15;
461 if(n) {
462 do {
463 *ptr-- = hex_char(n & 0xf);
464 n >>= 4;
465 }while(n);
466 ptr++;
467 }else {
468 *ptr = '0';
471 return return_string(res, ptr);
474 static HRESULT Global_Oct(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
476 FIXME("\n");
477 return E_NOTIMPL;
480 static HRESULT Global_VarType(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
482 FIXME("\n");
483 return E_NOTIMPL;
486 static HRESULT Global_IsDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
488 FIXME("\n");
489 return E_NOTIMPL;
492 static HRESULT Global_IsEmpty(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
494 TRACE("(%s)\n", debugstr_variant(arg));
496 assert(args_cnt == 1);
498 if(res) {
499 V_VT(res) = VT_BOOL;
500 V_BOOL(res) = V_VT(arg) == VT_EMPTY ? VARIANT_TRUE : VARIANT_FALSE;
502 return S_OK;
505 static HRESULT Global_IsNull(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
507 TRACE("(%s)\n", debugstr_variant(arg));
509 assert(args_cnt == 1);
511 if(res) {
512 V_VT(res) = VT_BOOL;
513 V_BOOL(res) = V_VT(arg) == VT_NULL ? VARIANT_TRUE : VARIANT_FALSE;
515 return S_OK;
518 static HRESULT Global_IsNumeric(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
520 FIXME("\n");
521 return E_NOTIMPL;
524 static HRESULT Global_IsArray(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
526 FIXME("\n");
527 return E_NOTIMPL;
530 static HRESULT Global_IsObject(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
532 TRACE("(%s)\n", debugstr_variant(arg));
534 assert(args_cnt == 1);
536 if(res) {
537 V_VT(res) = VT_BOOL;
538 V_BOOL(res) = V_VT(arg) == VT_DISPATCH ? VARIANT_TRUE : VARIANT_FALSE;
540 return S_OK;
543 static HRESULT Global_Ant(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
545 FIXME("\n");
546 return E_NOTIMPL;
549 static HRESULT Global_Cos(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
551 FIXME("\n");
552 return E_NOTIMPL;
555 static HRESULT Global_Sin(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
557 FIXME("\n");
558 return E_NOTIMPL;
561 static HRESULT Global_Tan(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
563 FIXME("\n");
564 return E_NOTIMPL;
567 static HRESULT Global_Exp(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
569 FIXME("\n");
570 return E_NOTIMPL;
573 static HRESULT Global_Log(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
575 FIXME("\n");
576 return E_NOTIMPL;
579 static HRESULT Global_Sqr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
581 FIXME("\n");
582 return E_NOTIMPL;
585 static HRESULT Global_Randomize(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
587 FIXME("\n");
588 return E_NOTIMPL;
591 static HRESULT Global_Rnd(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
593 FIXME("\n");
594 return E_NOTIMPL;
597 static HRESULT Global_Timer(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
599 FIXME("\n");
600 return E_NOTIMPL;
603 static HRESULT Global_LBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
605 FIXME("\n");
606 return E_NOTIMPL;
609 static HRESULT Global_UBound(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
611 FIXME("\n");
612 return E_NOTIMPL;
615 static HRESULT Global_RGB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
617 FIXME("\n");
618 return E_NOTIMPL;
621 static HRESULT Global_Len(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
623 DWORD len;
624 HRESULT hres;
626 TRACE("%s\n", debugstr_variant(arg));
628 if(V_VT(arg) == VT_NULL)
629 return return_null(res);
631 if(V_VT(arg) != VT_BSTR) {
632 BSTR str;
634 hres = to_string(arg, &str);
635 if(FAILED(hres))
636 return hres;
638 len = SysStringLen(str);
639 SysFreeString(str);
640 }else {
641 len = SysStringLen(V_BSTR(arg));
644 return return_int(res, len);
647 static HRESULT Global_LenB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
649 FIXME("\n");
650 return E_NOTIMPL;
653 static HRESULT Global_Left(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
655 BSTR str, ret, conv_str = NULL;
656 int len, str_len;
657 HRESULT hres;
659 TRACE("(%s %s)\n", debugstr_variant(args+1), debugstr_variant(args));
661 if(V_VT(args) == VT_BSTR) {
662 str = V_BSTR(args);
663 }else {
664 hres = to_string(args, &conv_str);
665 if(FAILED(hres))
666 return hres;
667 str = conv_str;
670 hres = to_int(args+1, &len);
671 if(FAILED(hres))
672 return hres;
674 if(len < 0) {
675 FIXME("len = %d\n", len);
676 return E_FAIL;
679 str_len = SysStringLen(str);
680 if(len > str_len)
681 len = str_len;
683 ret = SysAllocStringLen(str, len);
684 SysFreeString(conv_str);
685 if(!ret)
686 return E_OUTOFMEMORY;
688 return return_bstr(res, ret);
691 static HRESULT Global_LeftB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
693 FIXME("\n");
694 return E_NOTIMPL;
697 static HRESULT Global_Right(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
699 BSTR str, ret, conv_str = NULL;
700 int len, str_len;
701 HRESULT hres;
703 TRACE("(%s %s)\n", debugstr_variant(args), debugstr_variant(args+1));
705 if(V_VT(args+1) == VT_BSTR) {
706 str = V_BSTR(args);
707 }else {
708 hres = to_string(args, &conv_str);
709 if(FAILED(hres))
710 return hres;
711 str = conv_str;
714 hres = to_int(args+1, &len);
715 if(FAILED(hres))
716 return hres;
718 if(len < 0) {
719 FIXME("len = %d\n", len);
720 return E_FAIL;
723 str_len = SysStringLen(str);
724 if(len > str_len)
725 len = str_len;
727 ret = SysAllocStringLen(str+str_len-len, len);
728 SysFreeString(conv_str);
729 if(!ret)
730 return E_OUTOFMEMORY;
732 return return_bstr(res, ret);
735 static HRESULT Global_RightB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
737 FIXME("\n");
738 return E_NOTIMPL;
741 static HRESULT Global_Mid(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
743 int len = -1, start, str_len;
744 BSTR str;
745 HRESULT hres;
747 TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
749 assert(args_cnt == 2 || args_cnt == 3);
751 if(V_VT(args) != VT_BSTR) {
752 FIXME("args[0] = %s\n", debugstr_variant(args));
753 return E_NOTIMPL;
756 str = V_BSTR(args);
758 hres = to_int(args+1, &start);
759 if(FAILED(hres))
760 return hres;
762 if(args_cnt == 3) {
763 hres = to_int(args+2, &len);
764 if(FAILED(hres))
765 return hres;
767 if(len < 0) {
768 FIXME("len = %d\n", len);
769 return E_FAIL;
774 str_len = SysStringLen(str);
775 start--;
776 if(start > str_len)
777 start = str_len;
779 if(len == -1)
780 len = str_len-start;
781 else if(len > str_len-start)
782 len = str_len-start;
784 if(res) {
785 V_VT(res) = VT_BSTR;
786 V_BSTR(res) = SysAllocStringLen(str+start, len);
787 if(!V_BSTR(res))
788 return E_OUTOFMEMORY;
791 return S_OK;
794 static HRESULT Global_MidB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
796 FIXME("\n");
797 return E_NOTIMPL;
800 static HRESULT Global_StrComp(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
802 FIXME("\n");
803 return E_NOTIMPL;
806 static HRESULT Global_LCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
808 BSTR str;
809 HRESULT hres;
811 TRACE("%s\n", debugstr_variant(arg));
813 if(V_VT(arg) == VT_NULL) {
814 if(res)
815 V_VT(res) = VT_NULL;
816 return S_OK;
819 hres = to_string(arg, &str);
820 if(FAILED(hres))
821 return hres;
823 if(res) {
824 WCHAR *ptr;
826 for(ptr = str; *ptr; ptr++)
827 *ptr = tolowerW(*ptr);
829 V_VT(res) = VT_BSTR;
830 V_BSTR(res) = str;
831 }else {
832 SysFreeString(str);
834 return S_OK;
837 static HRESULT Global_UCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
839 BSTR str;
840 HRESULT hres;
842 TRACE("%s\n", debugstr_variant(arg));
844 if(V_VT(arg) == VT_NULL) {
845 if(res)
846 V_VT(res) = VT_NULL;
847 return S_OK;
850 hres = to_string(arg, &str);
851 if(FAILED(hres))
852 return hres;
854 if(res) {
855 WCHAR *ptr;
857 for(ptr = str; *ptr; ptr++)
858 *ptr = toupperW(*ptr);
860 V_VT(res) = VT_BSTR;
861 V_BSTR(res) = str;
862 }else {
863 SysFreeString(str);
865 return S_OK;
868 static HRESULT Global_LTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
870 BSTR str, conv_str = NULL;
871 WCHAR *ptr;
872 HRESULT hres;
874 TRACE("%s\n", debugstr_variant(arg));
876 if(V_VT(arg) == VT_BSTR) {
877 str = V_BSTR(arg);
878 }else {
879 hres = to_string(arg, &conv_str);
880 if(FAILED(hres))
881 return hres;
882 str = conv_str;
885 for(ptr = str; *ptr && isspaceW(*ptr); ptr++);
887 str = SysAllocString(ptr);
888 SysFreeString(conv_str);
889 if(!str)
890 return E_OUTOFMEMORY;
892 return return_bstr(res, str);
895 static HRESULT Global_RTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
897 BSTR str, conv_str = NULL;
898 WCHAR *ptr;
899 HRESULT hres;
901 TRACE("%s\n", debugstr_variant(arg));
903 if(V_VT(arg) == VT_BSTR) {
904 str = V_BSTR(arg);
905 }else {
906 hres = to_string(arg, &conv_str);
907 if(FAILED(hres))
908 return hres;
909 str = conv_str;
912 for(ptr = str+SysStringLen(str); ptr-1 > str && isspaceW(*(ptr-1)); ptr--);
914 str = SysAllocStringLen(str, ptr-str);
915 SysFreeString(conv_str);
916 if(!str)
917 return E_OUTOFMEMORY;
919 return return_bstr(res, str);
922 static HRESULT Global_Trim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
924 BSTR str, conv_str = NULL;
925 WCHAR *begin_ptr, *end_ptr;
926 HRESULT hres;
928 TRACE("%s\n", debugstr_variant(arg));
930 if(V_VT(arg) == VT_BSTR) {
931 str = V_BSTR(arg);
932 }else {
933 hres = to_string(arg, &conv_str);
934 if(FAILED(hres))
935 return hres;
936 str = conv_str;
939 for(begin_ptr = str; *begin_ptr && isspaceW(*begin_ptr); begin_ptr++);
940 for(end_ptr = str+SysStringLen(str); end_ptr-1 > begin_ptr && isspaceW(*(end_ptr-1)); end_ptr--);
942 str = SysAllocStringLen(begin_ptr, end_ptr-begin_ptr);
943 SysFreeString(conv_str);
944 if(!str)
945 return E_OUTOFMEMORY;
947 return return_bstr(res, str);
950 static HRESULT Global_Space(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
952 BSTR str;
953 int n, i;
954 HRESULT hres;
956 TRACE("%s\n", debugstr_variant(arg));
958 hres = to_int(arg, &n);
959 if(FAILED(hres))
960 return hres;
962 if(n < 0) {
963 FIXME("n = %d\n", n);
964 return E_NOTIMPL;
967 if(!res)
968 return S_OK;
970 str = SysAllocStringLen(NULL, n);
971 if(!str)
972 return E_OUTOFMEMORY;
974 for(i=0; i<n; i++)
975 str[i] = ' ';
977 V_VT(res) = VT_BSTR;
978 V_BSTR(res) = str;
979 return S_OK;
982 static HRESULT Global_String(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
984 FIXME("\n");
985 return E_NOTIMPL;
988 static HRESULT Global_InStr(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
990 VARIANT *startv, *str1v, *str2v;
991 BSTR str1, str2;
992 int start, ret;
993 HRESULT hres;
995 TRACE("\n");
997 assert(2 <= args_cnt && args_cnt <= 4);
999 switch(args_cnt) {
1000 case 2:
1001 startv = NULL;
1002 str1v = args;
1003 str2v = args+1;
1004 break;
1005 case 3:
1006 startv = args;
1007 str1v = args+1;
1008 str2v = args+2;
1009 break;
1010 case 4:
1011 FIXME("unsupported compare argument %s\n", debugstr_variant(args));
1012 return E_NOTIMPL;
1013 default:
1014 assert(0);
1017 if(startv) {
1018 hres = to_int(startv, &start);
1019 if(FAILED(hres))
1020 return hres;
1021 if(--start < 0) {
1022 FIXME("start %d\n", start);
1023 return E_FAIL;
1025 }else {
1026 start = 0;
1029 if(V_VT(str1v) == VT_NULL || V_VT(str2v) == VT_NULL)
1030 return return_null(res);
1032 if(V_VT(str1v) != VT_BSTR) {
1033 FIXME("Unsupported str1 type %s\n", debugstr_variant(str1v));
1034 return E_NOTIMPL;
1036 str1 = V_BSTR(str1v);
1038 if(V_VT(str2v) != VT_BSTR) {
1039 FIXME("Unsupported str2 type %s\n", debugstr_variant(str2v));
1040 return E_NOTIMPL;
1042 str2 = V_BSTR(str2v);
1044 if(start < SysStringLen(str1)) {
1045 WCHAR *ptr;
1047 ptr = strstrW(str1+start, str2);
1048 ret = ptr ? ptr-str1+1 : 0;
1049 }else {
1050 ret = 0;
1053 return return_int(res, ret);
1056 static HRESULT Global_InStrB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1058 FIXME("\n");
1059 return E_NOTIMPL;
1062 static HRESULT Global_AscB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1064 FIXME("\n");
1065 return E_NOTIMPL;
1068 static HRESULT Global_ChrB(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1070 FIXME("\n");
1071 return E_NOTIMPL;
1074 static HRESULT Global_Asc(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1076 FIXME("\n");
1077 return E_NOTIMPL;
1080 static HRESULT Global_Chr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1082 int c;
1083 HRESULT hres;
1085 TRACE("%s\n", debugstr_variant(arg));
1087 hres = to_int(arg, &c);
1088 if(FAILED(hres))
1089 return hres;
1091 if(c <= 0 || c >= 0x100) {
1092 FIXME("invalid arg\n");
1093 return E_FAIL;
1096 if(res) {
1097 WCHAR ch = c;
1099 V_VT(res) = VT_BSTR;
1100 V_BSTR(res) = SysAllocStringLen(&ch, 1);
1101 if(!V_BSTR(res))
1102 return E_OUTOFMEMORY;
1104 return S_OK;
1107 static HRESULT Global_AscW(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1109 FIXME("\n");
1110 return E_NOTIMPL;
1113 static HRESULT Global_ChrW(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1115 FIXME("\n");
1116 return E_NOTIMPL;
1119 static HRESULT Global_Abs(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1121 FIXME("\n");
1122 return E_NOTIMPL;
1125 static HRESULT Global_Fix(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1127 FIXME("\n");
1128 return E_NOTIMPL;
1131 static HRESULT Global_Int(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1133 FIXME("\n");
1134 return E_NOTIMPL;
1137 static HRESULT Global_Sgn(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1139 FIXME("\n");
1140 return E_NOTIMPL;
1143 static HRESULT Global_Now(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1145 SYSTEMTIME lt;
1146 double date;
1148 TRACE("\n");
1150 GetLocalTime(&lt);
1151 SystemTimeToVariantTime(&lt, &date);
1152 return return_date(res, date);
1155 static HRESULT Global_Date(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1157 FIXME("\n");
1158 return E_NOTIMPL;
1161 static HRESULT Global_Time(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1163 FIXME("\n");
1164 return E_NOTIMPL;
1167 static HRESULT Global_Day(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1169 FIXME("\n");
1170 return E_NOTIMPL;
1173 static HRESULT Global_Month(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1175 FIXME("\n");
1176 return E_NOTIMPL;
1179 static HRESULT Global_Weekday(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1181 FIXME("\n");
1182 return E_NOTIMPL;
1185 static HRESULT Global_Year(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1187 FIXME("\n");
1188 return E_NOTIMPL;
1191 static HRESULT Global_Hour(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1193 FIXME("\n");
1194 return E_NOTIMPL;
1197 static HRESULT Global_Minute(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1199 FIXME("\n");
1200 return E_NOTIMPL;
1203 static HRESULT Global_Second(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1205 FIXME("\n");
1206 return E_NOTIMPL;
1209 static HRESULT Global_DateValue(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1211 FIXME("\n");
1212 return E_NOTIMPL;
1215 static HRESULT Global_TimeValue(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1217 FIXME("\n");
1218 return E_NOTIMPL;
1221 static HRESULT Global_DateSerial(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1223 FIXME("\n");
1224 return E_NOTIMPL;
1227 static HRESULT Global_TimeSerial(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1229 FIXME("\n");
1230 return E_NOTIMPL;
1233 static HRESULT Global_InputBox(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1235 FIXME("\n");
1236 return E_NOTIMPL;
1239 static HRESULT Global_MsgBox(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
1241 BSTR prompt;
1242 HRESULT hres;
1244 TRACE("\n");
1246 if(args_cnt != 1) {
1247 FIXME("unsupported arg_cnt %d\n", args_cnt);
1248 return E_NOTIMPL;
1251 hres = to_string(args, &prompt);
1252 if(FAILED(hres))
1253 return hres;
1255 hres = show_msgbox(This->desc->ctx, prompt, res);
1256 SysFreeString(prompt);
1257 return hres;
1260 static HRESULT Global_CreateObject(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1262 IUnknown *obj;
1263 HRESULT hres;
1265 TRACE("(%s)\n", debugstr_variant(arg));
1267 if(V_VT(arg) != VT_BSTR) {
1268 FIXME("non-bstr arg\n");
1269 return E_INVALIDARG;
1272 obj = create_object(This->desc->ctx, V_BSTR(arg));
1273 if(!obj)
1274 return VB_E_CANNOT_CREATE_OBJ;
1276 if(res) {
1277 hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&V_DISPATCH(res));
1278 if(FAILED(hres))
1279 return hres;
1281 V_VT(res) = VT_DISPATCH;
1284 IUnknown_Release(obj);
1285 return S_OK;
1288 static HRESULT Global_GetObject(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
1290 IBindCtx *bind_ctx;
1291 IUnknown *obj_unk;
1292 IDispatch *disp;
1293 ULONG eaten = 0;
1294 IMoniker *mon;
1295 HRESULT hres;
1297 TRACE("%s %s\n", args_cnt ? debugstr_variant(args) : "", args_cnt > 1 ? debugstr_variant(args+1) : "");
1299 if(args_cnt != 1 || V_VT(args) != VT_BSTR) {
1300 FIXME("unsupported args\n");
1301 return E_NOTIMPL;
1304 if(This->desc->ctx->safeopt & (INTERFACE_USES_SECURITY_MANAGER|INTERFACESAFE_FOR_UNTRUSTED_DATA)) {
1305 WARN("blocked in current safety mode\n");
1306 return VB_E_CANNOT_CREATE_OBJ;
1309 hres = CreateBindCtx(0, &bind_ctx);
1310 if(FAILED(hres))
1311 return hres;
1313 hres = MkParseDisplayName(bind_ctx, V_BSTR(args), &eaten, &mon);
1314 if(SUCCEEDED(hres)) {
1315 hres = IMoniker_BindToObject(mon, bind_ctx, NULL, &IID_IUnknown, (void**)&obj_unk);
1316 IMoniker_Release(mon);
1317 }else {
1318 hres = MK_E_SYNTAX;
1320 IBindCtx_Release(bind_ctx);
1321 if(FAILED(hres))
1322 return hres;
1324 hres = set_object_site(This->desc->ctx, obj_unk);
1325 if(FAILED(hres)) {
1326 IUnknown_Release(obj_unk);
1327 return hres;
1330 hres = IUnknown_QueryInterface(obj_unk, &IID_IDispatch, (void**)&disp);
1331 if(SUCCEEDED(hres)) {
1332 if(res) {
1333 V_VT(res) = VT_DISPATCH;
1334 V_DISPATCH(res) = disp;
1335 }else {
1336 IDispatch_Release(disp);
1338 }else {
1339 FIXME("object does not support IDispatch\n");
1342 return hres;
1345 static HRESULT Global_DateAdd(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1347 FIXME("\n");
1348 return E_NOTIMPL;
1351 static HRESULT Global_DateDiff(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1353 FIXME("\n");
1354 return E_NOTIMPL;
1357 static HRESULT Global_DatePart(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1359 FIXME("\n");
1360 return E_NOTIMPL;
1363 static HRESULT Global_TypeName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1365 FIXME("\n");
1366 return E_NOTIMPL;
1369 static HRESULT Global_Array(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1371 FIXME("\n");
1372 return E_NOTIMPL;
1375 static HRESULT Global_Erase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1377 FIXME("\n");
1378 return E_NOTIMPL;
1381 static HRESULT Global_Filter(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1383 FIXME("\n");
1384 return E_NOTIMPL;
1387 static HRESULT Global_Join(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1389 FIXME("\n");
1390 return E_NOTIMPL;
1393 static HRESULT Global_Split(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1395 FIXME("\n");
1396 return E_NOTIMPL;
1399 static HRESULT Global_Replace(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1401 FIXME("\n");
1402 return E_NOTIMPL;
1405 static HRESULT Global_StrReverse(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1407 WCHAR *ptr1, *ptr2, ch;
1408 BSTR ret;
1409 HRESULT hres;
1411 TRACE("%s\n", debugstr_variant(arg));
1413 hres = to_string(arg, &ret);
1414 if(FAILED(hres))
1415 return hres;
1417 ptr1 = ret;
1418 ptr2 = ret + SysStringLen(ret)-1;
1419 while(ptr1 < ptr2) {
1420 ch = *ptr1;
1421 *ptr1++ = *ptr2;
1422 *ptr2-- = ch;
1425 return return_bstr(res, ret);
1428 static HRESULT Global_InStrRev(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1430 FIXME("\n");
1431 return E_NOTIMPL;
1434 static HRESULT Global_LoadPicture(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1436 FIXME("\n");
1437 return E_NOTIMPL;
1440 static HRESULT Global_ScriptEngine(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1442 FIXME("\n");
1443 return E_NOTIMPL;
1446 static HRESULT Global_ScriptEngineMajorVersion(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1448 FIXME("\n");
1449 return E_NOTIMPL;
1452 static HRESULT Global_ScriptEngineMinorVersion(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1454 FIXME("\n");
1455 return E_NOTIMPL;
1458 static HRESULT Global_ScriptEngineBuildVersion(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1460 FIXME("\n");
1461 return E_NOTIMPL;
1464 static HRESULT Global_FormatNumber(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1466 FIXME("\n");
1467 return E_NOTIMPL;
1470 static HRESULT Global_FormatCurrency(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1472 FIXME("\n");
1473 return E_NOTIMPL;
1476 static HRESULT Global_FormatPercent(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1478 FIXME("\n");
1479 return E_NOTIMPL;
1482 static HRESULT Global_FormatDateTime(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1484 FIXME("\n");
1485 return E_NOTIMPL;
1488 static HRESULT Global_WeekdayName(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
1490 int weekday, first_day = 1, abbrev = 0;
1491 BSTR ret;
1492 HRESULT hres;
1494 TRACE("\n");
1496 assert(1 <= args_cnt && args_cnt <= 3);
1498 hres = to_int(args, &weekday);
1499 if(FAILED(hres))
1500 return hres;
1502 if(args_cnt > 1) {
1503 hres = to_int(args+1, &abbrev);
1504 if(FAILED(hres))
1505 return hres;
1507 if(args_cnt == 3) {
1508 hres = to_int(args+2, &first_day);
1509 if(FAILED(hres))
1510 return hres;
1514 hres = VarWeekdayName(weekday, abbrev, first_day, 0, &ret);
1515 if(FAILED(hres))
1516 return hres;
1518 return return_bstr(res, ret);
1521 static HRESULT Global_MonthName(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
1523 int month, abbrev = 0;
1524 BSTR ret;
1525 HRESULT hres;
1527 TRACE("\n");
1529 assert(args_cnt == 1 || args_cnt == 2);
1531 hres = to_int(args, &month);
1532 if(FAILED(hres))
1533 return hres;
1535 if(args_cnt == 2) {
1536 hres = to_int(args+1, &abbrev);
1537 if(FAILED(hres))
1538 return hres;
1541 hres = VarMonthName(month, abbrev, 0, &ret);
1542 if(FAILED(hres))
1543 return hres;
1545 return return_bstr(res, ret);
1548 static HRESULT Global_Round(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1550 double n;
1551 HRESULT hres;
1553 TRACE("%s\n", debugstr_variant(arg));
1555 if(!res)
1556 return S_OK;
1558 switch(V_VT(arg)) {
1559 case VT_I2:
1560 case VT_I4:
1561 case VT_BOOL:
1562 *res = *arg;
1563 return S_OK;
1564 case VT_R8:
1565 n = V_R8(arg);
1566 break;
1567 default:
1568 hres = to_double(arg, &n);
1569 if(FAILED(hres))
1570 return hres;
1573 return return_double(res, round(n));
1576 static HRESULT Global_Escape(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1578 FIXME("\n");
1579 return E_NOTIMPL;
1582 static HRESULT Global_Unescape(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1584 FIXME("\n");
1585 return E_NOTIMPL;
1588 static HRESULT Global_Eval(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1590 FIXME("\n");
1591 return E_NOTIMPL;
1594 static HRESULT Global_Execute(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1596 FIXME("\n");
1597 return E_NOTIMPL;
1600 static HRESULT Global_ExecuteGlobal(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1602 FIXME("\n");
1603 return E_NOTIMPL;
1606 static HRESULT Global_GetRef(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1608 FIXME("\n");
1609 return E_NOTIMPL;
1612 static HRESULT Global_vbUseDefault(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1614 FIXME("\n");
1615 return E_NOTIMPL;
1618 static HRESULT Global_vbBinaryCompare(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1620 FIXME("\n");
1621 return E_NOTIMPL;
1624 static HRESULT Global_vbTextCompare(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1626 FIXME("\n");
1627 return E_NOTIMPL;
1630 static HRESULT Global_vbDatabaseCompare(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1632 FIXME("\n");
1633 return E_NOTIMPL;
1636 static HRESULT Global_vbGeneralDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1638 FIXME("\n");
1639 return E_NOTIMPL;
1642 static HRESULT Global_vbLongDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1644 FIXME("\n");
1645 return E_NOTIMPL;
1648 static HRESULT Global_vbShortDate(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1650 FIXME("\n");
1651 return E_NOTIMPL;
1654 static HRESULT Global_vbLongTime(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1656 FIXME("\n");
1657 return E_NOTIMPL;
1660 static HRESULT Global_vbShortTime(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1662 FIXME("\n");
1663 return E_NOTIMPL;
1666 static HRESULT Global_vbObjectError(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1668 FIXME("\n");
1669 return E_NOTIMPL;
1672 static HRESULT Global_vbBlack(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1674 FIXME("\n");
1675 return E_NOTIMPL;
1678 static HRESULT Global_vbBlue(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1680 FIXME("\n");
1681 return E_NOTIMPL;
1684 static HRESULT Global_vbCyan(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1686 FIXME("\n");
1687 return E_NOTIMPL;
1690 static HRESULT Global_vbGreen(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1692 FIXME("\n");
1693 return E_NOTIMPL;
1696 static HRESULT Global_vbMagenta(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1698 FIXME("\n");
1699 return E_NOTIMPL;
1702 static HRESULT Global_vbRed(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1704 FIXME("\n");
1705 return E_NOTIMPL;
1708 static HRESULT Global_vbWhite(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1710 FIXME("\n");
1711 return E_NOTIMPL;
1714 static HRESULT Global_vbYellow(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1716 FIXME("\n");
1717 return E_NOTIMPL;
1720 static HRESULT Global_vbCr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1722 FIXME("\n");
1723 return E_NOTIMPL;
1726 static HRESULT Global_vbCrLf(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1728 FIXME("\n");
1729 return E_NOTIMPL;
1732 static HRESULT Global_vbNewLine(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1734 FIXME("\n");
1735 return E_NOTIMPL;
1738 static HRESULT Global_vbFormFeed(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1740 FIXME("\n");
1741 return E_NOTIMPL;
1744 static HRESULT Global_vbLf(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1746 FIXME("\n");
1747 return E_NOTIMPL;
1750 static HRESULT Global_vbNullChar(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1752 FIXME("\n");
1753 return E_NOTIMPL;
1756 static HRESULT Global_vbNullString(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1758 FIXME("\n");
1759 return E_NOTIMPL;
1762 static HRESULT Global_vbTab(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1764 FIXME("\n");
1765 return E_NOTIMPL;
1768 static HRESULT Global_vbVerticalTab(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1770 FIXME("\n");
1771 return E_NOTIMPL;
1774 static HRESULT Global_vbMsgBoxHelpButton(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1776 FIXME("\n");
1777 return E_NOTIMPL;
1780 static HRESULT Global_vbMsgBoxSetForeground(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1782 FIXME("\n");
1783 return E_NOTIMPL;
1786 static HRESULT Global_vbMsgBoxRight(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1788 FIXME("\n");
1789 return E_NOTIMPL;
1792 static HRESULT Global_vbMsgBoxRtlReading(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
1794 FIXME("\n");
1795 return E_NOTIMPL;
1798 static const builtin_prop_t global_props[] = {
1799 {DISPID_GLOBAL_VBUSESYSTEM, NULL, BP_GET, 0},
1800 {DISPID_GLOBAL_USESYSTEMDAYOFWEEK, NULL, BP_GET, 0},
1801 {DISPID_GLOBAL_VBSUNDAY, NULL, BP_GET, 1},
1802 {DISPID_GLOBAL_VBMONDAY, NULL, BP_GET, 2},
1803 {DISPID_GLOBAL_VBTUESDAY, NULL, BP_GET, 3},
1804 {DISPID_GLOBAL_VBWEDNESDAY, NULL, BP_GET, 4},
1805 {DISPID_GLOBAL_VBTHURSDAY, NULL, BP_GET, 5},
1806 {DISPID_GLOBAL_VBFRIDAY, NULL, BP_GET, 6},
1807 {DISPID_GLOBAL_VBSATURDAY, NULL, BP_GET, 7},
1808 {DISPID_GLOBAL_VBFIRSTJAN1, NULL, BP_GET, 1},
1809 {DISPID_GLOBAL_VBFIRSTFOURDAYS, NULL, BP_GET, 2},
1810 {DISPID_GLOBAL_VBFIRSTFULLWEEK, NULL, BP_GET, 3},
1811 {DISPID_GLOBAL_VBOKONLY, NULL, BP_GET, MB_OK},
1812 {DISPID_GLOBAL_VBOKCANCEL, NULL, BP_GET, MB_OKCANCEL},
1813 {DISPID_GLOBAL_VBABORTRETRYIGNORE, NULL, BP_GET, MB_ABORTRETRYIGNORE},
1814 {DISPID_GLOBAL_VBYESNOCANCEL, NULL, BP_GET, MB_YESNOCANCEL},
1815 {DISPID_GLOBAL_VBYESNO, NULL, BP_GET, MB_YESNO},
1816 {DISPID_GLOBAL_VBRETRYCANCEL, NULL, BP_GET, MB_RETRYCANCEL},
1817 {DISPID_GLOBAL_VBCRITICAL, NULL, BP_GET, MB_ICONHAND},
1818 {DISPID_GLOBAL_VBQUESTION, NULL, BP_GET, MB_ICONQUESTION},
1819 {DISPID_GLOBAL_VBEXCLAMATION, NULL, BP_GET, MB_ICONEXCLAMATION},
1820 {DISPID_GLOBAL_VBINFORMATION, NULL, BP_GET, MB_ICONASTERISK},
1821 {DISPID_GLOBAL_VBDEFAULTBUTTON1, NULL, BP_GET, MB_DEFBUTTON1},
1822 {DISPID_GLOBAL_VBDEFAULTBUTTON2, NULL, BP_GET, MB_DEFBUTTON2},
1823 {DISPID_GLOBAL_VBDEFAULTBUTTON3, NULL, BP_GET, MB_DEFBUTTON3},
1824 {DISPID_GLOBAL_VBDEFAULTBUTTON4, NULL, BP_GET, MB_DEFBUTTON4},
1825 {DISPID_GLOBAL_VBAPPLICATIONMODAL, NULL, BP_GET, MB_APPLMODAL},
1826 {DISPID_GLOBAL_VBSYSTEMMODAL, NULL, BP_GET, MB_SYSTEMMODAL},
1827 {DISPID_GLOBAL_VBOK, NULL, BP_GET, IDOK},
1828 {DISPID_GLOBAL_VBCANCEL, NULL, BP_GET, IDCANCEL},
1829 {DISPID_GLOBAL_VBABORT, NULL, BP_GET, IDABORT},
1830 {DISPID_GLOBAL_VBRETRY, NULL, BP_GET, IDRETRY},
1831 {DISPID_GLOBAL_VBIGNORE, NULL, BP_GET, IDIGNORE},
1832 {DISPID_GLOBAL_VBYES, NULL, BP_GET, IDYES},
1833 {DISPID_GLOBAL_VBNO, NULL, BP_GET, IDNO},
1834 {DISPID_GLOBAL_VBEMPTY, NULL, BP_GET, VT_EMPTY},
1835 {DISPID_GLOBAL_VBNULL, NULL, BP_GET, VT_NULL},
1836 {DISPID_GLOBAL_VBINTEGER, NULL, BP_GET, VT_I2},
1837 {DISPID_GLOBAL_VBLONG, NULL, BP_GET, VT_I4},
1838 {DISPID_GLOBAL_VBSINGLE, NULL, BP_GET, VT_R4},
1839 {DISPID_GLOBAL_VBDOUBLE, NULL, BP_GET, VT_R8},
1840 {DISPID_GLOBAL_VBCURRENCY, NULL, BP_GET, VT_CY},
1841 {DISPID_GLOBAL_VBDATE, NULL, BP_GET, VT_DATE},
1842 {DISPID_GLOBAL_VBSTRING, NULL, BP_GET, VT_BSTR},
1843 {DISPID_GLOBAL_VBOBJECT, NULL, BP_GET, VT_DISPATCH},
1844 {DISPID_GLOBAL_VBERROR, NULL, BP_GET, VT_ERROR},
1845 {DISPID_GLOBAL_VBBOOLEAN, NULL, BP_GET, VT_BOOL},
1846 {DISPID_GLOBAL_VBVARIANT, NULL, BP_GET, VT_VARIANT},
1847 {DISPID_GLOBAL_VBDATAOBJECT, NULL, BP_GET, VT_UNKNOWN},
1848 {DISPID_GLOBAL_VBDECIMAL, NULL, BP_GET, VT_DECIMAL},
1849 {DISPID_GLOBAL_VBBYTE, NULL, BP_GET, VT_UI1},
1850 {DISPID_GLOBAL_VBARRAY, NULL, BP_GET, VT_ARRAY},
1851 {DISPID_GLOBAL_VBTRUE, NULL, BP_GET, VARIANT_TRUE},
1852 {DISPID_GLOBAL_VBFALSE, NULL, BP_GET, VARIANT_FALSE},
1853 {DISPID_GLOBAL_VBUSEDEFAULT, Global_vbUseDefault, BP_GET},
1854 {DISPID_GLOBAL_VBBINARYCOMPARE, Global_vbBinaryCompare, BP_GET},
1855 {DISPID_GLOBAL_VBTEXTCOMPARE, Global_vbTextCompare, BP_GET},
1856 {DISPID_GLOBAL_VBDATABASECOMPARE, Global_vbDatabaseCompare, BP_GET},
1857 {DISPID_GLOBAL_VBGENERALDATE, Global_vbGeneralDate, BP_GET},
1858 {DISPID_GLOBAL_VBLONGDATE, Global_vbLongDate, BP_GET},
1859 {DISPID_GLOBAL_VBSHORTDATE, Global_vbShortDate, BP_GET},
1860 {DISPID_GLOBAL_VBLONGTIME, Global_vbLongTime, BP_GET},
1861 {DISPID_GLOBAL_VBSHORTTIME, Global_vbShortTime, BP_GET},
1862 {DISPID_GLOBAL_VBOBJECTERROR, Global_vbObjectError, BP_GET},
1863 {DISPID_GLOBAL_VBBLACK, Global_vbBlack, BP_GET},
1864 {DISPID_GLOBAL_VBBLUE, Global_vbBlue, BP_GET},
1865 {DISPID_GLOBAL_VBCYAN, Global_vbCyan, BP_GET},
1866 {DISPID_GLOBAL_VBGREEN, Global_vbGreen, BP_GET},
1867 {DISPID_GLOBAL_VBMAGENTA, Global_vbMagenta, BP_GET},
1868 {DISPID_GLOBAL_VBRED, Global_vbRed, BP_GET},
1869 {DISPID_GLOBAL_VBWHITE, Global_vbWhite, BP_GET},
1870 {DISPID_GLOBAL_VBYELLOW, Global_vbYellow, BP_GET},
1871 {DISPID_GLOBAL_VBCR, Global_vbCr, BP_GET},
1872 {DISPID_GLOBAL_VBCRLF, Global_vbCrLf, BP_GET},
1873 {DISPID_GLOBAL_VBNEWLINE, Global_vbNewLine, BP_GET},
1874 {DISPID_GLOBAL_VBFORMFEED, Global_vbFormFeed, BP_GET},
1875 {DISPID_GLOBAL_VBLF, Global_vbLf, BP_GET},
1876 {DISPID_GLOBAL_VBNULLCHAR, Global_vbNullChar, BP_GET},
1877 {DISPID_GLOBAL_VBNULLSTRING, Global_vbNullString, BP_GET},
1878 {DISPID_GLOBAL_VBTAB, Global_vbTab, BP_GET},
1879 {DISPID_GLOBAL_VBVERTICALTAB, Global_vbVerticalTab, BP_GET},
1880 {DISPID_GLOBAL_CCUR, Global_CCur, 0, 1},
1881 {DISPID_GLOBAL_CINT, Global_CInt, 0, 1},
1882 {DISPID_GLOBAL_CLNG, Global_CLng, 0, 1},
1883 {DISPID_GLOBAL_CBOOL, Global_CBool, 0, 1},
1884 {DISPID_GLOBAL_CBYTE, Global_CByte, 0, 1},
1885 {DISPID_GLOBAL_CDATE, Global_CDate, 0, 1},
1886 {DISPID_GLOBAL_CDBL, Global_CDbl, 0, 1},
1887 {DISPID_GLOBAL_CSNG, Global_CSng, 0, 1},
1888 {DISPID_GLOBAL_CSTR, Global_CStr, 0, 1},
1889 {DISPID_GLOBAL_HEX, Global_Hex, 0, 1},
1890 {DISPID_GLOBAL_OCT, Global_Oct, 0, 1},
1891 {DISPID_GLOBAL_VARTYPE, Global_VarType, 0, 1},
1892 {DISPID_GLOBAL_ISDATE, Global_IsDate, 0, 1},
1893 {DISPID_GLOBAL_ISEMPTY, Global_IsEmpty, 0, 1},
1894 {DISPID_GLOBAL_ISNULL, Global_IsNull, 0, 1},
1895 {DISPID_GLOBAL_ISNUMERIC, Global_IsNumeric, 0, 1},
1896 {DISPID_GLOBAL_ISARRAY, Global_IsArray, 0, 1},
1897 {DISPID_GLOBAL_ISOBJECT, Global_IsObject, 0, 1},
1898 {DISPID_GLOBAL_ATN, Global_Ant, 0, 1},
1899 {DISPID_GLOBAL_COS, Global_Cos, 0, 1},
1900 {DISPID_GLOBAL_SIN, Global_Sin, 0, 1},
1901 {DISPID_GLOBAL_TAN, Global_Tan, 0, 1},
1902 {DISPID_GLOBAL_EXP, Global_Exp, 0, 1},
1903 {DISPID_GLOBAL_LOG, Global_Log, 0, 1},
1904 {DISPID_GLOBAL_SQR, Global_Sqr, 0, 1},
1905 {DISPID_GLOBAL_RANDOMIZE, Global_Randomize, 0, 1},
1906 {DISPID_GLOBAL_RND, Global_Rnd, 0, 1},
1907 {DISPID_GLOBAL_TIMER, Global_Timer, 0, 0},
1908 {DISPID_GLOBAL_LBOUND, Global_LBound, 0, 1},
1909 {DISPID_GLOBAL_UBOUND, Global_UBound, 0, 1},
1910 {DISPID_GLOBAL_RGB, Global_RGB, 0, 3},
1911 {DISPID_GLOBAL_LEN, Global_Len, 0, 1},
1912 {DISPID_GLOBAL_LENB, Global_LenB, 0, 1},
1913 {DISPID_GLOBAL_LEFT, Global_Left, 0, 2},
1914 {DISPID_GLOBAL_LEFTB, Global_LeftB, 0, 2},
1915 {DISPID_GLOBAL_RIGHT, Global_Right, 0, 2},
1916 {DISPID_GLOBAL_RIGHTB, Global_RightB, 0, 2},
1917 {DISPID_GLOBAL_MID, Global_Mid, 0, 2, 3},
1918 {DISPID_GLOBAL_MIDB, Global_MidB, 0, 2, 3},
1919 {DISPID_GLOBAL_STRCOMP, Global_StrComp, 0, 2, 3},
1920 {DISPID_GLOBAL_LCASE, Global_LCase, 0, 1},
1921 {DISPID_GLOBAL_UCASE, Global_UCase, 0, 1},
1922 {DISPID_GLOBAL_LTRIM, Global_LTrim, 0, 1},
1923 {DISPID_GLOBAL_RTRIM, Global_RTrim, 0, 1},
1924 {DISPID_GLOBAL_TRIM, Global_Trim, 0, 1},
1925 {DISPID_GLOBAL_SPACE, Global_Space, 0, 1},
1926 {DISPID_GLOBAL_STRING, Global_String, 0, 0, 2},
1927 {DISPID_GLOBAL_INSTR, Global_InStr, 0, 2, 4},
1928 {DISPID_GLOBAL_INSTRB, Global_InStrB, 0, 3, 4},
1929 {DISPID_GLOBAL_ASCB, Global_AscB, 0, 1},
1930 {DISPID_GLOBAL_CHRB, Global_ChrB, 0, 1},
1931 {DISPID_GLOBAL_ASC, Global_Asc, 0, 1},
1932 {DISPID_GLOBAL_CHR, Global_Chr, 0, 1},
1933 {DISPID_GLOBAL_ASCW, Global_AscW, 0, 1},
1934 {DISPID_GLOBAL_CHRW, Global_ChrW, 0, 1},
1935 {DISPID_GLOBAL_ABS, Global_Abs, 0, 1},
1936 {DISPID_GLOBAL_FIX, Global_Fix, 0, 1},
1937 {DISPID_GLOBAL_INT, Global_Int, 0, 1},
1938 {DISPID_GLOBAL_SGN, Global_Sgn, 0, 1},
1939 {DISPID_GLOBAL_NOW, Global_Now, 0, 0},
1940 {DISPID_GLOBAL_DATE, Global_Date, 0, 0},
1941 {DISPID_GLOBAL_TIME, Global_Time, 0, 0},
1942 {DISPID_GLOBAL_DAY, Global_Day, 0, 1},
1943 {DISPID_GLOBAL_MONTH, Global_Month, 0, 1},
1944 {DISPID_GLOBAL_WEEKDAY, Global_Weekday, 0, 1, 2},
1945 {DISPID_GLOBAL_YEAR, Global_Year, 0, 1},
1946 {DISPID_GLOBAL_HOUR, Global_Hour, 0, 1},
1947 {DISPID_GLOBAL_MINUTE, Global_Minute, 0, 1},
1948 {DISPID_GLOBAL_SECOND, Global_Second, 0, 1},
1949 {DISPID_GLOBAL_DATEVALUE, Global_DateValue, 0, 1},
1950 {DISPID_GLOBAL_TIMEVALUE, Global_TimeValue, 0, 1},
1951 {DISPID_GLOBAL_DATESERIAL, Global_DateSerial, 0, 3},
1952 {DISPID_GLOBAL_TIMESERIAL, Global_TimeSerial, 0, 3},
1953 {DISPID_GLOBAL_INPUTBOX, Global_InputBox, 0, 1, 7},
1954 {DISPID_GLOBAL_MSGBOX, Global_MsgBox, 0, 1, 5},
1955 {DISPID_GLOBAL_CREATEOBJECT, Global_CreateObject, 0, 1},
1956 {DISPID_GLOBAL_GETOBJECT, Global_GetObject, 0, 0, 2},
1957 {DISPID_GLOBAL_DATEADD, Global_DateAdd, 0, 3},
1958 {DISPID_GLOBAL_DATEDIFF, Global_DateDiff, 0, 3, 5},
1959 {DISPID_GLOBAL_DATEPART, Global_DatePart, 0, 2, 4},
1960 {DISPID_GLOBAL_TYPENAME, Global_TypeName, 0, 1},
1961 {DISPID_GLOBAL_ARRAY, Global_Array, 0, 1},
1962 {DISPID_GLOBAL_ERASE, Global_Erase, 0, 1},
1963 {DISPID_GLOBAL_FILTER, Global_Filter, 0, 2, 4},
1964 {DISPID_GLOBAL_JOIN, Global_Join, 0, 1, 2},
1965 {DISPID_GLOBAL_SPLIT, Global_Split, 0, 1, 4},
1966 {DISPID_GLOBAL_REPLACE, Global_Replace, 0, 3, 6},
1967 {DISPID_GLOBAL_STRREVERSE, Global_StrReverse, 0, 1},
1968 {DISPID_GLOBAL_INSTRREV, Global_InStrRev, 0, 2, 4},
1969 {DISPID_GLOBAL_LOADPICTURE, Global_LoadPicture, 0, 1},
1970 {DISPID_GLOBAL_SCRIPTENGINE, Global_ScriptEngine, 0, 0},
1971 {DISPID_GLOBAL_SCRIPTENGINEMAJORVERSION, Global_ScriptEngineMajorVersion, 0, 0},
1972 {DISPID_GLOBAL_SCRIPTENGINEMINORVERSION, Global_ScriptEngineMinorVersion, 0, 0},
1973 {DISPID_GLOBAL_SCRIPTENGINEBUILDVERSION, Global_ScriptEngineBuildVersion, 0, 0},
1974 {DISPID_GLOBAL_FORMATNUMBER, Global_FormatNumber, 0, 1, 5},
1975 {DISPID_GLOBAL_FORMATCURRENCY, Global_FormatCurrency, 0, 1, 5},
1976 {DISPID_GLOBAL_FORMATPERCENT, Global_FormatPercent, 0, 1, 5},
1977 {DISPID_GLOBAL_FORMATDATETIME, Global_FormatDateTime, 0, 1, 2},
1978 {DISPID_GLOBAL_WEEKDAYNAME, Global_WeekdayName, 0, 1, 3},
1979 {DISPID_GLOBAL_MONTHNAME, Global_MonthName, 0, 1, 2},
1980 {DISPID_GLOBAL_ROUND, Global_Round, 0, 1, 2},
1981 {DISPID_GLOBAL_ESCAPE, Global_Escape, 0, 1},
1982 {DISPID_GLOBAL_UNESCAPE, Global_Unescape, 0, 1},
1983 {DISPID_GLOBAL_EVAL, Global_Eval, 0, 1},
1984 {DISPID_GLOBAL_EXECUTE, Global_Execute, 0, 1},
1985 {DISPID_GLOBAL_EXECUTEGLOBAL, Global_ExecuteGlobal, 0, 1},
1986 {DISPID_GLOBAL_GETREF, Global_GetRef, 0, 1},
1987 {DISPID_GLOBAL_VBMSGBOXHELPBUTTON, Global_vbMsgBoxHelpButton, BP_GET},
1988 {DISPID_GLOBAL_VBMSGBOXSETFOREGROUND, Global_vbMsgBoxSetForeground, BP_GET},
1989 {DISPID_GLOBAL_VBMSGBOXRIGHT, Global_vbMsgBoxRight, BP_GET},
1990 {DISPID_GLOBAL_VBMSGBOXRTLREADING, Global_vbMsgBoxRtlReading, BP_GET}
1993 HRESULT init_global(script_ctx_t *ctx)
1995 HRESULT hres;
1997 ctx->global_desc.ctx = ctx;
1998 ctx->global_desc.builtin_prop_cnt = sizeof(global_props)/sizeof(*global_props);
1999 ctx->global_desc.builtin_props = global_props;
2001 hres = get_typeinfo(GlobalObj_tid, &ctx->global_desc.typeinfo);
2002 if(FAILED(hres))
2003 return hres;
2005 hres = create_vbdisp(&ctx->global_desc, &ctx->global_obj);
2006 if(FAILED(hres))
2007 return hres;
2009 hres = create_script_disp(ctx, &ctx->script_obj);
2010 if(FAILED(hres))
2011 return hres;
2013 return init_err(ctx);