vbscript: Add err.description implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-10-03 18:18:51 +02:00 committed by Alexandre Julliard
parent 8277c24806
commit 0d9f024d6a
7 changed files with 127 additions and 34 deletions

View File

@ -2445,10 +2445,27 @@ static const builtin_prop_t global_props[] = {
{DISPID_GLOBAL_VBMSGBOXRTLREADING, NULL, BP_GET, VT_I4, MB_RTLREADING}
};
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;
}
static HRESULT Err_Description(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
TRACE("\n");
return !This->desc ? E_UNEXPECTED : err_string_prop(&This->desc->ctx->ei.bstrDescription, args, args_cnt, res);
}
static HRESULT Err_HelpContext(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res)

View File

@ -2166,7 +2166,14 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, vbdisp_t *vbthis, DISPP
op = exec.instr->op;
hres = op_funcs[op](&exec);
if(FAILED(hres)) {
ctx->ei.scode = hres = map_hres(hres);
if(hres != SCRIPT_E_RECORDED) {
clear_ei(&ctx->ei);
ctx->ei.scode = hres = map_hres(hres);
ctx->ei.bstrDescription = get_vbscript_error_string(hres);
}else {
hres = ctx->ei.scode;
}
if(exec.resume_next) {
unsigned stack_off;

View File

@ -134,6 +134,7 @@ sub testCStrError()
Error.clear()
CStr(null)
call ok(Err.number = 94, "Err.number = " & Err.number)
if isEnglishLang then call ok(Err.description = "Invalid use of Null", "Err.description = " & Err.description)
end sub
call testCStrError()
@ -152,6 +153,7 @@ sub testChrError
call Err.clear()
call Chr(-1)
call ok(Err.number = 5, "Err.number = " & Err.number)
if isEnglishLang then call ok(Err.description = "Invalid procedure call or argument", "Err.description = " & Err.description)
call Err.clear()
call Chr(256)
@ -253,6 +255,8 @@ sub testUBoundError()
call Err.clear()
call UBound(arr, 1, 2)
call ok(Err.number = 450, "Err.number = " & Err.number)
if isEnglishLang then call ok(Err.description = "Wrong number of arguments or invalid property assignment", _
"Err.description = " & Err.description)
end sub
call testUBoundError()

View File

@ -29,6 +29,7 @@
#include "activdbg.h"
#include "vbscript_classes.h"
#include "vbscript_defs.h"
#include "wine/heap.h"
#include "wine/list.h"
@ -393,40 +394,12 @@ HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) DECLSPEC_HIDDEN;
#define FACILITY_VBS 0xa
#define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code)
#define VBSE_ILLEGAL_FUNC_CALL 5
#define VBSE_OVERFLOW 6
#define VBSE_OUT_OF_MEMORY 7
#define VBSE_OUT_OF_BOUNDS 9
#define VBSE_ARRAY_LOCKED 10
#define VBSE_TYPE_MISMATCH 13
#define VBSE_FILE_NOT_FOUND 53
#define VBSE_IO_ERROR 57
#define VBSE_FILE_ALREADY_EXISTS 58
#define VBSE_DISK_FULL 61
#define VBSE_TOO_MANY_FILES 67
#define VBSE_PERMISSION_DENIED 70
#define VBSE_PATH_FILE_ACCESS 75
#define VBSE_PATH_NOT_FOUND 76
#define VBSE_ILLEGAL_NULL_USE 94
#define VBSE_OLE_NOT_SUPPORTED 430
#define VBSE_OLE_NO_PROP_OR_METHOD 438
#define VBSE_ACTION_NOT_SUPPORTED 445
#define VBSE_NAMED_ARGS_NOT_SUPPORTED 446
#define VBSE_LOCALE_SETTING_NOT_SUPPORTED 447
#define VBSE_NAMED_PARAM_NOT_FOUND 448
#define VBSE_INVALID_TYPELIB_VARIABLE 458
#define VBSE_FUNC_ARITY_MISMATCH 450
#define VBSE_PARAMETER_NOT_OPTIONAL 449
#define VBSE_NOT_ENUM 451
#define VBSE_INVALID_DLL_FUNCTION_NAME 453
#define VBSE_CANT_CREATE_TMP_FILE 322
#define VBSE_OLE_FILE_NOT_FOUND 432
#define VBSE_CANT_CREATE_OBJECT 429
#define VBSE_SERVER_NOT_FOUND 462
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
HRESULT WINAPI VBScriptRegExpFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
BSTR get_vbscript_string(int) DECLSPEC_HIDDEN;
BSTR get_vbscript_error_string(HRESULT) DECLSPEC_HIDDEN;
static inline LPWSTR heap_strdupW(LPCWSTR str)
{
LPWSTR ret = NULL;

View File

@ -17,6 +17,47 @@
*/
#include <windef.h>
#include "vbscript_defs.h"
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE
{
VBSE_ILLEGAL_FUNC_CALL "Invalid procedure call or argument"
VBSE_OVERFLOW "Overflow"
VBSE_OUT_OF_MEMORY "Out of memory"
VBSE_OUT_OF_BOUNDS "Subscript out of range"
VBSE_ARRAY_LOCKED "This array is fixed or temporarily locked"
VBSE_TYPE_MISMATCH "Type mismatch"
VBSE_FILE_NOT_FOUND "File not found"
VBSE_IO_ERROR "Device I/O error"
VBSE_FILE_ALREADY_EXISTS "File already exists"
VBSE_DISK_FULL "Disk full"
VBSE_TOO_MANY_FILES "Too many files"
VBSE_PERMISSION_DENIED "Permission denied"
VBSE_PATH_FILE_ACCESS "Path/File access error"
VBSE_PATH_NOT_FOUND "Path not found"
VBSE_ILLEGAL_NULL_USE "Invalid use of Null"
VBSE_CANT_CREATE_TMP_FILE "Can't create necessary temporary file"
VBSE_CANT_CREATE_OBJECT "ActiveX component can't create object"
VBSE_OLE_NOT_SUPPORTED "Class doesn't support Automation"
VBSE_OLE_FILE_NOT_FOUND "File name or class name not found during Automation operation"
VBSE_OLE_NO_PROP_OR_METHOD "Object doesn't support this property or method"
VBSE_ACTION_NOT_SUPPORTED "Object doesn't support this action"
VBSE_NAMED_ARGS_NOT_SUPPORTED "Object doesn't support named arguments"
VBSE_LOCALE_SETTING_NOT_SUPPORTED "Object doesn't support current locale setting"
VBSE_NAMED_PARAM_NOT_FOUND "Named argument not found"
VBSE_PARAMETER_NOT_OPTIONAL "Named argument not found"
VBSE_FUNC_ARITY_MISMATCH "Wrong number of arguments or invalid property assignment"
VBSE_NOT_ENUM "Object not a collection"
VBSE_INVALID_DLL_FUNCTION_NAME "Specified DLL function not found"
VBSE_INVALID_TYPELIB_VARIABLE "Variable uses an Automation type not supported in VBScript"
VBSE_SERVER_NOT_FOUND "The remote server machine does not exist or is unavailable"
VBS_COMPILE_ERROR "Microsoft VBScript compilation error"
VBS_RUNTIME_ERROR "Microsoft VBScript runtime error"
VBS_UNKNOWN_RUNTIME_ERROR "Unknown runtime error"
}
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL

View File

@ -234,3 +234,39 @@
#define DISPID_REGEXP_TEST 10005
#define DISPID_REGEXP_REPLACE 10006
#define DISPID_REGEXP_MULTILINE 10007
/* error codes */
#define VBSE_ILLEGAL_FUNC_CALL 5
#define VBSE_OVERFLOW 6
#define VBSE_OUT_OF_MEMORY 7
#define VBSE_OUT_OF_BOUNDS 9
#define VBSE_ARRAY_LOCKED 10
#define VBSE_TYPE_MISMATCH 13
#define VBSE_FILE_NOT_FOUND 53
#define VBSE_IO_ERROR 57
#define VBSE_FILE_ALREADY_EXISTS 58
#define VBSE_DISK_FULL 61
#define VBSE_TOO_MANY_FILES 67
#define VBSE_PERMISSION_DENIED 70
#define VBSE_PATH_FILE_ACCESS 75
#define VBSE_PATH_NOT_FOUND 76
#define VBSE_ILLEGAL_NULL_USE 94
#define VBSE_CANT_CREATE_TMP_FILE 322
#define VBSE_CANT_CREATE_OBJECT 429
#define VBSE_OLE_NOT_SUPPORTED 430
#define VBSE_OLE_FILE_NOT_FOUND 432
#define VBSE_OLE_NO_PROP_OR_METHOD 438
#define VBSE_ACTION_NOT_SUPPORTED 445
#define VBSE_NAMED_ARGS_NOT_SUPPORTED 446
#define VBSE_LOCALE_SETTING_NOT_SUPPORTED 447
#define VBSE_NAMED_PARAM_NOT_FOUND 448
#define VBSE_PARAMETER_NOT_OPTIONAL 449
#define VBSE_FUNC_ARITY_MISMATCH 450
#define VBSE_NOT_ENUM 451
#define VBSE_INVALID_DLL_FUNCTION_NAME 453
#define VBSE_INVALID_TYPELIB_VARIABLE 458
#define VBSE_SERVER_NOT_FOUND 462
#define VBS_COMPILE_ERROR 4096
#define VBS_RUNTIME_ERROR 4097
#define VBS_UNKNOWN_RUNTIME_ERROR 4098

View File

@ -95,6 +95,21 @@ static void release_typelib(void)
ITypeLib_Release(typelib);
}
BSTR get_vbscript_string(int id)
{
WCHAR buf[512];
if(!LoadStringW(vbscript_hinstance, id, buf, ARRAY_SIZE(buf))) return NULL;
return SysAllocString(buf);
}
BSTR get_vbscript_error_string(HRESULT error)
{
BSTR ret;
if(HRESULT_FACILITY(error) != FACILITY_VBS || !(ret = get_vbscript_string(HRESULT_CODE(error))))
ret = get_vbscript_string(VBS_UNKNOWN_RUNTIME_ERROR);
return ret;
}
#define MIN_BLOCK_SIZE 128
#define ARENA_FREE_FILLER 0xaa