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
23 #include "vbscript_defs.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
;
54 hres
= IActiveScriptSite_QueryInterface(ctx
->site
, &IID_IServiceProvider
, (void**)&sp
);
58 hres
= IServiceProvider_QueryService(sp
, &SID_SInternetHostSecurityManager
, &IID_IInternetHostSecurityManager
,
60 IServiceProvider_Release(sp
);
64 return ctx
->secmgr
= secmgr
;
67 static HRESULT
return_string(VARIANT
*res
, const WCHAR
*str
)
74 ret
= SysAllocString(str
);
83 static HRESULT
return_bstr(VARIANT
*res
, BSTR str
)
94 static HRESULT
return_short(VARIANT
*res
, short val
)
104 static HRESULT
return_int(VARIANT
*res
, int val
)
106 if((short)val
== val
)
107 return return_short(res
, val
);
117 static HRESULT
return_bool(VARIANT
*res
, int val
)
121 V_BOOL(res
) = val
!= 0 ? VARIANT_TRUE
: VARIANT_FALSE
;
127 static inline HRESULT
return_double(VARIANT
*res
, double val
)
137 static inline HRESULT
return_null(VARIANT
*res
)
144 static inline HRESULT
return_date(VARIANT
*res
, double date
)
153 static HRESULT
to_int(VARIANT
*v
, int *ret
)
163 double n
= floor(V_R8(v
)+0.5);
167 FIXME("%lf is out of int range\n", n
);
171 /* Round half to even */
173 if(i
%2 && n
-V_R8(v
) == 0.5)
180 *ret
= V_BOOL(v
) ? -1 : 0;
183 FIXME("not supported %s\n", debugstr_variant(v
));
190 static HRESULT
to_double(VARIANT
*v
, double *ret
)
209 V_VT(&dst
) = VT_EMPTY
;
210 hres
= VariantChangeType(&dst
, v
, VARIANT_LOCALBOOL
, VT_R8
);
217 FIXME("arg %s not supported\n", debugstr_variant(v
));
224 static HRESULT
to_string(VARIANT
*v
, BSTR
*ret
)
229 V_VT(&dst
) = VT_EMPTY
;
230 hres
= VariantChangeType(&dst
, v
, VARIANT_LOCALBOOL
, VT_BSTR
);
238 static HRESULT
set_object_site(script_ctx_t
*ctx
, IUnknown
*obj
)
240 IObjectWithSite
*obj_site
;
244 hres
= IUnknown_QueryInterface(obj
, &IID_IObjectWithSite
, (void**)&obj_site
);
248 ax_site
= create_ax_site(ctx
);
250 hres
= IObjectWithSite_SetSite(obj_site
, ax_site
);
252 hres
= E_OUTOFMEMORY
;
253 IUnknown_Release(ax_site
);
254 IObjectWithSite_Release(obj_site
);
258 static IUnknown
*create_object(script_ctx_t
*ctx
, const WCHAR
*progid
)
260 IInternetHostSecurityManager
*secmgr
= NULL
;
261 struct CONFIRMSAFETY cs
;
262 IClassFactoryEx
*cfex
;
271 hres
= CLSIDFromProgID(progid
, &guid
);
275 TRACE("GUID %s\n", debugstr_guid(&guid
));
277 if(ctx
->safeopt
& INTERFACE_USES_SECURITY_MANAGER
) {
278 secmgr
= get_sec_mgr(ctx
);
283 hres
= IInternetHostSecurityManager_ProcessUrlAction(secmgr
, URLACTION_ACTIVEX_RUN
,
284 (BYTE
*)&policy
, sizeof(policy
), (BYTE
*)&guid
, sizeof(GUID
), 0, 0);
285 if(FAILED(hres
) || policy
!= URLPOLICY_ALLOW
)
289 hres
= CoGetClassObject(&guid
, CLSCTX_INPROC_SERVER
|CLSCTX_LOCAL_SERVER
, NULL
, &IID_IClassFactory
, (void**)&cf
);
293 hres
= IClassFactory_QueryInterface(cf
, &IID_IClassFactoryEx
, (void**)&cfex
);
294 if(SUCCEEDED(hres
)) {
295 FIXME("Use IClassFactoryEx\n");
296 IClassFactoryEx_Release(cfex
);
299 hres
= IClassFactory_CreateInstance(cf
, NULL
, &IID_IUnknown
, (void**)&obj
);
307 hres
= IInternetHostSecurityManager_QueryCustomPolicy(secmgr
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
308 &bpolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
309 if(SUCCEEDED(hres
)) {
310 policy
= policy_size
>= sizeof(DWORD
) ? *(DWORD
*)bpolicy
: URLPOLICY_DISALLOW
;
311 CoTaskMemFree(bpolicy
);
314 if(FAILED(hres
) || policy
!= URLPOLICY_ALLOW
) {
315 IUnknown_Release(obj
);
320 hres
= set_object_site(ctx
, obj
);
322 IUnknown_Release(obj
);
329 static HRESULT
show_msgbox(script_ctx_t
*ctx
, BSTR prompt
, VARIANT
*res
)
331 SCRIPTUICHANDLING uic_handling
= SCRIPTUICHANDLING_ALLOW
;
332 IActiveScriptSiteUIControl
*ui_control
;
333 IActiveScriptSiteWindow
*acts_window
;
339 hres
= IActiveScriptSite_QueryInterface(ctx
->site
, &IID_IActiveScriptSiteUIControl
, (void**)&ui_control
);
340 if(SUCCEEDED(hres
)) {
341 hres
= IActiveScriptSiteUIControl_GetUIBehavior(ui_control
, SCRIPTUICITEM_MSGBOX
, &uic_handling
);
342 IActiveScriptSiteUIControl_Release(ui_control
);
344 uic_handling
= SCRIPTUICHANDLING_ALLOW
;
347 switch(uic_handling
) {
348 case SCRIPTUICHANDLING_ALLOW
:
350 case SCRIPTUICHANDLING_NOUIDEFAULT
:
351 return return_short(res
, 0);
357 title
= (ctx
->safeopt
& INTERFACE_USES_SECURITY_MANAGER
) ? vbscriptW
: emptyW
;
359 hres
= IActiveScriptSite_QueryInterface(ctx
->site
, &IID_IActiveScriptSiteWindow
, (void**)&acts_window
);
361 FIXME("No IActiveScriptSiteWindow\n");
365 hres
= IActiveScriptSiteWindow_GetWindow(acts_window
, &hwnd
);
366 if(SUCCEEDED(hres
)) {
367 hres
= IActiveScriptSiteWindow_EnableModeless(acts_window
, FALSE
);
368 if(SUCCEEDED(hres
)) {
369 ret
= MessageBoxW(hwnd
, prompt
, title
, MB_OK
);
370 hres
= IActiveScriptSiteWindow_EnableModeless(acts_window
, TRUE
);
374 IActiveScriptSiteWindow_Release(acts_window
);
376 FIXME("failed: %08x\n", hres
);
380 return return_short(res
, ret
);
383 static HRESULT
Global_CCur(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
389 static HRESULT
Global_CInt(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
394 TRACE("%s\n", debugstr_variant(arg
));
396 assert(args_cnt
== 1);
398 hres
= to_int(arg
, &val
);
402 return return_int(res
, val
);
405 static HRESULT
Global_CLng(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
411 static HRESULT
Global_CBool(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
414 TRACE("%s\n", debugstr_variant(arg
));
416 assert(args_cnt
== 1);
426 val
= V_R4(arg
) > 0.0 || V_R4(arg
) < 0.0;
429 val
= V_R8(arg
) > 0.0 || V_R8(arg
) < 0.0;
432 ERR("Not a numeric value: %s\n", debugstr_variant(arg
));
436 return return_bool(res
, val
);
439 static HRESULT
Global_CByte(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
445 static HRESULT
Global_CDate(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
451 static HRESULT
Global_CDbl(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
457 static HRESULT
Global_CSng(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
463 static HRESULT
Global_CStr(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
468 TRACE("%s\n", debugstr_variant(arg
));
470 hres
= to_string(arg
, &str
);
474 return return_bstr(res
, str
);
477 static inline WCHAR
hex_char(unsigned n
)
479 return n
< 10 ? '0'+n
: 'A'+n
-10;
482 static HRESULT
Global_Hex(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
487 TRACE("%s\n", debugstr_variant(arg
));
504 FIXME("unsupported type %s\n", debugstr_variant(arg
));
513 *ptr
-- = hex_char(n
& 0xf);
521 return return_string(res
, ptr
);
524 static HRESULT
Global_Oct(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
530 static HRESULT
Global_VarType(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
536 static HRESULT
Global_IsDate(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
542 static HRESULT
Global_IsEmpty(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
544 TRACE("(%s)\n", debugstr_variant(arg
));
546 assert(args_cnt
== 1);
550 V_BOOL(res
) = V_VT(arg
) == VT_EMPTY
? VARIANT_TRUE
: VARIANT_FALSE
;
555 static HRESULT
Global_IsNull(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
557 TRACE("(%s)\n", debugstr_variant(arg
));
559 assert(args_cnt
== 1);
563 V_BOOL(res
) = V_VT(arg
) == VT_NULL
? VARIANT_TRUE
: VARIANT_FALSE
;
568 static HRESULT
Global_IsNumeric(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
574 static HRESULT
Global_IsArray(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
580 static HRESULT
Global_IsObject(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
582 TRACE("(%s)\n", debugstr_variant(arg
));
584 assert(args_cnt
== 1);
588 V_BOOL(res
) = V_VT(arg
) == VT_DISPATCH
? VARIANT_TRUE
: VARIANT_FALSE
;
593 static HRESULT
Global_Ant(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
599 static HRESULT
Global_Cos(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
605 static HRESULT
Global_Sin(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
611 static HRESULT
Global_Tan(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
617 static HRESULT
Global_Exp(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
623 static HRESULT
Global_Log(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
629 static HRESULT
Global_Sqr(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
635 static HRESULT
Global_Randomize(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
641 static HRESULT
Global_Rnd(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
647 static HRESULT
Global_Timer(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
653 static HRESULT
Global_LBound(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
659 static HRESULT
Global_UBound(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
665 static HRESULT
Global_RGB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
671 static HRESULT
Global_Len(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
676 TRACE("%s\n", debugstr_variant(arg
));
678 if(V_VT(arg
) == VT_NULL
)
679 return return_null(res
);
681 if(V_VT(arg
) != VT_BSTR
) {
684 hres
= to_string(arg
, &str
);
688 len
= SysStringLen(str
);
691 len
= SysStringLen(V_BSTR(arg
));
694 return return_int(res
, len
);
697 static HRESULT
Global_LenB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
703 static HRESULT
Global_Left(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
705 BSTR str
, ret
, conv_str
= NULL
;
709 TRACE("(%s %s)\n", debugstr_variant(args
+1), debugstr_variant(args
));
711 if(V_VT(args
) == VT_BSTR
) {
714 hres
= to_string(args
, &conv_str
);
720 hres
= to_int(args
+1, &len
);
725 FIXME("len = %d\n", len
);
729 str_len
= SysStringLen(str
);
733 ret
= SysAllocStringLen(str
, len
);
734 SysFreeString(conv_str
);
736 return E_OUTOFMEMORY
;
738 return return_bstr(res
, ret
);
741 static HRESULT
Global_LeftB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
747 static HRESULT
Global_Right(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
749 BSTR str
, ret
, conv_str
= NULL
;
753 TRACE("(%s %s)\n", debugstr_variant(args
), debugstr_variant(args
+1));
755 if(V_VT(args
+1) == VT_BSTR
) {
758 hres
= to_string(args
, &conv_str
);
764 hres
= to_int(args
+1, &len
);
769 FIXME("len = %d\n", len
);
773 str_len
= SysStringLen(str
);
777 ret
= SysAllocStringLen(str
+str_len
-len
, len
);
778 SysFreeString(conv_str
);
780 return E_OUTOFMEMORY
;
782 return return_bstr(res
, ret
);
785 static HRESULT
Global_RightB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
791 static HRESULT
Global_Mid(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
793 int len
= -1, start
, str_len
;
797 TRACE("(%s %s ...)\n", debugstr_variant(args
), debugstr_variant(args
+1));
799 assert(args_cnt
== 2 || args_cnt
== 3);
801 if(V_VT(args
) != VT_BSTR
) {
802 FIXME("args[0] = %s\n", debugstr_variant(args
));
808 hres
= to_int(args
+1, &start
);
813 hres
= to_int(args
+2, &len
);
818 FIXME("len = %d\n", len
);
824 str_len
= SysStringLen(str
);
831 else if(len
> str_len
-start
)
836 V_BSTR(res
) = SysAllocStringLen(str
+start
, len
);
838 return E_OUTOFMEMORY
;
844 static HRESULT
Global_MidB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
850 static HRESULT
Global_StrComp(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
856 static HRESULT
Global_LCase(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
861 TRACE("%s\n", debugstr_variant(arg
));
863 if(V_VT(arg
) == VT_NULL
) {
869 hres
= to_string(arg
, &str
);
876 for(ptr
= str
; *ptr
; ptr
++)
877 *ptr
= tolowerW(*ptr
);
887 static HRESULT
Global_UCase(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
892 TRACE("%s\n", debugstr_variant(arg
));
894 if(V_VT(arg
) == VT_NULL
) {
900 hres
= to_string(arg
, &str
);
907 for(ptr
= str
; *ptr
; ptr
++)
908 *ptr
= toupperW(*ptr
);
918 static HRESULT
Global_LTrim(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
920 BSTR str
, conv_str
= NULL
;
924 TRACE("%s\n", debugstr_variant(arg
));
926 if(V_VT(arg
) == VT_BSTR
) {
929 hres
= to_string(arg
, &conv_str
);
935 for(ptr
= str
; *ptr
&& isspaceW(*ptr
); ptr
++);
937 str
= SysAllocString(ptr
);
938 SysFreeString(conv_str
);
940 return E_OUTOFMEMORY
;
942 return return_bstr(res
, str
);
945 static HRESULT
Global_RTrim(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
947 BSTR str
, conv_str
= NULL
;
951 TRACE("%s\n", debugstr_variant(arg
));
953 if(V_VT(arg
) == VT_BSTR
) {
956 hres
= to_string(arg
, &conv_str
);
962 for(ptr
= str
+SysStringLen(str
); ptr
-1 > str
&& isspaceW(*(ptr
-1)); ptr
--);
964 str
= SysAllocStringLen(str
, ptr
-str
);
965 SysFreeString(conv_str
);
967 return E_OUTOFMEMORY
;
969 return return_bstr(res
, str
);
972 static HRESULT
Global_Trim(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
974 BSTR str
, conv_str
= NULL
;
975 WCHAR
*begin_ptr
, *end_ptr
;
978 TRACE("%s\n", debugstr_variant(arg
));
980 if(V_VT(arg
) == VT_BSTR
) {
983 hres
= to_string(arg
, &conv_str
);
989 for(begin_ptr
= str
; *begin_ptr
&& isspaceW(*begin_ptr
); begin_ptr
++);
990 for(end_ptr
= str
+SysStringLen(str
); end_ptr
-1 > begin_ptr
&& isspaceW(*(end_ptr
-1)); end_ptr
--);
992 str
= SysAllocStringLen(begin_ptr
, end_ptr
-begin_ptr
);
993 SysFreeString(conv_str
);
995 return E_OUTOFMEMORY
;
997 return return_bstr(res
, str
);
1000 static HRESULT
Global_Space(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1006 TRACE("%s\n", debugstr_variant(arg
));
1008 hres
= to_int(arg
, &n
);
1013 FIXME("n = %d\n", n
);
1020 str
= SysAllocStringLen(NULL
, n
);
1022 return E_OUTOFMEMORY
;
1027 V_VT(res
) = VT_BSTR
;
1032 static HRESULT
Global_String(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1038 static HRESULT
Global_InStr(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1040 VARIANT
*startv
, *str1v
, *str2v
;
1047 assert(2 <= args_cnt
&& args_cnt
<= 4);
1061 FIXME("unsupported compare argument %s\n", debugstr_variant(args
));
1063 DEFAULT_UNREACHABLE
;
1067 hres
= to_int(startv
, &start
);
1071 FIXME("start %d\n", start
);
1078 if(V_VT(str1v
) == VT_NULL
|| V_VT(str2v
) == VT_NULL
)
1079 return return_null(res
);
1081 if(V_VT(str1v
) != VT_BSTR
) {
1082 FIXME("Unsupported str1 type %s\n", debugstr_variant(str1v
));
1085 str1
= V_BSTR(str1v
);
1087 if(V_VT(str2v
) != VT_BSTR
) {
1088 FIXME("Unsupported str2 type %s\n", debugstr_variant(str2v
));
1091 str2
= V_BSTR(str2v
);
1093 if(start
< SysStringLen(str1
)) {
1096 ptr
= strstrW(str1
+start
, str2
);
1097 ret
= ptr
? ptr
-str1
+1 : 0;
1102 return return_int(res
, ret
);
1105 static HRESULT
Global_InStrB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1111 static HRESULT
Global_AscB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1117 static HRESULT
Global_ChrB(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1123 static HRESULT
Global_Asc(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1129 static HRESULT
Global_Chr(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1134 TRACE("%s\n", debugstr_variant(arg
));
1136 hres
= to_int(arg
, &c
);
1140 if(c
< 0 || c
>= 0x100) {
1141 FIXME("invalid arg\n");
1148 V_VT(res
) = VT_BSTR
;
1149 V_BSTR(res
) = SysAllocStringLen(&ch
, 1);
1151 return E_OUTOFMEMORY
;
1156 static HRESULT
Global_AscW(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1162 static HRESULT
Global_ChrW(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1168 static HRESULT
Global_Abs(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1174 static HRESULT
Global_Fix(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1180 static HRESULT
Global_Int(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1186 static HRESULT
Global_Sgn(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1192 static HRESULT
Global_Now(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1200 SystemTimeToVariantTime(<
, &date
);
1201 return return_date(res
, date
);
1204 static HRESULT
Global_Date(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1210 static HRESULT
Global_Time(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1216 static HRESULT
Global_Day(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1222 static HRESULT
Global_Month(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1228 static HRESULT
Global_Weekday(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1234 static HRESULT
Global_Year(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1240 static HRESULT
Global_Hour(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1246 static HRESULT
Global_Minute(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1252 static HRESULT
Global_Second(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1258 static HRESULT
Global_DateValue(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1264 static HRESULT
Global_TimeValue(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1270 static HRESULT
Global_DateSerial(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1276 static HRESULT
Global_TimeSerial(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1282 static HRESULT
Global_InputBox(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1288 static HRESULT
Global_MsgBox(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1296 FIXME("unsupported arg_cnt %d\n", args_cnt
);
1300 hres
= to_string(args
, &prompt
);
1304 hres
= show_msgbox(This
->desc
->ctx
, prompt
, res
);
1305 SysFreeString(prompt
);
1309 static HRESULT
Global_CreateObject(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1314 TRACE("(%s)\n", debugstr_variant(arg
));
1316 if(V_VT(arg
) != VT_BSTR
) {
1317 FIXME("non-bstr arg\n");
1318 return E_INVALIDARG
;
1321 obj
= create_object(This
->desc
->ctx
, V_BSTR(arg
));
1323 return VB_E_CANNOT_CREATE_OBJ
;
1326 hres
= IUnknown_QueryInterface(obj
, &IID_IDispatch
, (void**)&V_DISPATCH(res
));
1330 V_VT(res
) = VT_DISPATCH
;
1333 IUnknown_Release(obj
);
1337 static HRESULT
Global_GetObject(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1346 TRACE("%s %s\n", args_cnt
? debugstr_variant(args
) : "", args_cnt
> 1 ? debugstr_variant(args
+1) : "");
1348 if(args_cnt
!= 1 || V_VT(args
) != VT_BSTR
) {
1349 FIXME("unsupported args\n");
1353 if(This
->desc
->ctx
->safeopt
& (INTERFACE_USES_SECURITY_MANAGER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
)) {
1354 WARN("blocked in current safety mode\n");
1355 return VB_E_CANNOT_CREATE_OBJ
;
1358 hres
= CreateBindCtx(0, &bind_ctx
);
1362 hres
= MkParseDisplayName(bind_ctx
, V_BSTR(args
), &eaten
, &mon
);
1363 if(SUCCEEDED(hres
)) {
1364 hres
= IMoniker_BindToObject(mon
, bind_ctx
, NULL
, &IID_IUnknown
, (void**)&obj_unk
);
1365 IMoniker_Release(mon
);
1369 IBindCtx_Release(bind_ctx
);
1373 hres
= set_object_site(This
->desc
->ctx
, obj_unk
);
1375 IUnknown_Release(obj_unk
);
1379 hres
= IUnknown_QueryInterface(obj_unk
, &IID_IDispatch
, (void**)&disp
);
1380 if(SUCCEEDED(hres
)) {
1382 V_VT(res
) = VT_DISPATCH
;
1383 V_DISPATCH(res
) = disp
;
1385 IDispatch_Release(disp
);
1388 FIXME("object does not support IDispatch\n");
1394 static HRESULT
Global_DateAdd(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1400 static HRESULT
Global_DateDiff(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1406 static HRESULT
Global_DatePart(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1412 static HRESULT
Global_TypeName(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1418 static HRESULT
Global_Array(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1424 static HRESULT
Global_Erase(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1430 static HRESULT
Global_Filter(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1436 static HRESULT
Global_Join(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1442 static HRESULT
Global_Split(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1448 static HRESULT
Global_Replace(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1454 static HRESULT
Global_StrReverse(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1456 WCHAR
*ptr1
, *ptr2
, ch
;
1460 TRACE("%s\n", debugstr_variant(arg
));
1462 hres
= to_string(arg
, &ret
);
1467 ptr2
= ret
+ SysStringLen(ret
)-1;
1468 while(ptr1
< ptr2
) {
1474 return return_bstr(res
, ret
);
1477 static HRESULT
Global_InStrRev(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1483 static HRESULT
Global_LoadPicture(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1489 static HRESULT
Global_ScriptEngine(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1495 static HRESULT
Global_ScriptEngineMajorVersion(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1501 static HRESULT
Global_ScriptEngineMinorVersion(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1507 static HRESULT
Global_ScriptEngineBuildVersion(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1513 static HRESULT
Global_FormatNumber(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1519 static HRESULT
Global_FormatCurrency(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1525 static HRESULT
Global_FormatPercent(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1531 static HRESULT
Global_FormatDateTime(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1537 static HRESULT
Global_WeekdayName(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1539 int weekday
, first_day
= 1, abbrev
= 0;
1545 assert(1 <= args_cnt
&& args_cnt
<= 3);
1547 hres
= to_int(args
, &weekday
);
1552 hres
= to_int(args
+1, &abbrev
);
1557 hres
= to_int(args
+2, &first_day
);
1563 hres
= VarWeekdayName(weekday
, abbrev
, first_day
, 0, &ret
);
1567 return return_bstr(res
, ret
);
1570 static HRESULT
Global_MonthName(vbdisp_t
*This
, VARIANT
*args
, unsigned args_cnt
, VARIANT
*res
)
1572 int month
, abbrev
= 0;
1578 assert(args_cnt
== 1 || args_cnt
== 2);
1580 hres
= to_int(args
, &month
);
1585 hres
= to_int(args
+1, &abbrev
);
1590 hres
= VarMonthName(month
, abbrev
, 0, &ret
);
1594 return return_bstr(res
, ret
);
1597 static HRESULT
Global_Round(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1602 TRACE("%s\n", debugstr_variant(arg
));
1617 hres
= to_double(arg
, &n
);
1622 return return_double(res
, round(n
));
1625 static HRESULT
Global_Escape(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1631 static HRESULT
Global_Unescape(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1637 static HRESULT
Global_Eval(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1643 static HRESULT
Global_Execute(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1649 static HRESULT
Global_ExecuteGlobal(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1655 static HRESULT
Global_GetRef(vbdisp_t
*This
, VARIANT
*arg
, unsigned args_cnt
, VARIANT
*res
)
1661 static const string_constant_t vbCr
= {1, {'\r'}};
1662 static const string_constant_t vbCrLf
= {2, {'\r','\n'}};
1663 static const string_constant_t vbNewLine
= {2, {'\r','\n'}};
1664 static const string_constant_t vbFormFeed
= {1, {0xc}};
1665 static const string_constant_t vbLf
= {1, {'\n'}};
1666 static const string_constant_t vbNullChar
= {1};
1667 static const string_constant_t vbNullString
= {0};
1668 static const string_constant_t vbTab
= {1, {'\t'}};
1669 static const string_constant_t vbVerticalTab
= {1, {0xb}};
1671 static const builtin_prop_t global_props
[] = {
1672 {DISPID_GLOBAL_VBUSESYSTEM
, NULL
, BP_GET
, VT_I2
, 0},
1673 {DISPID_GLOBAL_USESYSTEMDAYOFWEEK
, NULL
, BP_GET
, VT_I2
, 0},
1674 {DISPID_GLOBAL_VBSUNDAY
, NULL
, BP_GET
, VT_I2
, 1},
1675 {DISPID_GLOBAL_VBMONDAY
, NULL
, BP_GET
, VT_I2
, 2},
1676 {DISPID_GLOBAL_VBTUESDAY
, NULL
, BP_GET
, VT_I2
, 3},
1677 {DISPID_GLOBAL_VBWEDNESDAY
, NULL
, BP_GET
, VT_I2
, 4},
1678 {DISPID_GLOBAL_VBTHURSDAY
, NULL
, BP_GET
, VT_I2
, 5},
1679 {DISPID_GLOBAL_VBFRIDAY
, NULL
, BP_GET
, VT_I2
, 6},
1680 {DISPID_GLOBAL_VBSATURDAY
, NULL
, BP_GET
, VT_I2
, 7},
1681 {DISPID_GLOBAL_VBFIRSTJAN1
, NULL
, BP_GET
, VT_I2
, 1},
1682 {DISPID_GLOBAL_VBFIRSTFOURDAYS
, NULL
, BP_GET
, VT_I2
, 2},
1683 {DISPID_GLOBAL_VBFIRSTFULLWEEK
, NULL
, BP_GET
, VT_I2
, 3},
1684 {DISPID_GLOBAL_VBOKONLY
, NULL
, BP_GET
, VT_I2
, MB_OK
},
1685 {DISPID_GLOBAL_VBOKCANCEL
, NULL
, BP_GET
, VT_I2
, MB_OKCANCEL
},
1686 {DISPID_GLOBAL_VBABORTRETRYIGNORE
, NULL
, BP_GET
, VT_I2
, MB_ABORTRETRYIGNORE
},
1687 {DISPID_GLOBAL_VBYESNOCANCEL
, NULL
, BP_GET
, VT_I2
, MB_YESNOCANCEL
},
1688 {DISPID_GLOBAL_VBYESNO
, NULL
, BP_GET
, VT_I2
, MB_YESNO
},
1689 {DISPID_GLOBAL_VBRETRYCANCEL
, NULL
, BP_GET
, VT_I2
, MB_RETRYCANCEL
},
1690 {DISPID_GLOBAL_VBCRITICAL
, NULL
, BP_GET
, VT_I2
, MB_ICONHAND
},
1691 {DISPID_GLOBAL_VBQUESTION
, NULL
, BP_GET
, VT_I2
, MB_ICONQUESTION
},
1692 {DISPID_GLOBAL_VBEXCLAMATION
, NULL
, BP_GET
, VT_I2
, MB_ICONEXCLAMATION
},
1693 {DISPID_GLOBAL_VBINFORMATION
, NULL
, BP_GET
, VT_I2
, MB_ICONASTERISK
},
1694 {DISPID_GLOBAL_VBDEFAULTBUTTON1
, NULL
, BP_GET
, VT_I2
, MB_DEFBUTTON1
},
1695 {DISPID_GLOBAL_VBDEFAULTBUTTON2
, NULL
, BP_GET
, VT_I2
, MB_DEFBUTTON2
},
1696 {DISPID_GLOBAL_VBDEFAULTBUTTON3
, NULL
, BP_GET
, VT_I2
, MB_DEFBUTTON3
},
1697 {DISPID_GLOBAL_VBDEFAULTBUTTON4
, NULL
, BP_GET
, VT_I2
, MB_DEFBUTTON4
},
1698 {DISPID_GLOBAL_VBAPPLICATIONMODAL
, NULL
, BP_GET
, VT_I2
, MB_APPLMODAL
},
1699 {DISPID_GLOBAL_VBSYSTEMMODAL
, NULL
, BP_GET
, VT_I2
, MB_SYSTEMMODAL
},
1700 {DISPID_GLOBAL_VBOK
, NULL
, BP_GET
, VT_I2
, IDOK
},
1701 {DISPID_GLOBAL_VBCANCEL
, NULL
, BP_GET
, VT_I2
, IDCANCEL
},
1702 {DISPID_GLOBAL_VBABORT
, NULL
, BP_GET
, VT_I2
, IDABORT
},
1703 {DISPID_GLOBAL_VBRETRY
, NULL
, BP_GET
, VT_I2
, IDRETRY
},
1704 {DISPID_GLOBAL_VBIGNORE
, NULL
, BP_GET
, VT_I2
, IDIGNORE
},
1705 {DISPID_GLOBAL_VBYES
, NULL
, BP_GET
, VT_I2
, IDYES
},
1706 {DISPID_GLOBAL_VBNO
, NULL
, BP_GET
, VT_I2
, IDNO
},
1707 {DISPID_GLOBAL_VBEMPTY
, NULL
, BP_GET
, VT_I2
, VT_EMPTY
},
1708 {DISPID_GLOBAL_VBNULL
, NULL
, BP_GET
, VT_I2
, VT_NULL
},
1709 {DISPID_GLOBAL_VBINTEGER
, NULL
, BP_GET
, VT_I2
, VT_I2
},
1710 {DISPID_GLOBAL_VBLONG
, NULL
, BP_GET
, VT_I2
, VT_I4
},
1711 {DISPID_GLOBAL_VBSINGLE
, NULL
, BP_GET
, VT_I2
, VT_R4
},
1712 {DISPID_GLOBAL_VBDOUBLE
, NULL
, BP_GET
, VT_I2
, VT_R8
},
1713 {DISPID_GLOBAL_VBCURRENCY
, NULL
, BP_GET
, VT_I2
, VT_CY
},
1714 {DISPID_GLOBAL_VBDATE
, NULL
, BP_GET
, VT_I2
, VT_DATE
},
1715 {DISPID_GLOBAL_VBSTRING
, NULL
, BP_GET
, VT_I2
, VT_BSTR
},
1716 {DISPID_GLOBAL_VBOBJECT
, NULL
, BP_GET
, VT_I2
, VT_DISPATCH
},
1717 {DISPID_GLOBAL_VBERROR
, NULL
, BP_GET
, VT_I2
, VT_ERROR
},
1718 {DISPID_GLOBAL_VBBOOLEAN
, NULL
, BP_GET
, VT_I2
, VT_BOOL
},
1719 {DISPID_GLOBAL_VBVARIANT
, NULL
, BP_GET
, VT_I2
, VT_VARIANT
},
1720 {DISPID_GLOBAL_VBDATAOBJECT
, NULL
, BP_GET
, VT_I2
, VT_UNKNOWN
},
1721 {DISPID_GLOBAL_VBDECIMAL
, NULL
, BP_GET
, VT_I2
, VT_DECIMAL
},
1722 {DISPID_GLOBAL_VBBYTE
, NULL
, BP_GET
, VT_I2
, VT_UI1
},
1723 {DISPID_GLOBAL_VBARRAY
, NULL
, BP_GET
, VT_I2
, VT_ARRAY
},
1724 {DISPID_GLOBAL_VBTRUE
, NULL
, BP_GET
, VT_I2
, VARIANT_TRUE
},
1725 {DISPID_GLOBAL_VBFALSE
, NULL
, BP_GET
, VT_I2
, VARIANT_FALSE
},
1726 {DISPID_GLOBAL_VBUSEDEFAULT
, NULL
, BP_GET
, VT_I2
, -2},
1727 {DISPID_GLOBAL_VBBINARYCOMPARE
, NULL
, BP_GET
, VT_I2
, 0},
1728 {DISPID_GLOBAL_VBTEXTCOMPARE
, NULL
, BP_GET
, VT_I2
, 1},
1729 {DISPID_GLOBAL_VBDATABASECOMPARE
, NULL
, BP_GET
, VT_I2
, 2},
1730 {DISPID_GLOBAL_VBGENERALDATE
, NULL
, BP_GET
, VT_I2
, 0},
1731 {DISPID_GLOBAL_VBLONGDATE
, NULL
, BP_GET
, VT_I2
, 1},
1732 {DISPID_GLOBAL_VBSHORTDATE
, NULL
, BP_GET
, VT_I2
, 2},
1733 {DISPID_GLOBAL_VBLONGTIME
, NULL
, BP_GET
, VT_I2
, 3},
1734 {DISPID_GLOBAL_VBSHORTTIME
, NULL
, BP_GET
, VT_I2
, 4},
1735 {DISPID_GLOBAL_VBOBJECTERROR
, NULL
, BP_GET
, VT_I4
, 0x80040000},
1736 {DISPID_GLOBAL_VBBLACK
, NULL
, BP_GET
, VT_I4
, 0x000000},
1737 {DISPID_GLOBAL_VBBLUE
, NULL
, BP_GET
, VT_I4
, 0xff0000},
1738 {DISPID_GLOBAL_VBCYAN
, NULL
, BP_GET
, VT_I4
, 0xffff00},
1739 {DISPID_GLOBAL_VBGREEN
, NULL
, BP_GET
, VT_I4
, 0x00ff00},
1740 {DISPID_GLOBAL_VBMAGENTA
, NULL
, BP_GET
, VT_I4
, 0xff00ff},
1741 {DISPID_GLOBAL_VBRED
, NULL
, BP_GET
, VT_I4
, 0x0000ff},
1742 {DISPID_GLOBAL_VBWHITE
, NULL
, BP_GET
, VT_I4
, 0xffffff},
1743 {DISPID_GLOBAL_VBYELLOW
, NULL
, BP_GET
, VT_I4
, 0x00ffff},
1744 {DISPID_GLOBAL_VBCR
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbCr
},
1745 {DISPID_GLOBAL_VBCRLF
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbCrLf
},
1746 {DISPID_GLOBAL_VBNEWLINE
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbNewLine
},
1747 {DISPID_GLOBAL_VBFORMFEED
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbFormFeed
},
1748 {DISPID_GLOBAL_VBLF
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbLf
},
1749 {DISPID_GLOBAL_VBNULLCHAR
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbNullChar
},
1750 {DISPID_GLOBAL_VBNULLSTRING
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbNullString
},
1751 {DISPID_GLOBAL_VBTAB
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbTab
},
1752 {DISPID_GLOBAL_VBVERTICALTAB
, NULL
, BP_GET
, VT_BSTR
, (UINT_PTR
)&vbVerticalTab
},
1753 {DISPID_GLOBAL_CCUR
, Global_CCur
, 0, 1},
1754 {DISPID_GLOBAL_CINT
, Global_CInt
, 0, 1},
1755 {DISPID_GLOBAL_CLNG
, Global_CLng
, 0, 1},
1756 {DISPID_GLOBAL_CBOOL
, Global_CBool
, 0, 1},
1757 {DISPID_GLOBAL_CBYTE
, Global_CByte
, 0, 1},
1758 {DISPID_GLOBAL_CDATE
, Global_CDate
, 0, 1},
1759 {DISPID_GLOBAL_CDBL
, Global_CDbl
, 0, 1},
1760 {DISPID_GLOBAL_CSNG
, Global_CSng
, 0, 1},
1761 {DISPID_GLOBAL_CSTR
, Global_CStr
, 0, 1},
1762 {DISPID_GLOBAL_HEX
, Global_Hex
, 0, 1},
1763 {DISPID_GLOBAL_OCT
, Global_Oct
, 0, 1},
1764 {DISPID_GLOBAL_VARTYPE
, Global_VarType
, 0, 1},
1765 {DISPID_GLOBAL_ISDATE
, Global_IsDate
, 0, 1},
1766 {DISPID_GLOBAL_ISEMPTY
, Global_IsEmpty
, 0, 1},
1767 {DISPID_GLOBAL_ISNULL
, Global_IsNull
, 0, 1},
1768 {DISPID_GLOBAL_ISNUMERIC
, Global_IsNumeric
, 0, 1},
1769 {DISPID_GLOBAL_ISARRAY
, Global_IsArray
, 0, 1},
1770 {DISPID_GLOBAL_ISOBJECT
, Global_IsObject
, 0, 1},
1771 {DISPID_GLOBAL_ATN
, Global_Ant
, 0, 1},
1772 {DISPID_GLOBAL_COS
, Global_Cos
, 0, 1},
1773 {DISPID_GLOBAL_SIN
, Global_Sin
, 0, 1},
1774 {DISPID_GLOBAL_TAN
, Global_Tan
, 0, 1},
1775 {DISPID_GLOBAL_EXP
, Global_Exp
, 0, 1},
1776 {DISPID_GLOBAL_LOG
, Global_Log
, 0, 1},
1777 {DISPID_GLOBAL_SQR
, Global_Sqr
, 0, 1},
1778 {DISPID_GLOBAL_RANDOMIZE
, Global_Randomize
, 0, 1},
1779 {DISPID_GLOBAL_RND
, Global_Rnd
, 0, 1},
1780 {DISPID_GLOBAL_TIMER
, Global_Timer
, 0, 0},
1781 {DISPID_GLOBAL_LBOUND
, Global_LBound
, 0, 1},
1782 {DISPID_GLOBAL_UBOUND
, Global_UBound
, 0, 1},
1783 {DISPID_GLOBAL_RGB
, Global_RGB
, 0, 3},
1784 {DISPID_GLOBAL_LEN
, Global_Len
, 0, 1},
1785 {DISPID_GLOBAL_LENB
, Global_LenB
, 0, 1},
1786 {DISPID_GLOBAL_LEFT
, Global_Left
, 0, 2},
1787 {DISPID_GLOBAL_LEFTB
, Global_LeftB
, 0, 2},
1788 {DISPID_GLOBAL_RIGHT
, Global_Right
, 0, 2},
1789 {DISPID_GLOBAL_RIGHTB
, Global_RightB
, 0, 2},
1790 {DISPID_GLOBAL_MID
, Global_Mid
, 0, 2, 3},
1791 {DISPID_GLOBAL_MIDB
, Global_MidB
, 0, 2, 3},
1792 {DISPID_GLOBAL_STRCOMP
, Global_StrComp
, 0, 2, 3},
1793 {DISPID_GLOBAL_LCASE
, Global_LCase
, 0, 1},
1794 {DISPID_GLOBAL_UCASE
, Global_UCase
, 0, 1},
1795 {DISPID_GLOBAL_LTRIM
, Global_LTrim
, 0, 1},
1796 {DISPID_GLOBAL_RTRIM
, Global_RTrim
, 0, 1},
1797 {DISPID_GLOBAL_TRIM
, Global_Trim
, 0, 1},
1798 {DISPID_GLOBAL_SPACE
, Global_Space
, 0, 1},
1799 {DISPID_GLOBAL_STRING
, Global_String
, 0, 0, 2},
1800 {DISPID_GLOBAL_INSTR
, Global_InStr
, 0, 2, 4},
1801 {DISPID_GLOBAL_INSTRB
, Global_InStrB
, 0, 3, 4},
1802 {DISPID_GLOBAL_ASCB
, Global_AscB
, 0, 1},
1803 {DISPID_GLOBAL_CHRB
, Global_ChrB
, 0, 1},
1804 {DISPID_GLOBAL_ASC
, Global_Asc
, 0, 1},
1805 {DISPID_GLOBAL_CHR
, Global_Chr
, 0, 1},
1806 {DISPID_GLOBAL_ASCW
, Global_AscW
, 0, 1},
1807 {DISPID_GLOBAL_CHRW
, Global_ChrW
, 0, 1},
1808 {DISPID_GLOBAL_ABS
, Global_Abs
, 0, 1},
1809 {DISPID_GLOBAL_FIX
, Global_Fix
, 0, 1},
1810 {DISPID_GLOBAL_INT
, Global_Int
, 0, 1},
1811 {DISPID_GLOBAL_SGN
, Global_Sgn
, 0, 1},
1812 {DISPID_GLOBAL_NOW
, Global_Now
, 0, 0},
1813 {DISPID_GLOBAL_DATE
, Global_Date
, 0, 0},
1814 {DISPID_GLOBAL_TIME
, Global_Time
, 0, 0},
1815 {DISPID_GLOBAL_DAY
, Global_Day
, 0, 1},
1816 {DISPID_GLOBAL_MONTH
, Global_Month
, 0, 1},
1817 {DISPID_GLOBAL_WEEKDAY
, Global_Weekday
, 0, 1, 2},
1818 {DISPID_GLOBAL_YEAR
, Global_Year
, 0, 1},
1819 {DISPID_GLOBAL_HOUR
, Global_Hour
, 0, 1},
1820 {DISPID_GLOBAL_MINUTE
, Global_Minute
, 0, 1},
1821 {DISPID_GLOBAL_SECOND
, Global_Second
, 0, 1},
1822 {DISPID_GLOBAL_DATEVALUE
, Global_DateValue
, 0, 1},
1823 {DISPID_GLOBAL_TIMEVALUE
, Global_TimeValue
, 0, 1},
1824 {DISPID_GLOBAL_DATESERIAL
, Global_DateSerial
, 0, 3},
1825 {DISPID_GLOBAL_TIMESERIAL
, Global_TimeSerial
, 0, 3},
1826 {DISPID_GLOBAL_INPUTBOX
, Global_InputBox
, 0, 1, 7},
1827 {DISPID_GLOBAL_MSGBOX
, Global_MsgBox
, 0, 1, 5},
1828 {DISPID_GLOBAL_CREATEOBJECT
, Global_CreateObject
, 0, 1},
1829 {DISPID_GLOBAL_GETOBJECT
, Global_GetObject
, 0, 0, 2},
1830 {DISPID_GLOBAL_DATEADD
, Global_DateAdd
, 0, 3},
1831 {DISPID_GLOBAL_DATEDIFF
, Global_DateDiff
, 0, 3, 5},
1832 {DISPID_GLOBAL_DATEPART
, Global_DatePart
, 0, 2, 4},
1833 {DISPID_GLOBAL_TYPENAME
, Global_TypeName
, 0, 1},
1834 {DISPID_GLOBAL_ARRAY
, Global_Array
, 0, 1},
1835 {DISPID_GLOBAL_ERASE
, Global_Erase
, 0, 1},
1836 {DISPID_GLOBAL_FILTER
, Global_Filter
, 0, 2, 4},
1837 {DISPID_GLOBAL_JOIN
, Global_Join
, 0, 1, 2},
1838 {DISPID_GLOBAL_SPLIT
, Global_Split
, 0, 1, 4},
1839 {DISPID_GLOBAL_REPLACE
, Global_Replace
, 0, 3, 6},
1840 {DISPID_GLOBAL_STRREVERSE
, Global_StrReverse
, 0, 1},
1841 {DISPID_GLOBAL_INSTRREV
, Global_InStrRev
, 0, 2, 4},
1842 {DISPID_GLOBAL_LOADPICTURE
, Global_LoadPicture
, 0, 1},
1843 {DISPID_GLOBAL_SCRIPTENGINE
, Global_ScriptEngine
, 0, 0},
1844 {DISPID_GLOBAL_SCRIPTENGINEMAJORVERSION
, Global_ScriptEngineMajorVersion
, 0, 0},
1845 {DISPID_GLOBAL_SCRIPTENGINEMINORVERSION
, Global_ScriptEngineMinorVersion
, 0, 0},
1846 {DISPID_GLOBAL_SCRIPTENGINEBUILDVERSION
, Global_ScriptEngineBuildVersion
, 0, 0},
1847 {DISPID_GLOBAL_FORMATNUMBER
, Global_FormatNumber
, 0, 1, 5},
1848 {DISPID_GLOBAL_FORMATCURRENCY
, Global_FormatCurrency
, 0, 1, 5},
1849 {DISPID_GLOBAL_FORMATPERCENT
, Global_FormatPercent
, 0, 1, 5},
1850 {DISPID_GLOBAL_FORMATDATETIME
, Global_FormatDateTime
, 0, 1, 2},
1851 {DISPID_GLOBAL_WEEKDAYNAME
, Global_WeekdayName
, 0, 1, 3},
1852 {DISPID_GLOBAL_MONTHNAME
, Global_MonthName
, 0, 1, 2},
1853 {DISPID_GLOBAL_ROUND
, Global_Round
, 0, 1, 2},
1854 {DISPID_GLOBAL_ESCAPE
, Global_Escape
, 0, 1},
1855 {DISPID_GLOBAL_UNESCAPE
, Global_Unescape
, 0, 1},
1856 {DISPID_GLOBAL_EVAL
, Global_Eval
, 0, 1},
1857 {DISPID_GLOBAL_EXECUTE
, Global_Execute
, 0, 1},
1858 {DISPID_GLOBAL_EXECUTEGLOBAL
, Global_ExecuteGlobal
, 0, 1},
1859 {DISPID_GLOBAL_GETREF
, Global_GetRef
, 0, 1},
1860 {DISPID_GLOBAL_VBMSGBOXHELPBUTTON
, NULL
, BP_GET
, VT_I4
, MB_HELP
},
1861 {DISPID_GLOBAL_VBMSGBOXSETFOREGROUND
, NULL
, BP_GET
, VT_I4
, MB_SETFOREGROUND
},
1862 {DISPID_GLOBAL_VBMSGBOXRIGHT
, NULL
, BP_GET
, VT_I4
, MB_RIGHT
},
1863 {DISPID_GLOBAL_VBMSGBOXRTLREADING
, NULL
, BP_GET
, VT_I4
, MB_RTLREADING
}
1866 HRESULT
init_global(script_ctx_t
*ctx
)
1870 ctx
->global_desc
.ctx
= ctx
;
1871 ctx
->global_desc
.builtin_prop_cnt
= sizeof(global_props
)/sizeof(*global_props
);
1872 ctx
->global_desc
.builtin_props
= global_props
;
1874 hres
= get_typeinfo(GlobalObj_tid
, &ctx
->global_desc
.typeinfo
);
1878 hres
= create_vbdisp(&ctx
->global_desc
, &ctx
->global_obj
);
1882 hres
= create_script_disp(ctx
, &ctx
->script_obj
);
1886 return init_err(ctx
);