2011-09-19 14:08:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-10-19 19:38:44 +02:00
|
|
|
#include <assert.h>
|
2012-09-26 14:36:01 +02:00
|
|
|
#include <math.h>
|
2011-10-19 19:38:44 +02:00
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
#include "vbscript.h"
|
|
|
|
#include "vbscript_defs.h"
|
|
|
|
|
2011-09-22 14:25:27 +02:00
|
|
|
#include "mshtmhst.h"
|
|
|
|
#include "objsafe.h"
|
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
|
|
|
|
|
2011-09-22 14:25:27 +02:00
|
|
|
#define VB_E_CANNOT_CREATE_OBJ 0x800a01ad
|
2013-01-24 12:26:54 +01:00
|
|
|
#define VB_E_MK_PARSE_ERROR 0x800a01b0
|
2011-09-22 14:25:27 +02:00
|
|
|
|
|
|
|
/* Defined as extern in urlmon.idl, but not exported by uuid.lib */
|
|
|
|
const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
|
|
|
|
{0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
|
|
|
|
|
2012-09-26 14:36:45 +02:00
|
|
|
static const WCHAR emptyW[] = {0};
|
|
|
|
static const WCHAR vbscriptW[] = {'V','B','S','c','r','i','p','t',0};
|
|
|
|
|
2019-10-17 22:46:33 +02:00
|
|
|
HRESULT get_builtin_id(BuiltinDisp *disp, const WCHAR *name, DISPID *id)
|
|
|
|
{
|
|
|
|
return ITypeInfo_GetIDsOfNames(disp->desc->typeinfo, (WCHAR**)&name, 1, id);
|
|
|
|
}
|
|
|
|
|
2011-09-22 14:25:27 +02:00
|
|
|
static IInternetHostSecurityManager *get_sec_mgr(script_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
IInternetHostSecurityManager *secmgr;
|
|
|
|
IServiceProvider *sp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!ctx->site)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(ctx->secmgr)
|
|
|
|
return ctx->secmgr;
|
|
|
|
|
|
|
|
hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IServiceProvider, (void**)&sp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hres = IServiceProvider_QueryService(sp, &SID_SInternetHostSecurityManager, &IID_IInternetHostSecurityManager,
|
|
|
|
(void**)&secmgr);
|
|
|
|
IServiceProvider_Release(sp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ctx->secmgr = secmgr;
|
|
|
|
}
|
|
|
|
|
2012-09-27 13:10:49 +02:00
|
|
|
static HRESULT return_string(VARIANT *res, const WCHAR *str)
|
2011-10-11 14:59:32 +02:00
|
|
|
{
|
|
|
|
BSTR ret;
|
|
|
|
|
|
|
|
if(!res)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
ret = SysAllocString(str);
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
V_VT(res) = VT_BSTR;
|
|
|
|
V_BSTR(res) = ret;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-27 13:10:49 +02:00
|
|
|
static HRESULT return_bstr(VARIANT *res, BSTR str)
|
|
|
|
{
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_BSTR;
|
|
|
|
V_BSTR(res) = str;
|
|
|
|
}else {
|
|
|
|
SysFreeString(str);
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-21 17:41:22 +02:00
|
|
|
static HRESULT return_bool(VARIANT *res, BOOL val)
|
|
|
|
{
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_BOOL;
|
|
|
|
V_BOOL(res) = val ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-21 12:42:37 +02:00
|
|
|
static HRESULT return_short(VARIANT *res, short val)
|
|
|
|
{
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_I2;
|
|
|
|
V_I2(res) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-30 17:00:12 +01:00
|
|
|
static HRESULT return_int(VARIANT *res, int val)
|
|
|
|
{
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_I4;
|
|
|
|
V_I4(res) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-26 14:36:01 +02:00
|
|
|
static inline HRESULT return_double(VARIANT *res, double val)
|
|
|
|
{
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_R8;
|
|
|
|
V_R8(res) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-13 11:18:24 +02:00
|
|
|
static inline HRESULT return_float(VARIANT *res, float val)
|
|
|
|
{
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_R4;
|
|
|
|
V_R4(res) = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-30 17:00:12 +01:00
|
|
|
static inline HRESULT return_null(VARIANT *res)
|
|
|
|
{
|
|
|
|
if(res)
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-28 11:49:30 +02:00
|
|
|
static inline HRESULT return_date(VARIANT *res, double date)
|
|
|
|
{
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_DATE;
|
|
|
|
V_DATE(res) = date;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-13 16:29:39 +01:00
|
|
|
HRESULT to_int(VARIANT *v, int *ret)
|
2012-03-29 12:06:11 +02:00
|
|
|
{
|
2014-07-21 16:05:14 +02:00
|
|
|
VARIANT r;
|
|
|
|
HRESULT hres;
|
2013-05-16 11:26:17 +02:00
|
|
|
|
2014-07-21 16:05:14 +02:00
|
|
|
V_VT(&r) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&r, v, 0, VT_I4);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2012-03-29 12:06:11 +02:00
|
|
|
|
2014-07-21 16:05:14 +02:00
|
|
|
*ret = V_I4(&r);
|
2012-03-29 12:06:11 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-26 14:36:01 +02:00
|
|
|
static HRESULT to_double(VARIANT *v, double *ret)
|
|
|
|
{
|
2014-07-11 05:47:45 +02:00
|
|
|
VARIANT dst;
|
|
|
|
HRESULT hres;
|
2012-09-26 14:36:01 +02:00
|
|
|
|
2014-07-11 05:47:45 +02:00
|
|
|
V_VT(&dst) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&dst, v, 0, VT_R8);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2012-09-26 14:36:01 +02:00
|
|
|
|
2014-07-11 05:47:45 +02:00
|
|
|
*ret = V_R8(&dst);
|
2012-09-26 14:36:01 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-11 10:23:22 +02:00
|
|
|
static HRESULT to_string(VARIANT *v, BSTR *ret)
|
|
|
|
{
|
2012-07-18 13:37:07 +02:00
|
|
|
VARIANT dst;
|
|
|
|
HRESULT hres;
|
2012-07-11 10:23:22 +02:00
|
|
|
|
2012-07-18 13:37:07 +02:00
|
|
|
V_VT(&dst) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&dst, v, VARIANT_LOCALBOOL, VT_BSTR);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*ret = V_BSTR(&dst);
|
|
|
|
return S_OK;
|
2012-07-11 10:23:22 +02:00
|
|
|
}
|
|
|
|
|
2019-09-30 20:19:31 +02:00
|
|
|
static HRESULT to_system_time(VARIANT *v, SYSTEMTIME *st)
|
|
|
|
{
|
|
|
|
VARIANT date;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(&date) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&date, v, 0, VT_DATE);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return VariantTimeToSystemTime(V_DATE(&date), st);
|
|
|
|
}
|
|
|
|
|
2013-01-24 12:26:54 +01:00
|
|
|
static HRESULT set_object_site(script_ctx_t *ctx, IUnknown *obj)
|
|
|
|
{
|
|
|
|
IObjectWithSite *obj_site;
|
|
|
|
IUnknown *ax_site;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(obj, &IID_IObjectWithSite, (void**)&obj_site);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
ax_site = create_ax_site(ctx);
|
2015-02-16 09:30:11 +01:00
|
|
|
if(ax_site) {
|
2013-01-24 12:26:54 +01:00
|
|
|
hres = IObjectWithSite_SetSite(obj_site, ax_site);
|
2015-02-16 09:30:11 +01:00
|
|
|
IUnknown_Release(ax_site);
|
|
|
|
}
|
2013-01-24 12:26:54 +01:00
|
|
|
else
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
IObjectWithSite_Release(obj_site);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2011-09-22 14:25:27 +02:00
|
|
|
static IUnknown *create_object(script_ctx_t *ctx, const WCHAR *progid)
|
|
|
|
{
|
|
|
|
IInternetHostSecurityManager *secmgr = NULL;
|
|
|
|
struct CONFIRMSAFETY cs;
|
|
|
|
IClassFactoryEx *cfex;
|
|
|
|
IClassFactory *cf;
|
|
|
|
DWORD policy_size;
|
|
|
|
BYTE *bpolicy;
|
|
|
|
IUnknown *obj;
|
|
|
|
DWORD policy;
|
|
|
|
GUID guid;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = CLSIDFromProgID(progid, &guid);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
TRACE("GUID %s\n", debugstr_guid(&guid));
|
|
|
|
|
|
|
|
if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
|
|
|
|
secmgr = get_sec_mgr(ctx);
|
|
|
|
if(!secmgr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
policy = 0;
|
|
|
|
hres = IInternetHostSecurityManager_ProcessUrlAction(secmgr, URLACTION_ACTIVEX_RUN,
|
|
|
|
(BYTE*)&policy, sizeof(policy), (BYTE*)&guid, sizeof(GUID), 0, 0);
|
|
|
|
if(FAILED(hres) || policy != URLPOLICY_ALLOW)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hres = IClassFactory_QueryInterface(cf, &IID_IClassFactoryEx, (void**)&cfex);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
FIXME("Use IClassFactoryEx\n");
|
|
|
|
IClassFactoryEx_Release(cfex);
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(secmgr) {
|
|
|
|
cs.clsid = guid;
|
|
|
|
cs.pUnk = obj;
|
|
|
|
cs.dwFlags = 0;
|
|
|
|
hres = IInternetHostSecurityManager_QueryCustomPolicy(secmgr, &GUID_CUSTOM_CONFIRMOBJECTSAFETY,
|
|
|
|
&bpolicy, &policy_size, (BYTE*)&cs, sizeof(cs), 0);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
policy = policy_size >= sizeof(DWORD) ? *(DWORD*)bpolicy : URLPOLICY_DISALLOW;
|
|
|
|
CoTaskMemFree(bpolicy);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
|
|
|
|
IUnknown_Release(obj);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 12:26:54 +01:00
|
|
|
hres = set_object_site(ctx, obj);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IUnknown_Release(obj);
|
|
|
|
return NULL;
|
2011-09-22 14:25:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2014-07-23 18:28:28 +02:00
|
|
|
static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR orig_title, VARIANT *res)
|
2012-09-26 14:36:45 +02:00
|
|
|
{
|
|
|
|
SCRIPTUICHANDLING uic_handling = SCRIPTUICHANDLING_ALLOW;
|
|
|
|
IActiveScriptSiteUIControl *ui_control;
|
|
|
|
IActiveScriptSiteWindow *acts_window;
|
2014-07-23 18:28:28 +02:00
|
|
|
WCHAR *title_buf = NULL;
|
2012-09-26 14:36:45 +02:00
|
|
|
const WCHAR *title;
|
|
|
|
HWND hwnd = NULL;
|
2014-07-23 18:28:28 +02:00
|
|
|
int ret = 0;
|
2012-09-26 14:36:45 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteUIControl, (void**)&ui_control);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IActiveScriptSiteUIControl_GetUIBehavior(ui_control, SCRIPTUICITEM_MSGBOX, &uic_handling);
|
|
|
|
IActiveScriptSiteUIControl_Release(ui_control);
|
|
|
|
if(FAILED(hres))
|
|
|
|
uic_handling = SCRIPTUICHANDLING_ALLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(uic_handling) {
|
|
|
|
case SCRIPTUICHANDLING_ALLOW:
|
|
|
|
break;
|
|
|
|
case SCRIPTUICHANDLING_NOUIDEFAULT:
|
|
|
|
return return_short(res, 0);
|
|
|
|
default:
|
|
|
|
FIXME("blocked\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IActiveScriptSite_QueryInterface(ctx->site, &IID_IActiveScriptSiteWindow, (void**)&acts_window);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
FIXME("No IActiveScriptSiteWindow\n");
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2014-07-23 18:28:28 +02:00
|
|
|
if(ctx->safeopt & INTERFACE_USES_SECURITY_MANAGER) {
|
|
|
|
if(orig_title && *orig_title) {
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
2019-06-25 08:38:01 +02:00
|
|
|
title = title_buf = heap_alloc(sizeof(vbscriptW) + (lstrlenW(orig_title)+2)*sizeof(WCHAR));
|
2014-07-23 18:28:28 +02:00
|
|
|
if(!title)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
memcpy(title_buf, vbscriptW, sizeof(vbscriptW));
|
2018-07-18 23:01:34 +02:00
|
|
|
ptr = title_buf + ARRAY_SIZE(vbscriptW)-1;
|
2014-07-23 18:28:28 +02:00
|
|
|
|
|
|
|
*ptr++ = ':';
|
|
|
|
*ptr++ = ' ';
|
2019-06-25 08:38:01 +02:00
|
|
|
lstrcpyW(ptr, orig_title);
|
2014-07-23 18:28:28 +02:00
|
|
|
}else {
|
|
|
|
title = vbscriptW;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
title = orig_title ? orig_title : emptyW;
|
|
|
|
}
|
|
|
|
|
2012-09-26 14:36:45 +02:00
|
|
|
hres = IActiveScriptSiteWindow_GetWindow(acts_window, &hwnd);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IActiveScriptSiteWindow_EnableModeless(acts_window, FALSE);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2014-07-23 18:28:28 +02:00
|
|
|
ret = MessageBoxW(hwnd, prompt, title, type);
|
2012-09-26 14:36:45 +02:00
|
|
|
hres = IActiveScriptSiteWindow_EnableModeless(acts_window, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-23 18:28:28 +02:00
|
|
|
heap_free(title_buf);
|
2012-09-26 14:36:45 +02:00
|
|
|
IActiveScriptSiteWindow_Release(acts_window);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
FIXME("failed: %08x\n", hres);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_short(res, ret);
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CCur(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-05-20 03:05:07 +02:00
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&v, arg, 0, VT_CY);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(!res) {
|
|
|
|
VariantClear(&v);
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*res = v;
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CInt(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-06-02 02:17:54 +02:00
|
|
|
VARIANT v;
|
2013-05-21 15:29:03 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
2014-06-02 02:17:54 +02:00
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&v, arg, 0, VT_I2);
|
2013-05-21 15:29:03 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2014-06-02 02:17:54 +02:00
|
|
|
if(!res)
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
else {
|
|
|
|
*res = v;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CLng(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-07-21 16:05:14 +02:00
|
|
|
int i;
|
2014-06-02 02:16:43 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
2014-07-21 16:05:14 +02:00
|
|
|
hres = to_int(arg, &i);
|
2014-06-02 02:16:43 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
if(!res)
|
|
|
|
return DISP_E_BADVARTYPE;
|
2014-07-21 16:05:14 +02:00
|
|
|
|
2014-09-22 15:52:13 +02:00
|
|
|
return return_int(res, i);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CBool(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-05-03 04:14:26 +02:00
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2013-05-21 15:30:06 +02:00
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
2014-05-03 04:14:26 +02:00
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&v, arg, VARIANT_LOCALBOOL, VT_BOOL);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2013-05-21 15:30:06 +02:00
|
|
|
|
2014-05-03 04:14:26 +02:00
|
|
|
if(res)
|
|
|
|
*res = v;
|
|
|
|
else
|
|
|
|
VariantClear(&v);
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CByte(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-05-14 17:05:02 +02:00
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&v, arg, VARIANT_LOCALBOOL, VT_UI1);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(!res) {
|
|
|
|
VariantClear(&v);
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*res = v;
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CDate(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CDbl(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-06-02 02:15:34 +02:00
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&v, arg, 0, VT_R8);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(!res)
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
else {
|
|
|
|
*res = v;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CSng(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-06-13 16:30:29 +02:00
|
|
|
VARIANT v;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
V_VT(&v) = VT_EMPTY;
|
|
|
|
hres = VariantChangeType(&v, arg, 0, VT_R4);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(!res)
|
|
|
|
return DISP_E_BADVARTYPE;
|
|
|
|
|
|
|
|
*res = v;
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CStr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-10-08 14:38:25 +02:00
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
2019-08-21 20:22:46 +02:00
|
|
|
if(V_VT(arg) == VT_NULL)
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
|
|
|
|
|
2012-10-08 14:38:25 +02:00
|
|
|
hres = to_string(arg, &str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_bstr(res, str);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2011-10-11 14:59:32 +02:00
|
|
|
static inline WCHAR hex_char(unsigned n)
|
|
|
|
{
|
|
|
|
return n < 10 ? '0'+n : 'A'+n-10;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Hex(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2011-10-11 14:59:32 +02:00
|
|
|
WCHAR buf[17], *ptr;
|
|
|
|
DWORD n;
|
2015-04-02 16:20:49 +02:00
|
|
|
HRESULT hres;
|
|
|
|
int ret;
|
2011-10-11 14:59:32 +02:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
switch(V_VT(arg)) {
|
|
|
|
case VT_I2:
|
|
|
|
n = (WORD)V_I2(arg);
|
|
|
|
break;
|
|
|
|
case VT_NULL:
|
|
|
|
if(res)
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
default:
|
2015-04-02 16:20:49 +02:00
|
|
|
hres = to_int(arg, &ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
else
|
|
|
|
n = ret;
|
2011-10-11 14:59:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
buf[16] = 0;
|
|
|
|
ptr = buf+15;
|
|
|
|
|
|
|
|
if(n) {
|
|
|
|
do {
|
|
|
|
*ptr-- = hex_char(n & 0xf);
|
|
|
|
n >>= 4;
|
|
|
|
}while(n);
|
|
|
|
ptr++;
|
|
|
|
}else {
|
|
|
|
*ptr = '0';
|
|
|
|
}
|
|
|
|
|
2012-09-27 13:10:49 +02:00
|
|
|
return return_string(res, ptr);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Oct(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2015-03-28 10:24:46 +01:00
|
|
|
HRESULT hres;
|
|
|
|
WCHAR buf[23], *ptr;
|
|
|
|
DWORD n;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
switch(V_VT(arg)) {
|
|
|
|
case VT_I2:
|
|
|
|
n = (WORD)V_I2(arg);
|
|
|
|
break;
|
|
|
|
case VT_NULL:
|
|
|
|
if(res)
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
default:
|
|
|
|
hres = to_int(arg, &ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
else
|
|
|
|
n = ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf[22] = 0;
|
|
|
|
ptr = buf + 21;
|
|
|
|
|
|
|
|
if(n) {
|
|
|
|
do {
|
|
|
|
*ptr-- = '0' + (n & 0x7);
|
|
|
|
n >>= 3;
|
|
|
|
}while(n);
|
|
|
|
ptr++;
|
|
|
|
}else {
|
|
|
|
*ptr = '0';
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_string(res, ptr);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_VarType(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-08-22 19:31:35 +02:00
|
|
|
VARTYPE vt;
|
|
|
|
|
2014-07-11 05:43:28 +02:00
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
2019-08-22 19:31:35 +02:00
|
|
|
vt = V_VT(arg) & ~VT_BYREF;
|
|
|
|
if(vt & ~(VT_TYPEMASK | VT_ARRAY)) {
|
2014-07-11 05:43:28 +02:00
|
|
|
FIXME("not supported %s\n", debugstr_variant(arg));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-08-22 19:31:35 +02:00
|
|
|
return return_short(res, vt);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_IsDate(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_IsEmpty(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2011-10-19 19:39:00 +02:00
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_BOOL;
|
|
|
|
V_BOOL(res) = V_VT(arg) == VT_EMPTY ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_IsNull(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2011-10-20 12:57:18 +02:00
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_BOOL;
|
|
|
|
V_BOOL(res) = V_VT(arg) == VT_NULL ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_IsNumeric(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-07-21 17:41:22 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
|
|
|
|
return return_bool(res, SUCCEEDED(hres));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_IsArray(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_IsObject(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:08:38 +02:00
|
|
|
{
|
2011-09-19 14:08:48 +02:00
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
2011-10-19 19:38:44 +02:00
|
|
|
assert(args_cnt == 1);
|
2011-09-19 14:08:48 +02:00
|
|
|
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_BOOL;
|
|
|
|
V_BOOL(res) = V_VT(arg) == VT_DISPATCH ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2011-09-19 14:08:38 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Atn(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-18 17:12:23 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_double(res, atan(d));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Cos(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-18 17:11:00 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_double(res, cos(d));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Sin(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-18 17:11:29 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_double(res, sin(d));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Tan(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-18 17:11:54 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_double(res, tan(d));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Exp(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-18 17:12:45 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_double(res, exp(d));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Log(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-18 17:13:12 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(d <= 0)
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
|
|
|
else
|
|
|
|
return return_double(res, log(d));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Sqr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-18 17:10:25 +02:00
|
|
|
HRESULT hres;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
hres = to_double(arg, &d);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(d < 0)
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
|
|
|
else
|
|
|
|
return return_double(res, sqrt(d));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Randomize(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Rnd(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Timer(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-10-13 11:18:24 +02:00
|
|
|
SYSTEMTIME lt;
|
|
|
|
double sec;
|
|
|
|
|
|
|
|
GetLocalTime(<);
|
|
|
|
sec = lt.wHour * 3600 + lt.wMinute * 60 + lt.wSecond + lt.wMilliseconds / 1000.0;
|
|
|
|
return return_float(res, sec);
|
|
|
|
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_LBound(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_UBound(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2017-11-06 16:53:08 +01:00
|
|
|
SAFEARRAY *sa;
|
|
|
|
HRESULT hres;
|
|
|
|
LONG ubound;
|
|
|
|
int dim;
|
|
|
|
|
|
|
|
assert(args_cnt == 1 || args_cnt == 2);
|
|
|
|
|
|
|
|
TRACE("%s %s\n", debugstr_variant(arg), args_cnt == 2 ? debugstr_variant(arg + 1) : "1");
|
|
|
|
|
|
|
|
switch(V_VT(arg)) {
|
|
|
|
case VT_VARIANT|VT_ARRAY:
|
|
|
|
sa = V_ARRAY(arg);
|
|
|
|
break;
|
|
|
|
case VT_VARIANT|VT_ARRAY|VT_BYREF:
|
|
|
|
sa = *V_ARRAYREF(arg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("arg %s not supported\n", debugstr_variant(arg));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(args_cnt == 2) {
|
|
|
|
hres = to_int(arg + 1, &dim);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}else {
|
|
|
|
dim = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = SafeArrayGetUBound(sa, dim, &ubound);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_int(res, ubound);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_RGB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-09-30 12:31:08 +02:00
|
|
|
HRESULT hres;
|
|
|
|
int i, color[3];
|
|
|
|
|
|
|
|
TRACE("%s %s %s\n", debugstr_variant(arg), debugstr_variant(arg + 1), debugstr_variant(arg + 2));
|
|
|
|
|
|
|
|
assert(args_cnt == 3);
|
|
|
|
|
|
|
|
for(i = 0; i < 3; i++) {
|
|
|
|
hres = to_int(arg + i, color + i);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
if(color[i] > 255)
|
|
|
|
color[i] = 255;
|
|
|
|
if(color[i] < 0)
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_int(res, RGB(color[0], color[1], color[2]));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Len(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-09-18 12:25:26 +02:00
|
|
|
DWORD len;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(V_VT(arg) == VT_NULL)
|
|
|
|
return return_null(res);
|
|
|
|
|
|
|
|
if(V_VT(arg) != VT_BSTR) {
|
|
|
|
BSTR str;
|
|
|
|
|
|
|
|
hres = to_string(arg, &str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
len = SysStringLen(str);
|
|
|
|
SysFreeString(str);
|
|
|
|
}else {
|
|
|
|
len = SysStringLen(V_BSTR(arg));
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_int(res, len);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_LenB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Left(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-10-01 12:59:56 +02:00
|
|
|
BSTR str, ret, conv_str = NULL;
|
|
|
|
int len, str_len;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s %s)\n", debugstr_variant(args+1), debugstr_variant(args));
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
if(V_VT(args) == VT_BSTR) {
|
|
|
|
str = V_BSTR(args);
|
2012-10-01 12:59:56 +02:00
|
|
|
}else {
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_string(args, &conv_str);
|
2012-10-01 12:59:56 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
str = conv_str;
|
|
|
|
}
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_int(args+1, &len);
|
2012-10-01 12:59:56 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(len < 0) {
|
|
|
|
FIXME("len = %d\n", len);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
str_len = SysStringLen(str);
|
|
|
|
if(len > str_len)
|
|
|
|
len = str_len;
|
|
|
|
|
|
|
|
ret = SysAllocStringLen(str, len);
|
|
|
|
SysFreeString(conv_str);
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return return_bstr(res, ret);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_LeftB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Right(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-10-01 13:00:09 +02:00
|
|
|
BSTR str, ret, conv_str = NULL;
|
|
|
|
int len, str_len;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
TRACE("(%s %s)\n", debugstr_variant(args), debugstr_variant(args+1));
|
2012-10-01 13:00:09 +02:00
|
|
|
|
|
|
|
if(V_VT(args+1) == VT_BSTR) {
|
2012-10-17 09:54:12 +02:00
|
|
|
str = V_BSTR(args);
|
2012-10-01 13:00:09 +02:00
|
|
|
}else {
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_string(args, &conv_str);
|
2012-10-01 13:00:09 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
str = conv_str;
|
|
|
|
}
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_int(args+1, &len);
|
2012-10-01 13:00:09 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(len < 0) {
|
|
|
|
FIXME("len = %d\n", len);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
str_len = SysStringLen(str);
|
|
|
|
if(len > str_len)
|
|
|
|
len = str_len;
|
|
|
|
|
|
|
|
ret = SysAllocStringLen(str+str_len-len, len);
|
|
|
|
SysFreeString(conv_str);
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return return_bstr(res, ret);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_RightB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Mid(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-03-29 12:06:11 +02:00
|
|
|
int len = -1, start, str_len;
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
|
2012-03-29 12:06:11 +02:00
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
assert(args_cnt == 2 || args_cnt == 3);
|
|
|
|
|
|
|
|
if(V_VT(args) != VT_BSTR) {
|
|
|
|
FIXME("args[0] = %s\n", debugstr_variant(args));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = V_BSTR(args);
|
|
|
|
|
|
|
|
hres = to_int(args+1, &start);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(args_cnt == 3) {
|
|
|
|
hres = to_int(args+2, &len);
|
2012-03-29 12:06:11 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(len < 0) {
|
|
|
|
FIXME("len = %d\n", len);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
str_len = SysStringLen(str);
|
|
|
|
start--;
|
|
|
|
if(start > str_len)
|
|
|
|
start = str_len;
|
|
|
|
|
|
|
|
if(len == -1)
|
|
|
|
len = str_len-start;
|
|
|
|
else if(len > str_len-start)
|
|
|
|
len = str_len-start;
|
|
|
|
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_BSTR;
|
|
|
|
V_BSTR(res) = SysAllocStringLen(str+start, len);
|
|
|
|
if(!V_BSTR(res))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_MidB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_StrComp(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2016-11-04 14:32:24 +01:00
|
|
|
BSTR left, right;
|
|
|
|
int mode, ret;
|
|
|
|
HRESULT hres;
|
|
|
|
short val;
|
|
|
|
|
|
|
|
TRACE("(%s %s ...)\n", debugstr_variant(args), debugstr_variant(args+1));
|
|
|
|
|
|
|
|
assert(args_cnt == 2 || args_cnt == 3);
|
|
|
|
|
|
|
|
if (args_cnt == 3) {
|
|
|
|
hres = to_int(args+2, &mode);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if (mode != 0 && mode != 1) {
|
|
|
|
FIXME("unknown compare mode = %d\n", mode);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mode = 0;
|
|
|
|
|
2016-11-08 08:06:15 +01:00
|
|
|
hres = to_string(args, &left);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = to_string(args+1, &right);
|
|
|
|
if(FAILED(hres))
|
|
|
|
{
|
|
|
|
SysFreeString(left);
|
|
|
|
return hres;
|
|
|
|
}
|
2016-11-04 14:32:24 +01:00
|
|
|
|
2019-06-25 08:38:01 +02:00
|
|
|
ret = mode ? wcsicmp(left, right) : wcscmp(left, right);
|
2016-11-04 14:32:24 +01:00
|
|
|
val = ret < 0 ? -1 : (ret > 0 ? 1 : 0);
|
2016-11-08 08:06:15 +01:00
|
|
|
|
|
|
|
SysFreeString(left);
|
|
|
|
SysFreeString(right);
|
2016-11-04 14:32:24 +01:00
|
|
|
return return_short(res, val);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_LCase(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-07-11 10:23:37 +02:00
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(V_VT(arg) == VT_NULL) {
|
|
|
|
if(res)
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = to_string(arg, &str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(res) {
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
|
|
|
for(ptr = str; *ptr; ptr++)
|
2019-06-25 08:38:01 +02:00
|
|
|
*ptr = towlower(*ptr);
|
2012-07-11 10:23:37 +02:00
|
|
|
|
|
|
|
V_VT(res) = VT_BSTR;
|
|
|
|
V_BSTR(res) = str;
|
|
|
|
}else {
|
|
|
|
SysFreeString(str);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_UCase(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-07-11 10:23:22 +02:00
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(V_VT(arg) == VT_NULL) {
|
|
|
|
if(res)
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = to_string(arg, &str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(res) {
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
|
|
|
for(ptr = str; *ptr; ptr++)
|
2019-06-25 08:38:01 +02:00
|
|
|
*ptr = towupper(*ptr);
|
2012-07-11 10:23:22 +02:00
|
|
|
|
|
|
|
V_VT(res) = VT_BSTR;
|
|
|
|
V_BSTR(res) = str;
|
|
|
|
}else {
|
|
|
|
SysFreeString(str);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_LTrim(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-10-02 10:33:50 +02:00
|
|
|
BSTR str, conv_str = NULL;
|
|
|
|
WCHAR *ptr;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(V_VT(arg) == VT_BSTR) {
|
|
|
|
str = V_BSTR(arg);
|
|
|
|
}else {
|
|
|
|
hres = to_string(arg, &conv_str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
str = conv_str;
|
|
|
|
}
|
|
|
|
|
2019-06-25 08:38:01 +02:00
|
|
|
for(ptr = str; *ptr && iswspace(*ptr); ptr++);
|
2012-10-02 10:33:50 +02:00
|
|
|
|
|
|
|
str = SysAllocString(ptr);
|
|
|
|
SysFreeString(conv_str);
|
|
|
|
if(!str)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return return_bstr(res, str);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_RTrim(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-10-02 10:34:07 +02:00
|
|
|
BSTR str, conv_str = NULL;
|
|
|
|
WCHAR *ptr;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(V_VT(arg) == VT_BSTR) {
|
|
|
|
str = V_BSTR(arg);
|
|
|
|
}else {
|
|
|
|
hres = to_string(arg, &conv_str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
str = conv_str;
|
|
|
|
}
|
|
|
|
|
2019-06-25 08:38:01 +02:00
|
|
|
for(ptr = str+SysStringLen(str); ptr-1 > str && iswspace(*(ptr-1)); ptr--);
|
2012-10-02 10:34:07 +02:00
|
|
|
|
|
|
|
str = SysAllocStringLen(str, ptr-str);
|
|
|
|
SysFreeString(conv_str);
|
|
|
|
if(!str)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return return_bstr(res, str);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Trim(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-10-02 10:33:30 +02:00
|
|
|
BSTR str, conv_str = NULL;
|
|
|
|
WCHAR *begin_ptr, *end_ptr;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(V_VT(arg) == VT_BSTR) {
|
|
|
|
str = V_BSTR(arg);
|
|
|
|
}else {
|
|
|
|
hres = to_string(arg, &conv_str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
str = conv_str;
|
|
|
|
}
|
|
|
|
|
2019-06-25 08:38:01 +02:00
|
|
|
for(begin_ptr = str; *begin_ptr && iswspace(*begin_ptr); begin_ptr++);
|
|
|
|
for(end_ptr = str+SysStringLen(str); end_ptr-1 > begin_ptr && iswspace(*(end_ptr-1)); end_ptr--);
|
2012-10-02 10:33:30 +02:00
|
|
|
|
|
|
|
str = SysAllocStringLen(begin_ptr, end_ptr-begin_ptr);
|
|
|
|
SysFreeString(conv_str);
|
|
|
|
if(!str)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return return_bstr(res, str);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Space(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-09-25 14:25:22 +02:00
|
|
|
BSTR str;
|
|
|
|
int n, i;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_int(arg, &n);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(n < 0) {
|
|
|
|
FIXME("n = %d\n", n);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!res)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
str = SysAllocStringLen(NULL, n);
|
|
|
|
if(!str)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
for(i=0; i<n; i++)
|
|
|
|
str[i] = ' ';
|
|
|
|
|
|
|
|
V_VT(res) = VT_BSTR;
|
|
|
|
V_BSTR(res) = str;
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_String(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_InStr(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2011-12-30 17:00:12 +01:00
|
|
|
VARIANT *startv, *str1v, *str2v;
|
|
|
|
BSTR str1, str2;
|
|
|
|
int start, ret;
|
2012-03-29 12:06:20 +02:00
|
|
|
HRESULT hres;
|
2011-12-30 17:00:12 +01:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
assert(2 <= args_cnt && args_cnt <= 4);
|
|
|
|
|
2011-12-30 17:00:12 +01:00
|
|
|
switch(args_cnt) {
|
|
|
|
case 2:
|
|
|
|
startv = NULL;
|
2012-10-17 09:54:12 +02:00
|
|
|
str1v = args;
|
|
|
|
str2v = args+1;
|
2011-12-30 17:00:12 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2012-10-17 09:54:12 +02:00
|
|
|
startv = args;
|
2011-12-30 17:00:12 +01:00
|
|
|
str1v = args+1;
|
2012-10-17 09:54:12 +02:00
|
|
|
str2v = args+2;
|
2011-12-30 17:00:12 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
FIXME("unsupported compare argument %s\n", debugstr_variant(args));
|
|
|
|
return E_NOTIMPL;
|
2013-03-13 10:43:56 +01:00
|
|
|
DEFAULT_UNREACHABLE;
|
2011-12-30 17:00:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(startv) {
|
2012-03-29 12:06:20 +02:00
|
|
|
hres = to_int(startv, &start);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2011-12-30 17:00:12 +01:00
|
|
|
if(--start < 0) {
|
|
|
|
FIXME("start %d\n", start);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
start = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(V_VT(str1v) == VT_NULL || V_VT(str2v) == VT_NULL)
|
|
|
|
return return_null(res);
|
|
|
|
|
|
|
|
if(V_VT(str1v) != VT_BSTR) {
|
|
|
|
FIXME("Unsupported str1 type %s\n", debugstr_variant(str1v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
str1 = V_BSTR(str1v);
|
|
|
|
|
|
|
|
if(V_VT(str2v) != VT_BSTR) {
|
|
|
|
FIXME("Unsupported str2 type %s\n", debugstr_variant(str2v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
str2 = V_BSTR(str2v);
|
|
|
|
|
|
|
|
if(start < SysStringLen(str1)) {
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
2019-06-25 08:38:01 +02:00
|
|
|
ptr = wcsstr(str1+start, str2);
|
2011-12-30 17:00:12 +01:00
|
|
|
ret = ptr ? ptr-str1+1 : 0;
|
|
|
|
}else {
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_int(res, ret);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_InStrB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_AscB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_ChrB(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-08-21 20:22:33 +02:00
|
|
|
BSTR conv_str = NULL, str;
|
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
switch(V_VT(arg)) {
|
|
|
|
case VT_NULL:
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
|
|
|
|
case VT_EMPTY:
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
|
|
|
case VT_BSTR:
|
|
|
|
str = V_BSTR(arg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
hres = to_string(arg, &conv_str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
str = conv_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!SysStringLen(str) || *str >= 0x100)
|
|
|
|
hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
|
|
|
else if(res)
|
|
|
|
hres = return_short(res, *str);
|
|
|
|
SysFreeString(conv_str);
|
|
|
|
return hres;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2014-05-19 16:44:02 +02:00
|
|
|
/* The function supports only single-byte and double-byte character sets. It
|
|
|
|
* ignores language specified by IActiveScriptSite::GetLCID. The argument needs
|
|
|
|
* to be in range of short or unsigned short. */
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Chr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-05-19 16:44:02 +02:00
|
|
|
int cp, c, len = 0;
|
|
|
|
CPINFO cpi;
|
|
|
|
WCHAR ch;
|
|
|
|
char buf[2];
|
2012-10-15 11:15:51 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_int(arg, &c);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2014-05-19 16:44:02 +02:00
|
|
|
cp = GetACP();
|
|
|
|
if(!GetCPInfo(cp, &cpi))
|
|
|
|
cpi.MaxCharSize = 1;
|
|
|
|
|
|
|
|
if((c!=(short)c && c!=(unsigned short)c) ||
|
|
|
|
(unsigned short)c>=(cpi.MaxCharSize>1 ? 0x10000 : 0x100)) {
|
2014-04-23 17:49:23 +02:00
|
|
|
WARN("invalid arg %d\n", c);
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
2012-10-15 11:15:51 +02:00
|
|
|
}
|
|
|
|
|
2014-05-19 16:44:02 +02:00
|
|
|
if(c>>8)
|
|
|
|
buf[len++] = c>>8;
|
|
|
|
if(!len || IsDBCSLeadByteEx(cp, buf[0]))
|
|
|
|
buf[len++] = c;
|
2015-03-08 11:51:37 +01:00
|
|
|
if(!MultiByteToWideChar(CP_ACP, 0, buf, len, &ch, 1)) {
|
2014-05-19 16:44:02 +02:00
|
|
|
WARN("invalid arg %d, cp %d\n", c, cp);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2012-10-15 11:15:51 +02:00
|
|
|
|
2014-05-19 16:44:02 +02:00
|
|
|
if(res) {
|
2012-10-15 11:15:51 +02:00
|
|
|
V_VT(res) = VT_BSTR;
|
|
|
|
V_BSTR(res) = SysAllocStringLen(&ch, 1);
|
|
|
|
if(!V_BSTR(res))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_AscW(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_ChrW(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Abs(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-07-15 17:02:55 +02:00
|
|
|
HRESULT hres;
|
|
|
|
VARIANT dst;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
hres = VarAbs(arg, &dst);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
*res = dst;
|
|
|
|
else
|
|
|
|
VariantClear(&dst);
|
|
|
|
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Fix(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-14 16:46:51 +02:00
|
|
|
HRESULT hres;
|
|
|
|
VARIANT dst;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
hres = VarFix(arg, &dst);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
*res = dst;
|
|
|
|
else
|
|
|
|
VariantClear(&dst);
|
|
|
|
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Int(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-14 16:47:30 +02:00
|
|
|
HRESULT hres;
|
|
|
|
VARIANT dst;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
hres = VarInt(arg, &dst);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
*res = dst;
|
|
|
|
else
|
|
|
|
VariantClear(&dst);
|
|
|
|
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Sgn(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-07-11 05:47:45 +02:00
|
|
|
double v;
|
|
|
|
short val;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
if(V_VT(arg) == VT_NULL)
|
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
|
|
|
|
|
|
|
|
hres = to_double(arg, &v);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
val = v == 0 ? 0 : (v > 0 ? 1 : -1);
|
|
|
|
return return_short(res, val);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Now(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-09-28 11:49:30 +02:00
|
|
|
SYSTEMTIME lt;
|
|
|
|
double date;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
GetLocalTime(<);
|
|
|
|
SystemTimeToVariantTime(<, &date);
|
|
|
|
return return_date(res, date);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Date(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-25 18:07:51 +02:00
|
|
|
SYSTEMTIME lt;
|
|
|
|
UDATE ud;
|
|
|
|
DATE date;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
GetLocalTime(<);
|
|
|
|
ud.st = lt;
|
|
|
|
ud.wDayOfYear = 0;
|
|
|
|
hres = VarDateFromUdateEx(&ud, 0, VAR_DATEVALUEONLY, &date);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
return return_date(res, date);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Time(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-25 18:08:27 +02:00
|
|
|
SYSTEMTIME lt;
|
|
|
|
UDATE ud;
|
|
|
|
DATE time;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
GetLocalTime(<);
|
|
|
|
ud.st = lt;
|
|
|
|
ud.wDayOfYear = 0;
|
|
|
|
hres = VarDateFromUdateEx(&ud, 0, VAR_TIMEVALUEONLY, &time);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
return return_date(res, time);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Day(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-09-30 20:19:31 +02:00
|
|
|
SYSTEMTIME st;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_system_time(arg, &st);
|
|
|
|
return FAILED(hres) ? hres : return_short(res, st.wDay);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Month(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-09-30 20:19:38 +02:00
|
|
|
SYSTEMTIME st;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_system_time(arg, &st);
|
|
|
|
return FAILED(hres) ? hres : return_short(res, st.wMonth);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Weekday(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Year(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-09-30 20:19:44 +02:00
|
|
|
SYSTEMTIME st;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_system_time(arg, &st);
|
|
|
|
return FAILED(hres) ? hres : return_short(res, st.wYear);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Hour(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-09-30 20:19:51 +02:00
|
|
|
SYSTEMTIME st;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_system_time(arg, &st);
|
|
|
|
return FAILED(hres) ? hres : return_short(res, st.wHour);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Minute(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-09-30 20:20:01 +02:00
|
|
|
SYSTEMTIME st;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_system_time(arg, &st);
|
|
|
|
return FAILED(hres) ? hres : return_short(res, st.wMinute);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Second(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2019-09-30 20:20:07 +02:00
|
|
|
SYSTEMTIME st;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_system_time(arg, &st);
|
|
|
|
return FAILED(hres) ? hres : return_short(res, st.wSecond);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_DateValue(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_TimeValue(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_DateSerial(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_TimeSerial(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_InputBox(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_MsgBox(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-07-23 18:28:28 +02:00
|
|
|
BSTR prompt, title = NULL;
|
|
|
|
int type = MB_OK;
|
2012-09-26 14:36:45 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2014-07-23 18:28:28 +02:00
|
|
|
assert(1 <= args_cnt && args_cnt <= 5);
|
2012-09-26 14:36:45 +02:00
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_string(args, &prompt);
|
2012-09-26 14:36:45 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2014-07-23 18:28:28 +02:00
|
|
|
if(args_cnt > 1)
|
|
|
|
hres = to_int(args+1, &type);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres) && args_cnt > 2)
|
|
|
|
hres = to_string(args+2, &title);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres) && args_cnt > 3) {
|
|
|
|
FIXME("unsupported arg_cnt %d\n", args_cnt);
|
|
|
|
hres = E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = show_msgbox(This->desc->ctx, prompt, type, title, res);
|
|
|
|
|
2012-09-26 14:36:45 +02:00
|
|
|
SysFreeString(prompt);
|
2014-07-23 18:28:28 +02:00
|
|
|
SysFreeString(title);
|
2012-09-26 14:36:45 +02:00
|
|
|
return hres;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_CreateObject(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2011-09-22 14:25:27 +02:00
|
|
|
IUnknown *obj;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(V_VT(arg) != VT_BSTR) {
|
|
|
|
FIXME("non-bstr arg\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = create_object(This->desc->ctx, V_BSTR(arg));
|
|
|
|
if(!obj)
|
|
|
|
return VB_E_CANNOT_CREATE_OBJ;
|
|
|
|
|
|
|
|
if(res) {
|
|
|
|
hres = IUnknown_QueryInterface(obj, &IID_IDispatch, (void**)&V_DISPATCH(res));
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
V_VT(res) = VT_DISPATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_Release(obj);
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_GetObject(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2013-01-24 12:26:54 +01:00
|
|
|
IBindCtx *bind_ctx;
|
|
|
|
IUnknown *obj_unk;
|
|
|
|
IDispatch *disp;
|
|
|
|
ULONG eaten = 0;
|
|
|
|
IMoniker *mon;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s %s\n", args_cnt ? debugstr_variant(args) : "", args_cnt > 1 ? debugstr_variant(args+1) : "");
|
|
|
|
|
|
|
|
if(args_cnt != 1 || V_VT(args) != VT_BSTR) {
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->desc->ctx->safeopt & (INTERFACE_USES_SECURITY_MANAGER|INTERFACESAFE_FOR_UNTRUSTED_DATA)) {
|
|
|
|
WARN("blocked in current safety mode\n");
|
|
|
|
return VB_E_CANNOT_CREATE_OBJ;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = CreateBindCtx(0, &bind_ctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = MkParseDisplayName(bind_ctx, V_BSTR(args), &eaten, &mon);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IMoniker_BindToObject(mon, bind_ctx, NULL, &IID_IUnknown, (void**)&obj_unk);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
}else {
|
|
|
|
hres = MK_E_SYNTAX;
|
|
|
|
}
|
|
|
|
IBindCtx_Release(bind_ctx);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = set_object_site(This->desc->ctx, obj_unk);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
IUnknown_Release(obj_unk);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(obj_unk, &IID_IDispatch, (void**)&disp);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(res) = disp;
|
|
|
|
}else {
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
FIXME("object does not support IDispatch\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_DateAdd(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_DateDiff(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_DatePart(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_TypeName(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-06-25 04:16:07 +02:00
|
|
|
static const WCHAR ByteW[] = {'B', 'y', 't', 'e', 0};
|
|
|
|
static const WCHAR IntegerW[] = {'I', 'n', 't', 'e', 'g', 'e', 'r', 0};
|
|
|
|
static const WCHAR LongW[] = {'L', 'o', 'n', 'g', 0};
|
|
|
|
static const WCHAR SingleW[] = {'S', 'i', 'n', 'g', 'l', 'e', 0};
|
|
|
|
static const WCHAR DoubleW[] = {'D', 'o', 'u', 'b', 'l', 'e', 0};
|
|
|
|
static const WCHAR CurrencyW[] = {'C', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 0};
|
|
|
|
static const WCHAR DecimalW[] = {'D', 'e', 'c', 'i', 'm', 'a', 'l', 0};
|
|
|
|
static const WCHAR DateW[] = {'D', 'a', 't', 'e', 0};
|
|
|
|
static const WCHAR StringW[] = {'S', 't', 'r', 'i', 'n', 'g', 0};
|
|
|
|
static const WCHAR BooleanW[] = {'B', 'o', 'o', 'l', 'e', 'a', 'n', 0};
|
|
|
|
static const WCHAR EmptyW[] = {'E', 'm', 'p', 't', 'y', 0};
|
|
|
|
static const WCHAR NullW[] = {'N', 'u', 'l', 'l', 0};
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 1);
|
|
|
|
|
|
|
|
switch(V_VT(arg)) {
|
|
|
|
case VT_UI1:
|
|
|
|
return return_string(res, ByteW);
|
|
|
|
case VT_I2:
|
|
|
|
return return_string(res, IntegerW);
|
|
|
|
case VT_I4:
|
|
|
|
return return_string(res, LongW);
|
|
|
|
case VT_R4:
|
|
|
|
return return_string(res, SingleW);
|
|
|
|
case VT_R8:
|
|
|
|
return return_string(res, DoubleW);
|
|
|
|
case VT_CY:
|
|
|
|
return return_string(res, CurrencyW);
|
|
|
|
case VT_DECIMAL:
|
|
|
|
return return_string(res, DecimalW);
|
|
|
|
case VT_DATE:
|
|
|
|
return return_string(res, DateW);
|
|
|
|
case VT_BSTR:
|
|
|
|
return return_string(res, StringW);
|
|
|
|
case VT_BOOL:
|
|
|
|
return return_string(res, BooleanW);
|
|
|
|
case VT_EMPTY:
|
|
|
|
return return_string(res, EmptyW);
|
|
|
|
case VT_NULL:
|
|
|
|
return return_string(res, NullW);
|
|
|
|
default:
|
|
|
|
FIXME("arg %s not supported\n", debugstr_variant(arg));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Array(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2017-10-10 17:07:50 +02:00
|
|
|
SAFEARRAYBOUND bounds;
|
|
|
|
SAFEARRAY *sa;
|
|
|
|
VARIANT *data;
|
|
|
|
HRESULT hres;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
TRACE("arg_cnt=%u\n", args_cnt);
|
|
|
|
|
|
|
|
bounds.lLbound = 0;
|
|
|
|
bounds.cElements = args_cnt;
|
|
|
|
sa = SafeArrayCreate(VT_VARIANT, 1, &bounds);
|
|
|
|
if(!sa)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hres = SafeArrayAccessData(sa, (void**)&data);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SafeArrayDestroy(sa);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i<args_cnt; i++) {
|
|
|
|
hres = VariantCopyInd(data+i, arg+i);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SafeArrayUnaccessData(sa);
|
|
|
|
SafeArrayDestroy(sa);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SafeArrayUnaccessData(sa);
|
|
|
|
|
|
|
|
if(res) {
|
|
|
|
V_VT(res) = VT_ARRAY|VT_VARIANT;
|
|
|
|
V_ARRAY(res) = sa;
|
|
|
|
}else {
|
|
|
|
SafeArrayDestroy(sa);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Erase(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Filter(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Join(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Split(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Replace(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_StrReverse(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-09-28 11:49:48 +02:00
|
|
|
WCHAR *ptr1, *ptr2, ch;
|
|
|
|
BSTR ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
hres = to_string(arg, &ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
ptr1 = ret;
|
|
|
|
ptr2 = ret + SysStringLen(ret)-1;
|
|
|
|
while(ptr1 < ptr2) {
|
|
|
|
ch = *ptr1;
|
|
|
|
*ptr1++ = *ptr2;
|
|
|
|
*ptr2-- = ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_bstr(res, ret);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_InStrRev(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2015-02-10 18:46:25 +01:00
|
|
|
int start, ret = 0;
|
|
|
|
BSTR str1, str2;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s %s arg_cnt=%u\n", debugstr_variant(args), debugstr_variant(args+1), args_cnt);
|
|
|
|
|
|
|
|
if(args_cnt > 3) {
|
|
|
|
FIXME("Unsupported args\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(2 <= args_cnt && args_cnt <= 4);
|
|
|
|
|
2015-05-23 18:58:00 +02:00
|
|
|
if(V_VT(args) == VT_NULL || V_VT(args+1) == VT_NULL || (args_cnt > 2 && V_VT(args+2) == VT_NULL))
|
2015-02-10 18:46:25 +01:00
|
|
|
return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);
|
|
|
|
|
|
|
|
hres = to_string(args, &str1);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = to_string(args+1, &str2);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
if(args_cnt > 2) {
|
|
|
|
hres = to_int(args+2, &start);
|
|
|
|
if(SUCCEEDED(hres) && start <= 0) {
|
|
|
|
FIXME("Unsupported start %d\n", start);
|
|
|
|
hres = E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
start = SysStringLen(str1);
|
|
|
|
}
|
2015-02-16 02:11:40 +01:00
|
|
|
} else {
|
|
|
|
str2 = NULL;
|
2015-02-10 18:46:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
const WCHAR *ptr;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
len = SysStringLen(str2);
|
|
|
|
if(start >= len && start <= SysStringLen(str1)) {
|
|
|
|
for(ptr = str1+start-SysStringLen(str2); ptr >= str1; ptr--) {
|
|
|
|
if(!memcmp(ptr, str2, len*sizeof(WCHAR))) {
|
|
|
|
ret = ptr-str1+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString(str1);
|
|
|
|
SysFreeString(str2);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_int(res, ret);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_LoadPicture(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_ScriptEngine(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-08 18:47:46 +02:00
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 0);
|
|
|
|
|
|
|
|
return return_string(res, vbscriptW);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_ScriptEngineMajorVersion(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-08 18:49:52 +02:00
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 0);
|
|
|
|
|
2014-09-22 15:52:13 +02:00
|
|
|
return return_int(res, VBSCRIPT_MAJOR_VERSION);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_ScriptEngineMinorVersion(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-08 18:52:28 +02:00
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 0);
|
|
|
|
|
2014-09-22 15:52:13 +02:00
|
|
|
return return_int(res, VBSCRIPT_MINOR_VERSION);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_ScriptEngineBuildVersion(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2014-08-08 18:49:05 +02:00
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
assert(args_cnt == 0);
|
|
|
|
|
2014-09-22 15:52:13 +02:00
|
|
|
return return_int(res, VBSCRIPT_BUILD_VERSION);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_FormatNumber(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_FormatCurrency(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_FormatPercent(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_FormatDateTime(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_WeekdayName(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-10-31 13:06:23 +01:00
|
|
|
int weekday, first_day = 1, abbrev = 0;
|
2012-09-27 13:10:49 +02:00
|
|
|
BSTR ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
assert(1 <= args_cnt && args_cnt <= 3);
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_int(args, &weekday);
|
2012-09-27 13:10:49 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(args_cnt > 1) {
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_int(args+1, &abbrev);
|
2012-09-27 13:10:49 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(args_cnt == 3) {
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_int(args+2, &first_day);
|
2012-09-27 13:10:49 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = VarWeekdayName(weekday, abbrev, first_day, 0, &ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_bstr(res, ret);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_MonthName(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-09-27 13:11:08 +02:00
|
|
|
int month, abbrev = 0;
|
|
|
|
BSTR ret;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
assert(args_cnt == 1 || args_cnt == 2);
|
|
|
|
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_int(args, &month);
|
2012-09-27 13:11:08 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(args_cnt == 2) {
|
2012-10-17 09:54:12 +02:00
|
|
|
hres = to_int(args+1, &abbrev);
|
2012-09-27 13:11:08 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = VarMonthName(month, abbrev, 0, &ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
return return_bstr(res, ret);
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Round(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
2012-09-26 14:36:01 +02:00
|
|
|
double n;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_variant(arg));
|
|
|
|
|
|
|
|
if(!res)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
switch(V_VT(arg)) {
|
|
|
|
case VT_I2:
|
|
|
|
case VT_I4:
|
|
|
|
case VT_BOOL:
|
|
|
|
*res = *arg;
|
|
|
|
return S_OK;
|
|
|
|
case VT_R8:
|
|
|
|
n = V_R8(arg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
hres = to_double(arg, &n);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_double(res, round(n));
|
2011-09-19 14:09:08 +02:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Escape(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Unescape(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Eval(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_Execute(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_ExecuteGlobal(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Global_GetRef(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
|
2011-09-19 14:09:08 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-02-27 12:56:05 +01:00
|
|
|
static const string_constant_t vbCr = {1, {'\r'}};
|
|
|
|
static const string_constant_t vbCrLf = {2, {'\r','\n'}};
|
|
|
|
static const string_constant_t vbNewLine = {2, {'\r','\n'}};
|
|
|
|
static const string_constant_t vbFormFeed = {1, {0xc}};
|
|
|
|
static const string_constant_t vbLf = {1, {'\n'}};
|
|
|
|
static const string_constant_t vbNullChar = {1};
|
|
|
|
static const string_constant_t vbNullString = {0};
|
|
|
|
static const string_constant_t vbTab = {1, {'\t'}};
|
|
|
|
static const string_constant_t vbVerticalTab = {1, {0xb}};
|
2011-09-19 14:09:08 +02:00
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
static const builtin_prop_t global_props[] = {
|
2013-02-27 12:55:19 +01:00
|
|
|
{DISPID_GLOBAL_VBUSESYSTEM, NULL, BP_GET, VT_I2, 0},
|
|
|
|
{DISPID_GLOBAL_USESYSTEMDAYOFWEEK, NULL, BP_GET, VT_I2, 0},
|
|
|
|
{DISPID_GLOBAL_VBSUNDAY, NULL, BP_GET, VT_I2, 1},
|
|
|
|
{DISPID_GLOBAL_VBMONDAY, NULL, BP_GET, VT_I2, 2},
|
|
|
|
{DISPID_GLOBAL_VBTUESDAY, NULL, BP_GET, VT_I2, 3},
|
|
|
|
{DISPID_GLOBAL_VBWEDNESDAY, NULL, BP_GET, VT_I2, 4},
|
|
|
|
{DISPID_GLOBAL_VBTHURSDAY, NULL, BP_GET, VT_I2, 5},
|
|
|
|
{DISPID_GLOBAL_VBFRIDAY, NULL, BP_GET, VT_I2, 6},
|
|
|
|
{DISPID_GLOBAL_VBSATURDAY, NULL, BP_GET, VT_I2, 7},
|
|
|
|
{DISPID_GLOBAL_VBFIRSTJAN1, NULL, BP_GET, VT_I2, 1},
|
|
|
|
{DISPID_GLOBAL_VBFIRSTFOURDAYS, NULL, BP_GET, VT_I2, 2},
|
|
|
|
{DISPID_GLOBAL_VBFIRSTFULLWEEK, NULL, BP_GET, VT_I2, 3},
|
|
|
|
{DISPID_GLOBAL_VBOKONLY, NULL, BP_GET, VT_I2, MB_OK},
|
|
|
|
{DISPID_GLOBAL_VBOKCANCEL, NULL, BP_GET, VT_I2, MB_OKCANCEL},
|
|
|
|
{DISPID_GLOBAL_VBABORTRETRYIGNORE, NULL, BP_GET, VT_I2, MB_ABORTRETRYIGNORE},
|
|
|
|
{DISPID_GLOBAL_VBYESNOCANCEL, NULL, BP_GET, VT_I2, MB_YESNOCANCEL},
|
|
|
|
{DISPID_GLOBAL_VBYESNO, NULL, BP_GET, VT_I2, MB_YESNO},
|
|
|
|
{DISPID_GLOBAL_VBRETRYCANCEL, NULL, BP_GET, VT_I2, MB_RETRYCANCEL},
|
|
|
|
{DISPID_GLOBAL_VBCRITICAL, NULL, BP_GET, VT_I2, MB_ICONHAND},
|
|
|
|
{DISPID_GLOBAL_VBQUESTION, NULL, BP_GET, VT_I2, MB_ICONQUESTION},
|
|
|
|
{DISPID_GLOBAL_VBEXCLAMATION, NULL, BP_GET, VT_I2, MB_ICONEXCLAMATION},
|
|
|
|
{DISPID_GLOBAL_VBINFORMATION, NULL, BP_GET, VT_I2, MB_ICONASTERISK},
|
|
|
|
{DISPID_GLOBAL_VBDEFAULTBUTTON1, NULL, BP_GET, VT_I2, MB_DEFBUTTON1},
|
|
|
|
{DISPID_GLOBAL_VBDEFAULTBUTTON2, NULL, BP_GET, VT_I2, MB_DEFBUTTON2},
|
|
|
|
{DISPID_GLOBAL_VBDEFAULTBUTTON3, NULL, BP_GET, VT_I2, MB_DEFBUTTON3},
|
|
|
|
{DISPID_GLOBAL_VBDEFAULTBUTTON4, NULL, BP_GET, VT_I2, MB_DEFBUTTON4},
|
|
|
|
{DISPID_GLOBAL_VBAPPLICATIONMODAL, NULL, BP_GET, VT_I2, MB_APPLMODAL},
|
|
|
|
{DISPID_GLOBAL_VBSYSTEMMODAL, NULL, BP_GET, VT_I2, MB_SYSTEMMODAL},
|
|
|
|
{DISPID_GLOBAL_VBOK, NULL, BP_GET, VT_I2, IDOK},
|
|
|
|
{DISPID_GLOBAL_VBCANCEL, NULL, BP_GET, VT_I2, IDCANCEL},
|
|
|
|
{DISPID_GLOBAL_VBABORT, NULL, BP_GET, VT_I2, IDABORT},
|
|
|
|
{DISPID_GLOBAL_VBRETRY, NULL, BP_GET, VT_I2, IDRETRY},
|
|
|
|
{DISPID_GLOBAL_VBIGNORE, NULL, BP_GET, VT_I2, IDIGNORE},
|
|
|
|
{DISPID_GLOBAL_VBYES, NULL, BP_GET, VT_I2, IDYES},
|
|
|
|
{DISPID_GLOBAL_VBNO, NULL, BP_GET, VT_I2, IDNO},
|
|
|
|
{DISPID_GLOBAL_VBEMPTY, NULL, BP_GET, VT_I2, VT_EMPTY},
|
|
|
|
{DISPID_GLOBAL_VBNULL, NULL, BP_GET, VT_I2, VT_NULL},
|
|
|
|
{DISPID_GLOBAL_VBINTEGER, NULL, BP_GET, VT_I2, VT_I2},
|
|
|
|
{DISPID_GLOBAL_VBLONG, NULL, BP_GET, VT_I2, VT_I4},
|
|
|
|
{DISPID_GLOBAL_VBSINGLE, NULL, BP_GET, VT_I2, VT_R4},
|
|
|
|
{DISPID_GLOBAL_VBDOUBLE, NULL, BP_GET, VT_I2, VT_R8},
|
|
|
|
{DISPID_GLOBAL_VBCURRENCY, NULL, BP_GET, VT_I2, VT_CY},
|
|
|
|
{DISPID_GLOBAL_VBDATE, NULL, BP_GET, VT_I2, VT_DATE},
|
|
|
|
{DISPID_GLOBAL_VBSTRING, NULL, BP_GET, VT_I2, VT_BSTR},
|
|
|
|
{DISPID_GLOBAL_VBOBJECT, NULL, BP_GET, VT_I2, VT_DISPATCH},
|
|
|
|
{DISPID_GLOBAL_VBERROR, NULL, BP_GET, VT_I2, VT_ERROR},
|
|
|
|
{DISPID_GLOBAL_VBBOOLEAN, NULL, BP_GET, VT_I2, VT_BOOL},
|
|
|
|
{DISPID_GLOBAL_VBVARIANT, NULL, BP_GET, VT_I2, VT_VARIANT},
|
|
|
|
{DISPID_GLOBAL_VBDATAOBJECT, NULL, BP_GET, VT_I2, VT_UNKNOWN},
|
|
|
|
{DISPID_GLOBAL_VBDECIMAL, NULL, BP_GET, VT_I2, VT_DECIMAL},
|
|
|
|
{DISPID_GLOBAL_VBBYTE, NULL, BP_GET, VT_I2, VT_UI1},
|
|
|
|
{DISPID_GLOBAL_VBARRAY, NULL, BP_GET, VT_I2, VT_ARRAY},
|
|
|
|
{DISPID_GLOBAL_VBTRUE, NULL, BP_GET, VT_I2, VARIANT_TRUE},
|
|
|
|
{DISPID_GLOBAL_VBFALSE, NULL, BP_GET, VT_I2, VARIANT_FALSE},
|
|
|
|
{DISPID_GLOBAL_VBUSEDEFAULT, NULL, BP_GET, VT_I2, -2},
|
|
|
|
{DISPID_GLOBAL_VBBINARYCOMPARE, NULL, BP_GET, VT_I2, 0},
|
|
|
|
{DISPID_GLOBAL_VBTEXTCOMPARE, NULL, BP_GET, VT_I2, 1},
|
|
|
|
{DISPID_GLOBAL_VBDATABASECOMPARE, NULL, BP_GET, VT_I2, 2},
|
|
|
|
{DISPID_GLOBAL_VBGENERALDATE, NULL, BP_GET, VT_I2, 0},
|
|
|
|
{DISPID_GLOBAL_VBLONGDATE, NULL, BP_GET, VT_I2, 1},
|
|
|
|
{DISPID_GLOBAL_VBSHORTDATE, NULL, BP_GET, VT_I2, 2},
|
|
|
|
{DISPID_GLOBAL_VBLONGTIME, NULL, BP_GET, VT_I2, 3},
|
|
|
|
{DISPID_GLOBAL_VBSHORTTIME, NULL, BP_GET, VT_I2, 4},
|
|
|
|
{DISPID_GLOBAL_VBOBJECTERROR, NULL, BP_GET, VT_I4, 0x80040000},
|
2013-02-27 12:55:32 +01:00
|
|
|
{DISPID_GLOBAL_VBBLACK, NULL, BP_GET, VT_I4, 0x000000},
|
|
|
|
{DISPID_GLOBAL_VBBLUE, NULL, BP_GET, VT_I4, 0xff0000},
|
|
|
|
{DISPID_GLOBAL_VBCYAN, NULL, BP_GET, VT_I4, 0xffff00},
|
|
|
|
{DISPID_GLOBAL_VBGREEN, NULL, BP_GET, VT_I4, 0x00ff00},
|
|
|
|
{DISPID_GLOBAL_VBMAGENTA, NULL, BP_GET, VT_I4, 0xff00ff},
|
|
|
|
{DISPID_GLOBAL_VBRED, NULL, BP_GET, VT_I4, 0x0000ff},
|
|
|
|
{DISPID_GLOBAL_VBWHITE, NULL, BP_GET, VT_I4, 0xffffff},
|
|
|
|
{DISPID_GLOBAL_VBYELLOW, NULL, BP_GET, VT_I4, 0x00ffff},
|
2013-02-27 12:56:05 +01:00
|
|
|
{DISPID_GLOBAL_VBCR, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbCr},
|
|
|
|
{DISPID_GLOBAL_VBCRLF, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbCrLf},
|
|
|
|
{DISPID_GLOBAL_VBNEWLINE, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbNewLine},
|
|
|
|
{DISPID_GLOBAL_VBFORMFEED, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbFormFeed},
|
|
|
|
{DISPID_GLOBAL_VBLF, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbLf},
|
|
|
|
{DISPID_GLOBAL_VBNULLCHAR, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbNullChar},
|
|
|
|
{DISPID_GLOBAL_VBNULLSTRING, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbNullString},
|
|
|
|
{DISPID_GLOBAL_VBTAB, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbTab},
|
|
|
|
{DISPID_GLOBAL_VBVERTICALTAB, NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbVerticalTab},
|
2011-09-19 14:09:08 +02:00
|
|
|
{DISPID_GLOBAL_CCUR, Global_CCur, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CINT, Global_CInt, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CLNG, Global_CLng, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CBOOL, Global_CBool, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CBYTE, Global_CByte, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CDATE, Global_CDate, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CDBL, Global_CDbl, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CSNG, Global_CSng, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CSTR, Global_CStr, 0, 1},
|
|
|
|
{DISPID_GLOBAL_HEX, Global_Hex, 0, 1},
|
|
|
|
{DISPID_GLOBAL_OCT, Global_Oct, 0, 1},
|
|
|
|
{DISPID_GLOBAL_VARTYPE, Global_VarType, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ISDATE, Global_IsDate, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ISEMPTY, Global_IsEmpty, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ISNULL, Global_IsNull, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ISNUMERIC, Global_IsNumeric, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ISARRAY, Global_IsArray, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ISOBJECT, Global_IsObject, 0, 1},
|
2014-08-18 17:12:23 +02:00
|
|
|
{DISPID_GLOBAL_ATN, Global_Atn, 0, 1},
|
2011-09-19 14:09:08 +02:00
|
|
|
{DISPID_GLOBAL_COS, Global_Cos, 0, 1},
|
|
|
|
{DISPID_GLOBAL_SIN, Global_Sin, 0, 1},
|
|
|
|
{DISPID_GLOBAL_TAN, Global_Tan, 0, 1},
|
|
|
|
{DISPID_GLOBAL_EXP, Global_Exp, 0, 1},
|
|
|
|
{DISPID_GLOBAL_LOG, Global_Log, 0, 1},
|
|
|
|
{DISPID_GLOBAL_SQR, Global_Sqr, 0, 1},
|
|
|
|
{DISPID_GLOBAL_RANDOMIZE, Global_Randomize, 0, 1},
|
|
|
|
{DISPID_GLOBAL_RND, Global_Rnd, 0, 1},
|
|
|
|
{DISPID_GLOBAL_TIMER, Global_Timer, 0, 0},
|
|
|
|
{DISPID_GLOBAL_LBOUND, Global_LBound, 0, 1},
|
2017-11-06 16:53:08 +01:00
|
|
|
{DISPID_GLOBAL_UBOUND, Global_UBound, 0, 1, 2},
|
2011-09-19 14:09:08 +02:00
|
|
|
{DISPID_GLOBAL_RGB, Global_RGB, 0, 3},
|
|
|
|
{DISPID_GLOBAL_LEN, Global_Len, 0, 1},
|
|
|
|
{DISPID_GLOBAL_LENB, Global_LenB, 0, 1},
|
|
|
|
{DISPID_GLOBAL_LEFT, Global_Left, 0, 2},
|
|
|
|
{DISPID_GLOBAL_LEFTB, Global_LeftB, 0, 2},
|
|
|
|
{DISPID_GLOBAL_RIGHT, Global_Right, 0, 2},
|
|
|
|
{DISPID_GLOBAL_RIGHTB, Global_RightB, 0, 2},
|
|
|
|
{DISPID_GLOBAL_MID, Global_Mid, 0, 2, 3},
|
|
|
|
{DISPID_GLOBAL_MIDB, Global_MidB, 0, 2, 3},
|
|
|
|
{DISPID_GLOBAL_STRCOMP, Global_StrComp, 0, 2, 3},
|
|
|
|
{DISPID_GLOBAL_LCASE, Global_LCase, 0, 1},
|
|
|
|
{DISPID_GLOBAL_UCASE, Global_UCase, 0, 1},
|
|
|
|
{DISPID_GLOBAL_LTRIM, Global_LTrim, 0, 1},
|
|
|
|
{DISPID_GLOBAL_RTRIM, Global_RTrim, 0, 1},
|
|
|
|
{DISPID_GLOBAL_TRIM, Global_Trim, 0, 1},
|
|
|
|
{DISPID_GLOBAL_SPACE, Global_Space, 0, 1},
|
|
|
|
{DISPID_GLOBAL_STRING, Global_String, 0, 0, 2},
|
2011-12-30 17:00:12 +01:00
|
|
|
{DISPID_GLOBAL_INSTR, Global_InStr, 0, 2, 4},
|
2011-09-19 14:09:08 +02:00
|
|
|
{DISPID_GLOBAL_INSTRB, Global_InStrB, 0, 3, 4},
|
|
|
|
{DISPID_GLOBAL_ASCB, Global_AscB, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CHRB, Global_ChrB, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ASC, Global_Asc, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CHR, Global_Chr, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ASCW, Global_AscW, 0, 1},
|
|
|
|
{DISPID_GLOBAL_CHRW, Global_ChrW, 0, 1},
|
|
|
|
{DISPID_GLOBAL_ABS, Global_Abs, 0, 1},
|
|
|
|
{DISPID_GLOBAL_FIX, Global_Fix, 0, 1},
|
|
|
|
{DISPID_GLOBAL_INT, Global_Int, 0, 1},
|
|
|
|
{DISPID_GLOBAL_SGN, Global_Sgn, 0, 1},
|
|
|
|
{DISPID_GLOBAL_NOW, Global_Now, 0, 0},
|
|
|
|
{DISPID_GLOBAL_DATE, Global_Date, 0, 0},
|
|
|
|
{DISPID_GLOBAL_TIME, Global_Time, 0, 0},
|
|
|
|
{DISPID_GLOBAL_DAY, Global_Day, 0, 1},
|
|
|
|
{DISPID_GLOBAL_MONTH, Global_Month, 0, 1},
|
|
|
|
{DISPID_GLOBAL_WEEKDAY, Global_Weekday, 0, 1, 2},
|
|
|
|
{DISPID_GLOBAL_YEAR, Global_Year, 0, 1},
|
|
|
|
{DISPID_GLOBAL_HOUR, Global_Hour, 0, 1},
|
|
|
|
{DISPID_GLOBAL_MINUTE, Global_Minute, 0, 1},
|
|
|
|
{DISPID_GLOBAL_SECOND, Global_Second, 0, 1},
|
|
|
|
{DISPID_GLOBAL_DATEVALUE, Global_DateValue, 0, 1},
|
|
|
|
{DISPID_GLOBAL_TIMEVALUE, Global_TimeValue, 0, 1},
|
|
|
|
{DISPID_GLOBAL_DATESERIAL, Global_DateSerial, 0, 3},
|
|
|
|
{DISPID_GLOBAL_TIMESERIAL, Global_TimeSerial, 0, 3},
|
|
|
|
{DISPID_GLOBAL_INPUTBOX, Global_InputBox, 0, 1, 7},
|
|
|
|
{DISPID_GLOBAL_MSGBOX, Global_MsgBox, 0, 1, 5},
|
|
|
|
{DISPID_GLOBAL_CREATEOBJECT, Global_CreateObject, 0, 1},
|
|
|
|
{DISPID_GLOBAL_GETOBJECT, Global_GetObject, 0, 0, 2},
|
|
|
|
{DISPID_GLOBAL_DATEADD, Global_DateAdd, 0, 3},
|
|
|
|
{DISPID_GLOBAL_DATEDIFF, Global_DateDiff, 0, 3, 5},
|
|
|
|
{DISPID_GLOBAL_DATEPART, Global_DatePart, 0, 2, 4},
|
|
|
|
{DISPID_GLOBAL_TYPENAME, Global_TypeName, 0, 1},
|
2017-10-10 17:07:50 +02:00
|
|
|
{DISPID_GLOBAL_ARRAY, Global_Array, 0, 0, MAXDWORD},
|
2011-09-19 14:09:08 +02:00
|
|
|
{DISPID_GLOBAL_ERASE, Global_Erase, 0, 1},
|
|
|
|
{DISPID_GLOBAL_FILTER, Global_Filter, 0, 2, 4},
|
|
|
|
{DISPID_GLOBAL_JOIN, Global_Join, 0, 1, 2},
|
|
|
|
{DISPID_GLOBAL_SPLIT, Global_Split, 0, 1, 4},
|
|
|
|
{DISPID_GLOBAL_REPLACE, Global_Replace, 0, 3, 6},
|
|
|
|
{DISPID_GLOBAL_STRREVERSE, Global_StrReverse, 0, 1},
|
|
|
|
{DISPID_GLOBAL_INSTRREV, Global_InStrRev, 0, 2, 4},
|
|
|
|
{DISPID_GLOBAL_LOADPICTURE, Global_LoadPicture, 0, 1},
|
|
|
|
{DISPID_GLOBAL_SCRIPTENGINE, Global_ScriptEngine, 0, 0},
|
|
|
|
{DISPID_GLOBAL_SCRIPTENGINEMAJORVERSION, Global_ScriptEngineMajorVersion, 0, 0},
|
|
|
|
{DISPID_GLOBAL_SCRIPTENGINEMINORVERSION, Global_ScriptEngineMinorVersion, 0, 0},
|
|
|
|
{DISPID_GLOBAL_SCRIPTENGINEBUILDVERSION, Global_ScriptEngineBuildVersion, 0, 0},
|
|
|
|
{DISPID_GLOBAL_FORMATNUMBER, Global_FormatNumber, 0, 1, 5},
|
|
|
|
{DISPID_GLOBAL_FORMATCURRENCY, Global_FormatCurrency, 0, 1, 5},
|
|
|
|
{DISPID_GLOBAL_FORMATPERCENT, Global_FormatPercent, 0, 1, 5},
|
|
|
|
{DISPID_GLOBAL_FORMATDATETIME, Global_FormatDateTime, 0, 1, 2},
|
2012-09-27 13:10:49 +02:00
|
|
|
{DISPID_GLOBAL_WEEKDAYNAME, Global_WeekdayName, 0, 1, 3},
|
2011-09-19 14:09:08 +02:00
|
|
|
{DISPID_GLOBAL_MONTHNAME, Global_MonthName, 0, 1, 2},
|
|
|
|
{DISPID_GLOBAL_ROUND, Global_Round, 0, 1, 2},
|
|
|
|
{DISPID_GLOBAL_ESCAPE, Global_Escape, 0, 1},
|
|
|
|
{DISPID_GLOBAL_UNESCAPE, Global_Unescape, 0, 1},
|
|
|
|
{DISPID_GLOBAL_EVAL, Global_Eval, 0, 1},
|
|
|
|
{DISPID_GLOBAL_EXECUTE, Global_Execute, 0, 1},
|
|
|
|
{DISPID_GLOBAL_EXECUTEGLOBAL, Global_ExecuteGlobal, 0, 1},
|
|
|
|
{DISPID_GLOBAL_GETREF, Global_GetRef, 0, 1},
|
2013-02-27 12:55:19 +01:00
|
|
|
{DISPID_GLOBAL_VBMSGBOXHELPBUTTON, NULL, BP_GET, VT_I4, MB_HELP},
|
|
|
|
{DISPID_GLOBAL_VBMSGBOXSETFOREGROUND, NULL, BP_GET, VT_I4, MB_SETFOREGROUND},
|
|
|
|
{DISPID_GLOBAL_VBMSGBOXRIGHT, NULL, BP_GET, VT_I4, MB_RIGHT},
|
|
|
|
{DISPID_GLOBAL_VBMSGBOXRTLREADING, NULL, BP_GET, VT_I4, MB_RTLREADING}
|
2011-09-19 14:08:38 +02:00
|
|
|
};
|
|
|
|
|
2019-10-03 18:18:51 +02:00
|
|
|
static HRESULT err_string_prop(BSTR *prop, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
|
|
|
{
|
|
|
|
BSTR str;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!args_cnt)
|
|
|
|
return return_string(res, *prop ? *prop : L"");
|
|
|
|
|
|
|
|
hres = to_string(args, &str);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
SysFreeString(*prop);
|
|
|
|
*prop = str;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Err_Description(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2014-03-21 14:36:45 +01:00
|
|
|
{
|
2019-10-03 18:18:51 +02:00
|
|
|
TRACE("\n");
|
|
|
|
return !This->desc ? E_UNEXPECTED : err_string_prop(&This->desc->ctx->ei.bstrDescription, args, args_cnt, res);
|
2014-03-21 14:36:45 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Err_HelpContext(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2014-03-21 14:36:45 +01:00
|
|
|
{
|
2019-10-03 18:19:11 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(!This->desc)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
if(args_cnt) {
|
|
|
|
FIXME("setter not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return return_int(res, This->desc->ctx->ei.dwHelpContext);
|
2014-03-21 14:36:45 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Err_HelpFile(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2014-03-21 14:36:45 +01:00
|
|
|
{
|
2019-10-03 18:19:11 +02:00
|
|
|
TRACE("\n");
|
|
|
|
return !This->desc ? E_UNEXPECTED : err_string_prop(&This->desc->ctx->ei.bstrHelpFile, args, args_cnt, res);
|
2014-03-21 14:36:45 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Err_Number(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2014-03-21 14:36:45 +01:00
|
|
|
{
|
2014-03-27 14:44:26 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
2014-03-21 14:38:11 +01:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(!This->desc)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
|
|
|
if(args_cnt) {
|
|
|
|
FIXME("setter not implemented\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-10-03 18:18:37 +02:00
|
|
|
hres = This->desc->ctx->ei.scode;
|
2014-03-27 14:44:26 +01:00
|
|
|
return return_int(res, HRESULT_FACILITY(hres) == FACILITY_VBS ? HRESULT_CODE(hres) : hres);
|
2014-03-21 14:36:45 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Err_Source(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2014-03-21 14:36:45 +01:00
|
|
|
{
|
2019-10-03 18:19:03 +02:00
|
|
|
TRACE("\n");
|
|
|
|
return !This->desc ? E_UNEXPECTED : err_string_prop(&This->desc->ctx->ei.bstrSource, args, args_cnt, res);
|
2014-03-21 14:36:45 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Err_Clear(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2014-03-21 14:36:45 +01:00
|
|
|
{
|
2014-03-21 14:38:33 +01:00
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if(!This->desc)
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
|
2019-10-03 18:18:37 +02:00
|
|
|
clear_ei(&This->desc->ctx->ei);
|
2014-03-21 14:38:33 +01:00
|
|
|
return S_OK;
|
2014-03-21 14:36:45 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
static HRESULT Err_Raise(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
|
2014-03-21 14:36:45 +01:00
|
|
|
{
|
2019-10-03 18:19:24 +02:00
|
|
|
BSTR source = NULL, description = NULL, helpfile = NULL;
|
|
|
|
int code, helpcontext = 0;
|
|
|
|
HRESULT hres, error;
|
|
|
|
|
|
|
|
TRACE("%s %u...\n", debugstr_variant(args), args_cnt);
|
|
|
|
|
|
|
|
hres = to_int(args, &code);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
if(code > 0 && code > 0xffff)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if(args_cnt >= 2)
|
|
|
|
hres = to_string(args + 1, &source);
|
|
|
|
if(args_cnt >= 3 && SUCCEEDED(hres))
|
|
|
|
hres = to_string(args + 2, &description);
|
|
|
|
if(args_cnt >= 4 && SUCCEEDED(hres))
|
|
|
|
hres = to_string(args + 3, &helpfile);
|
|
|
|
if(args_cnt >= 5 && SUCCEEDED(hres))
|
|
|
|
hres = to_int(args + 4, &helpcontext);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres) && This->desc) {
|
|
|
|
script_ctx_t *ctx = This->desc->ctx;
|
|
|
|
|
|
|
|
error = (code & ~0xffff) ? map_hres(code) : MAKE_VBSERROR(code);
|
|
|
|
|
|
|
|
if(source) {
|
|
|
|
if(ctx->ei.bstrSource) SysFreeString(ctx->ei.bstrSource);
|
|
|
|
ctx->ei.bstrSource = source;
|
|
|
|
}
|
|
|
|
if(!ctx->ei.bstrSource)
|
|
|
|
ctx->ei.bstrSource = get_vbscript_string(VBS_RUNTIME_ERROR);
|
|
|
|
if(description) {
|
|
|
|
if(ctx->ei.bstrDescription) SysFreeString(ctx->ei.bstrDescription);
|
|
|
|
ctx->ei.bstrDescription = description;
|
|
|
|
}
|
|
|
|
if(!ctx->ei.bstrDescription)
|
|
|
|
ctx->ei.bstrDescription = get_vbscript_error_string(error);
|
|
|
|
if(helpfile) {
|
|
|
|
if(ctx->ei.bstrHelpFile) SysFreeString(ctx->ei.bstrHelpFile);
|
|
|
|
ctx->ei.bstrHelpFile = helpfile;
|
|
|
|
}
|
|
|
|
if(args_cnt >= 5)
|
|
|
|
ctx->ei.dwHelpContext = helpcontext;
|
|
|
|
|
|
|
|
ctx->ei.scode = error;
|
|
|
|
hres = SCRIPT_E_RECORDED;
|
|
|
|
}else {
|
|
|
|
SysFreeString(source);
|
|
|
|
SysFreeString(description);
|
|
|
|
SysFreeString(helpfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
2014-03-21 14:36:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const builtin_prop_t err_props[] = {
|
|
|
|
{DISPID_ERR_DESCRIPTION, Err_Description, BP_GETPUT},
|
|
|
|
{DISPID_ERR_HELPCONTEXT, Err_HelpContext, BP_GETPUT},
|
|
|
|
{DISPID_ERR_HELPFILE, Err_HelpFile, BP_GETPUT},
|
|
|
|
{DISPID_ERR_NUMBER, Err_Number, BP_GETPUT},
|
|
|
|
{DISPID_ERR_SOURCE, Err_Source, BP_GETPUT},
|
|
|
|
{DISPID_ERR_CLEAR, Err_Clear},
|
2019-10-03 18:19:24 +02:00
|
|
|
{DISPID_ERR_RAISE, Err_Raise, 0, 1, 5},
|
2014-03-21 14:36:45 +01:00
|
|
|
};
|
|
|
|
|
2019-10-17 22:46:27 +02:00
|
|
|
void detach_global_objects(script_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
if(ctx->err_obj) {
|
|
|
|
IDispatchEx_Release(&ctx->err_obj->IDispatchEx_iface);
|
|
|
|
ctx->err_obj = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ctx->global_obj) {
|
|
|
|
IDispatchEx_Release(&ctx->global_obj->IDispatchEx_iface);
|
|
|
|
ctx->global_obj = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ctx->script_obj) {
|
|
|
|
ScriptDisp *script_obj = ctx->script_obj;
|
|
|
|
|
|
|
|
ctx->script_obj = NULL;
|
|
|
|
script_obj->ctx = NULL;
|
|
|
|
IDispatchEx_Release(&script_obj->IDispatchEx_iface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-19 14:08:38 +02:00
|
|
|
HRESULT init_global(script_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
ctx->global_desc.ctx = ctx;
|
2018-07-18 23:01:34 +02:00
|
|
|
ctx->global_desc.builtin_prop_cnt = ARRAY_SIZE(global_props);
|
2011-09-19 14:08:38 +02:00
|
|
|
ctx->global_desc.builtin_props = global_props;
|
|
|
|
|
|
|
|
hres = get_typeinfo(GlobalObj_tid, &ctx->global_desc.typeinfo);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
hres = create_vbdisp(&ctx->global_desc, (vbdisp_t**)&ctx->global_obj);
|
2011-09-19 14:08:38 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2012-09-07 15:09:34 +02:00
|
|
|
hres = create_script_disp(ctx, &ctx->script_obj);
|
2011-09-19 14:08:38 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2014-03-21 14:36:45 +01:00
|
|
|
ctx->err_desc.ctx = ctx;
|
2018-07-18 23:01:34 +02:00
|
|
|
ctx->err_desc.builtin_prop_cnt = ARRAY_SIZE(err_props);
|
2014-03-21 14:36:45 +01:00
|
|
|
ctx->err_desc.builtin_props = err_props;
|
|
|
|
|
|
|
|
hres = get_typeinfo(ErrObj_tid, &ctx->err_desc.typeinfo);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2019-10-17 22:46:25 +02:00
|
|
|
return create_vbdisp(&ctx->err_desc, (vbdisp_t**)&ctx->err_obj);
|
2011-09-19 14:08:38 +02:00
|
|
|
}
|