From: Michael Stefaniuc Subject: [PATCH] jscript: Use wide-char string literals. Message-Id: <20201123234907.126869-1-mstefani@winehq.org> Date: Tue, 24 Nov 2020 00:49:04 +0100 Signed-off-by: Michael Stefaniuc --- dlls/jscript/activex.c | 4 +- dlls/jscript/bool.c | 9 +-- dlls/jscript/compile.c | 4 +- dlls/jscript/date.c | 65 +++++----------- dlls/jscript/dispex.c | 15 +--- dlls/jscript/engine.c | 35 +++------ dlls/jscript/enumerator.c | 6 +- dlls/jscript/error.c | 35 +++------ dlls/jscript/function.c | 44 ++++------- dlls/jscript/global.c | 78 ++++++------------- dlls/jscript/json.c | 27 +++---- dlls/jscript/jsregexp.c | 27 ++----- dlls/jscript/jsstr.c | 6 +- dlls/jscript/jsutils.c | 19 ++--- dlls/jscript/lex.c | 4 +- dlls/jscript/number.c | 7 +- dlls/jscript/string.c | 159 ++++++++++++-------------------------- dlls/jscript/vbarray.c | 4 +- 18 files changed, 167 insertions(+), 381 deletions(-) diff --git a/dlls/jscript/activex.c b/dlls/jscript/activex.c index 9c8c681b5e7..80a89b5ae89 100644 --- a/dlls/jscript/activex.c +++ b/dlls/jscript/activex.c @@ -190,13 +190,11 @@ HRESULT create_activex_constr(script_ctx_t *ctx, jsdisp_t **ret) jsdisp_t *prototype; HRESULT hres; - static const WCHAR ActiveXObjectW[] = {'A','c','t','i','v','e','X','O','b','j','e','c','t',0}; - hres = create_object(ctx, NULL, &prototype); if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, + hres = create_builtin_function(ctx, ActiveXObject_value, L"ActiveXObject", NULL, PROPF_CONSTR|1, prototype, ret); jsdisp_release(prototype); diff --git a/dlls/jscript/bool.c b/dlls/jscript/bool.c index f31117e2141..44a8b7262de 100644 --- a/dlls/jscript/bool.c +++ b/dlls/jscript/bool.c @@ -57,9 +57,6 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns { BoolInstance *bool; - static const WCHAR trueW[] = {'t','r','u','e',0}; - static const WCHAR falseW[] = {'f','a','l','s','e',0}; - TRACE("\n"); if(!(bool = bool_this(jsthis))) @@ -68,7 +65,7 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns if(r) { jsstr_t *val; - val = jsstr_alloc(bool->val ? trueW : falseW); + val = jsstr_alloc(bool->val ? L"true" : L"false"); if(!val) return E_OUTOFMEMORY; @@ -197,13 +194,11 @@ HRESULT create_bool_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp BoolInstance *bool; HRESULT hres; - static const WCHAR BooleanW[] = {'B','o','o','l','e','a','n',0}; - hres = alloc_bool(ctx, object_prototype, &bool); if(FAILED(hres)) return hres; - hres = create_builtin_constructor(ctx, BoolConstr_value, BooleanW, NULL, + hres = create_builtin_constructor(ctx, BoolConstr_value, L"Boolean", NULL, PROPF_CONSTR|1, &bool->dispex, ret); jsdisp_release(&bool->dispex); diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 5ac93c9f2ff..a1d1171e2ec 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -719,15 +719,13 @@ static HRESULT compile_delete_expression(compiler_ctx_t *ctx, unary_expression_t case EXPR_IDENT: return push_instr_bstr(ctx, OP_delete_ident, ((identifier_expression_t*)expr->expression)->identifier); default: { - static const WCHAR fixmeW[] = {'F','I','X','M','E',0}; - WARN("invalid delete, unimplemented exception message\n"); hres = compile_expression(ctx, expr->expression, TRUE); if(FAILED(hres)) return hres; - return push_instr_uint_str(ctx, OP_throw_type, JS_E_INVALID_DELETE, fixmeW); + return push_instr_uint_str(ctx, OP_throw_type, JS_E_INVALID_DELETE, L"FIXME"); } } diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c index 4809cc976d8..5ca23f199f3 100644 --- a/dlls/jscript/date.c +++ b/dlls/jscript/date.c @@ -431,18 +431,6 @@ static SYSTEMTIME create_systemtime(DOUBLE time) static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset, jsval_t *r) { - static const WCHAR formatW[] = { '%','s',' ','%','s',' ','%','d',' ', - '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ', - 'U','T','C','%','c','%','0','2','d','%','0','2','d',' ','%','d','%','s',0 }; - static const WCHAR formatUTCW[] = { '%','s',' ','%','s',' ','%','d',' ', - '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ', - 'U','T','C',' ','%','d','%','s',0 }; - static const WCHAR formatNoOffsetW[] = { '%','s',' ','%','s',' ', - '%','d',' ','%','0','2','d',':','%','0','2','d',':', - '%','0','2','d',' ','%','d','%','s',0 }; - static const WCHAR ADW[] = { 0 }; - static const WCHAR BCW[] = { ' ','B','.','C','.',0 }; - static const DWORD week_ids[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1, LOCALE_SABBREVDAYNAME2, LOCALE_SABBREVDAYNAME3, LOCALE_SABBREVDAYNAME4, LOCALE_SABBREVDAYNAME5, LOCALE_SABBREVDAYNAME6 }; @@ -490,18 +478,18 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset, } if(!show_offset) - swprintf(buf, ARRAY_SIZE(buf), formatNoOffsetW, week, month, day, + swprintf(buf, ARRAY_SIZE(buf), L"%s %s %d %02d:%02d:%02d %d%s", week, month, day, (int)hour_from_time(time), (int)min_from_time(time), - (int)sec_from_time(time), year, formatAD?ADW:BCW); + (int)sec_from_time(time), year, formatAD?L"":L" B.C."); else if(offset) - swprintf(buf, ARRAY_SIZE(buf), formatW, week, month, day, + swprintf(buf, ARRAY_SIZE(buf), L"%s %s %d %02d:%02d:%02d UTC%c%02d%02d %d%s", week, month, day, (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time), sign, offset/60, offset%60, - year, formatAD?ADW:BCW); + year, formatAD?L"":L" B.C."); else - swprintf(buf, ARRAY_SIZE(buf), formatUTCW, week, month, day, + swprintf(buf, ARRAY_SIZE(buf), L"%s %s %d %02d:%02d:%02d UTC %d%s", week, month, day, (int)hour_from_time(time), (int)min_from_time(time), - (int)sec_from_time(time), year, formatAD?ADW:BCW); + (int)sec_from_time(time), year, formatAD?L"":L" B.C."); date_jsstr = jsstr_alloc(buf); if(!date_jsstr) @@ -588,11 +576,6 @@ static HRESULT Date_toISOString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, WCHAR buf[64], *p = buf; double year; - static const WCHAR short_year_formatW[] = {'%','0','4','d',0}; - static const WCHAR long_year_formatW[] = {'%','0','6','d',0}; - static const WCHAR formatW[] = {'-','%','0','2','d','-','%','0','2','d', - 'T','%','0','2','d',':','%','0','2','d',':','%','0','2','d','.','%','0','3','d','Z',0}; - TRACE("\n"); if(!(date = date_this(jsthis))) @@ -606,15 +589,15 @@ static HRESULT Date_toISOString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, if(year < 0) { *p++ = '-'; - p += swprintf(p, ARRAY_SIZE(buf) - 1, long_year_formatW, -(int)year); + p += swprintf(p, ARRAY_SIZE(buf) - 1, L"%06d", -(int)year); }else if(year > 9999) { *p++ = '+'; - p += swprintf(p, ARRAY_SIZE(buf) - 1, long_year_formatW, (int)year); + p += swprintf(p, ARRAY_SIZE(buf) - 1, L"%06d", (int)year); }else { - p += swprintf(p, ARRAY_SIZE(buf), short_year_formatW, (int)year); + p += swprintf(p, ARRAY_SIZE(buf), L"%04d", (int)year); } - swprintf(p, ARRAY_SIZE(buf) - (p - buf), formatW, + swprintf(p, ARRAY_SIZE(buf) - (p - buf), L"-%02d-%02dT%02d:%02d:%02d.%03dZ", (int)month_from_time(date->time) + 1, (int)date_from_time(date->time), (int)hour_from_time(date->time), (int)min_from_time(date->time), (int)sec_from_time(date->time), (int)ms_from_time(date->time)); @@ -645,11 +628,6 @@ static HRESULT Date_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r) { - static const WCHAR formatADW[] = { '%','s',',',' ','%','d',' ','%','s',' ','%','d',' ', - '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ','U','T','C',0 }; - static const WCHAR formatBCW[] = { '%','s',',',' ','%','d',' ','%','s',' ','%','d',' ','B','.','C','.',' ', - '%','0','2','d',':','%','0','2','d',':','%','0','2','d',' ','U','T','C',0 }; - static const DWORD week_ids[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1, LOCALE_SABBREVDAYNAME2, LOCALE_SABBREVDAYNAME3, LOCALE_SABBREVDAYNAME4, LOCALE_SABBREVDAYNAME5, LOCALE_SABBREVDAYNAME6 }; @@ -694,8 +672,9 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsva day = date_from_time(date->time); - swprintf(buf, ARRAY_SIZE(buf), formatAD ? formatADW : formatBCW, week, day, month, year, - (int)hour_from_time(date->time), (int)min_from_time(date->time), + swprintf(buf, ARRAY_SIZE(buf), + formatAD ? L"%s, %d %s %d %02d:%02d:%02d UTC" : L"%s, %d %s %d B.C. %02d:%02d:%02d UTC", + week, day, month, year, (int)hour_from_time(date->time), (int)min_from_time(date->time), (int)sec_from_time(date->time)); date_str = jsstr_alloc(buf); @@ -725,9 +704,6 @@ static HRESULT Date_toGMTString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, /* ECMA-262 3rd Edition 15.9.5.3 */ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r) { - static const WCHAR formatADW[] = { '%','s',' ','%','s',' ','%','d',' ','%','d',0 }; - static const WCHAR formatBCW[] = { '%','s',' ','%','s',' ','%','d',' ','%','d',' ','B','.','C','.',0 }; - static const DWORD week_ids[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1, LOCALE_SABBREVDAYNAME2, LOCALE_SABBREVDAYNAME3, LOCALE_SABBREVDAYNAME4, LOCALE_SABBREVDAYNAME5, LOCALE_SABBREVDAYNAME6 }; @@ -771,7 +747,8 @@ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r) day = date_from_time(time); - swprintf(buf, ARRAY_SIZE(buf), formatAD ? formatADW : formatBCW, week, month, day, year); + swprintf(buf, ARRAY_SIZE(buf), formatAD ? L"%s %s %d %d" : L"%s %s %d %d B.C.", week, month, + day, year); date_str = jsstr_alloc(buf); if(!date_str) @@ -797,10 +774,6 @@ static HRESULT Date_toDateString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - static const WCHAR formatW[] = { '%','0','2','d',':','%','0','2','d',':','%','0','2','d', - ' ','U','T','C','%','c','%','0','2','d','%','0','2','d',0 }; - static const WCHAR formatUTCW[] = { '%','0','2','d',':','%','0','2','d', - ':','%','0','2','d',' ','U','T','C',0 }; DateInstance *date; jsstr_t *date_str; WCHAR buf[32]; @@ -832,11 +805,11 @@ static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, else sign = '-'; if(offset) - swprintf(buf, ARRAY_SIZE(buf), formatW, (int)hour_from_time(time), + swprintf(buf, ARRAY_SIZE(buf), L"%02d:%02d:%02d UTC%c%02d%02d", (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time), sign, offset/60, offset%60); else - swprintf(buf, ARRAY_SIZE(buf), formatUTCW, (int)hour_from_time(time), + swprintf(buf, ARRAY_SIZE(buf), L"%02d:%02d:%02d UTC", (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time)); date_str = jsstr_alloc(buf); @@ -2482,13 +2455,11 @@ HRESULT create_date_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdisp jsdisp_t *date; HRESULT hres; - static const WCHAR DateW[] = {'D','a','t','e',0}; - hres = create_date(ctx, object_prototype, 0.0, &date); if(FAILED(hres)) return hres; - hres = create_builtin_constructor(ctx, DateConstr_value, DateW, &DateConstr_info, + hres = create_builtin_constructor(ctx, DateConstr_value, L"Date", &DateConstr_info, PROPF_CONSTR|7, date, ret); jsdisp_release(date); diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index f49d5da9719..5829cebe55b 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -1843,9 +1843,7 @@ HRESULT init_dispex_from_constr(jsdisp_t *dispex, script_ctx_t *ctx, const built dispex_prop_t *prop; HRESULT hres; - static const WCHAR prototypeW[] = {'p','r','o','t','o','t','y','p','e',0}; - - hres = find_prop_name_prot(constr, string_hash(prototypeW), prototypeW, &prop); + hres = find_prop_name_prot(constr, string_hash(L"prototype"), L"prototype", &prop); if(SUCCEEDED(hres) && prop && prop->type!=PROP_DELETED) { jsval_t val; @@ -2148,9 +2146,7 @@ HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val) { WCHAR buf[12]; - static const WCHAR formatW[] = {'%','d',0}; - - swprintf(buf, ARRAY_SIZE(buf), formatW, idx); + swprintf(buf, ARRAY_SIZE(buf), L"%d", idx); return jsdisp_propput_name(obj, buf, val); } @@ -2213,9 +2209,7 @@ HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r) dispex_prop_t *prop; HRESULT hres; - static const WCHAR formatW[] = {'%','d',0}; - - swprintf(name, ARRAY_SIZE(name), formatW, idx); + swprintf(name, ARRAY_SIZE(name), L"%d", idx); hres = find_prop_name_prot(obj, string_hash(name), name, &prop); if(FAILED(hres)) @@ -2265,13 +2259,12 @@ HRESULT disp_propget(script_ctx_t *ctx, IDispatch *disp, DISPID id, jsval_t *val HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx) { - static const WCHAR formatW[] = {'%','d',0}; WCHAR buf[12]; dispex_prop_t *prop; BOOL b; HRESULT hres; - swprintf(buf, ARRAY_SIZE(buf), formatW, idx); + swprintf(buf, ARRAY_SIZE(buf), L"%d", idx); hres = find_prop_name(obj, string_hash(buf), buf, &prop); if(FAILED(hres) || !prop) diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index bca632129bc..5635e3aa996 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -27,14 +27,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); -static const WCHAR booleanW[] = {'b','o','o','l','e','a','n',0}; -static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0}; -static const WCHAR numberW[] = {'n','u','m','b','e','r',0}; -static const WCHAR objectW[] = {'o','b','j','e','c','t',0}; -static const WCHAR stringW[] = {'s','t','r','i','n','g',0}; -static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0}; -static const WCHAR unknownW[] = {'u','n','k','n','o','w','n',0}; - struct _except_frame_t { unsigned stack_top; scope_chain_t *scope; @@ -632,7 +624,6 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re if(scope->frame) { function_code_t *func = scope->frame->function; local_ref_t *ref = lookup_local(func, identifier); - static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0}; if(ref) { ret->type = EXPRVAL_STACK_REF; @@ -641,7 +632,7 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re return S_OK; } - if(!wcscmp(identifier, argumentsW)) { + if(!wcscmp(identifier, L"arguments")) { hres = detach_variable_object(ctx, scope->frame, FALSE); if(FAILED(hres)) return hres; @@ -1631,8 +1622,6 @@ static HRESULT interp_instanceof(script_ctx_t *ctx) BOOL ret = FALSE; HRESULT hres; - static const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0}; - v = stack_pop(ctx); if(!is_object_instance(v) || !get_object(v)) { jsval_release(v); @@ -1647,7 +1636,7 @@ static HRESULT interp_instanceof(script_ctx_t *ctx) } if(is_class(obj, JSCLASS_FUNCTION)) { - hres = jsdisp_propget_name(obj, prototypeW, &prot); + hres = jsdisp_propget_name(obj, L"prototype", &prot); }else { hres = JS_E_FUNCTION_EXPECTED; } @@ -1945,30 +1934,30 @@ static HRESULT typeof_string(jsval_t v, const WCHAR **ret) { switch(jsval_type(v)) { case JSV_UNDEFINED: - *ret = undefinedW; + *ret = L"undefined"; break; case JSV_NULL: - *ret = objectW; + *ret = L"object"; break; case JSV_OBJECT: { jsdisp_t *dispex; if(get_object(v) && (dispex = iface_to_jsdisp(get_object(v)))) { - *ret = is_class(dispex, JSCLASS_FUNCTION) ? functionW : objectW; + *ret = is_class(dispex, JSCLASS_FUNCTION) ? L"function" : L"object"; jsdisp_release(dispex); }else { - *ret = objectW; + *ret = L"object"; } break; } case JSV_STRING: - *ret = stringW; + *ret = L"string"; break; case JSV_NUMBER: - *ret = numberW; + *ret = L"number"; break; case JSV_BOOL: - *ret = booleanW; + *ret = L"boolean"; break; case JSV_VARIANT: FIXME("unhandled variant %s\n", debugstr_variant(get_variant(v))); @@ -1994,7 +1983,7 @@ static HRESULT interp_typeofid(script_ctx_t *ctx) hres = exprval_propget(ctx, &ref, &v); exprval_release(&ref); if(FAILED(hres)) - return stack_push_string(ctx, unknownW); + return stack_push_string(ctx, L"unknown"); hres = typeof_string(v, &ret); jsval_release(v); @@ -2756,13 +2745,11 @@ static HRESULT unwind_exception(script_ctx_t *ctx, HRESULT exception_hres) jsdisp_t *error_obj; jsval_t msg; - static const WCHAR messageW[] = {'m','e','s','s','a','g','e',0}; - WARN("Exception %08x %s", exception_hres, debugstr_jsval(ei->valid_value ? ei->value : jsval_undefined())); if(ei->valid_value && jsval_type(ei->value) == JSV_OBJECT) { error_obj = to_jsdisp(get_object(ei->value)); if(error_obj) { - hres = jsdisp_propget_name(error_obj, messageW, &msg); + hres = jsdisp_propget_name(error_obj, L"message", &msg); if(SUCCEEDED(hres)) { WARN(" (message %s)", debugstr_jsval(msg)); jsval_release(msg); diff --git a/dlls/jscript/enumerator.c b/dlls/jscript/enumerator.c index 6971150bbb4..dea19406695 100644 --- a/dlls/jscript/enumerator.c +++ b/dlls/jscript/enumerator.c @@ -328,15 +328,13 @@ HRESULT create_enumerator_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, { EnumeratorInstance *enumerator; HRESULT hres; - static const WCHAR EnumeratorW[] = {'E','n','u','m','e','r','a','t','o','r',0}; hres = alloc_enumerator(ctx, object_prototype, &enumerator); if(FAILED(hres)) return hres; - hres = create_builtin_constructor(ctx, EnumeratorConstr_value, - EnumeratorW, &EnumeratorConstr_info, - PROPF_CONSTR|7, &enumerator->dispex, ret); + hres = create_builtin_constructor(ctx, EnumeratorConstr_value, L"Enumerator", + &EnumeratorConstr_info, PROPF_CONSTR|7, &enumerator->dispex, ret); jsdisp_release(&enumerator->dispex); return hres; diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c index 07ebc1144eb..38a2485c858 100644 --- a/dlls/jscript/error.c +++ b/dlls/jscript/error.c @@ -28,11 +28,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); -static const WCHAR descriptionW[] = {'d','e','s','c','r','i','p','t','i','o','n',0}; -static const WCHAR messageW[] = {'m','e','s','s','a','g','e',0}; -static const WCHAR nameW[] = {'n','a','m','e',0}; -static const WCHAR numberW[] = {'n','u','m','b','e','r',0}; - /* ECMA-262 3rd Edition 15.11.4.4 */ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) @@ -42,8 +37,6 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, jsval_t v; HRESULT hres; - static const WCHAR object_errorW[] = {'[','o','b','j','e','c','t',' ','E','r','r','o','r',']',0}; - TRACE("\n"); jsthis = get_jsdisp(vthis); @@ -51,7 +44,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, if(r) { jsstr_t *str; - str = jsstr_alloc(object_errorW); + str = jsstr_alloc(L"[object Error]"); if(!str) return E_OUTOFMEMORY; *r = jsval_string(str); @@ -59,7 +52,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, return S_OK; } - hres = jsdisp_propget_name(jsthis, nameW, &v); + hres = jsdisp_propget_name(jsthis, L"name", &v); if(FAILED(hres)) return hres; @@ -70,7 +63,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, return hres; } - hres = jsdisp_propget_name(jsthis, messageW, &v); + hres = jsdisp_propget_name(jsthis, L"message", &v); if(SUCCEEDED(hres)) { if(!is_undefined(v)) { hres = to_string(ctx, v, &msg); @@ -101,7 +94,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, ret = msg; msg = NULL; }else { - ret = jsstr_alloc(object_errorW); + ret = jsstr_alloc(L"[object Error]"); } } @@ -193,18 +186,18 @@ static HRESULT create_error(script_ctx_t *ctx, jsdisp_t *constr, if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(err, numberW, PROPF_WRITABLE | PROPF_CONFIGURABLE, + hres = jsdisp_define_data_property(err, L"number", PROPF_WRITABLE | PROPF_CONFIGURABLE, jsval_number((INT)number)); if(FAILED(hres)) { jsdisp_release(err); return hres; } - hres = jsdisp_define_data_property(err, messageW, + hres = jsdisp_define_data_property(err, L"message", PROPF_WRITABLE | PROPF_ENUMERABLE | PROPF_CONFIGURABLE, jsval_string(msg)); if(SUCCEEDED(hres)) - hres = jsdisp_define_data_property(err, descriptionW, PROPF_WRITABLE | PROPF_CONFIGURABLE, + hres = jsdisp_define_data_property(err, L"description", PROPF_WRITABLE | PROPF_CONFIGURABLE, jsval_string(msg)); if(FAILED(hres)) { jsdisp_release(err); @@ -325,16 +318,8 @@ static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype) { - static const WCHAR ErrorW[] = {'E','r','r','o','r',0}; - static const WCHAR EvalErrorW[] = {'E','v','a','l','E','r','r','o','r',0}; - static const WCHAR RangeErrorW[] = {'R','a','n','g','e','E','r','r','o','r',0}; - static const WCHAR ReferenceErrorW[] = {'R','e','f','e','r','e','n','c','e','E','r','r','o','r',0}; - static const WCHAR RegExpErrorW[] = {'R','e','g','E','x','p','E','r','r','o','r',0}; - static const WCHAR SyntaxErrorW[] = {'S','y','n','t','a','x','E','r','r','o','r',0}; - static const WCHAR TypeErrorW[] = {'T','y','p','e','E','r','r','o','r',0}; - static const WCHAR URIErrorW[] = {'U','R','I','E','r','r','o','r',0}; - static const WCHAR *names[] = {ErrorW, EvalErrorW, RangeErrorW, - ReferenceErrorW, RegExpErrorW, SyntaxErrorW, TypeErrorW, URIErrorW}; + static const WCHAR *names[] = {L"Error", L"EvalError", L"RangeError", + L"ReferenceError", L"RegExpError", L"SyntaxError", L"TypeError", L"URIError"}; jsdisp_t **constr_addr[] = {&ctx->error_constr, &ctx->eval_error_constr, &ctx->range_error_constr, &ctx->reference_error_constr, &ctx->regexp_error_constr, &ctx->syntax_error_constr, &ctx->type_error_constr, @@ -359,7 +344,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype) return E_OUTOFMEMORY; } - hres = jsdisp_define_data_property(err, nameW, PROPF_WRITABLE | PROPF_CONFIGURABLE, + hres = jsdisp_define_data_property(err, L"name", PROPF_WRITABLE | PROPF_CONFIGURABLE, jsval_string(str)); jsstr_release(str); if(SUCCEEDED(hres)) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index f0bd20d75a2..9f6aa4b4ec6 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -92,11 +92,6 @@ static inline ArgumentsInstance *arguments_from_jsdisp(jsdisp_t *jsdisp) return CONTAINING_RECORD(jsdisp, ArgumentsInstance, jsdisp); } -static const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0}; - -static const WCHAR lengthW[] = {'l','e','n','g','t','h',0}; -static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0}; - static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { @@ -191,8 +186,6 @@ HRESULT setup_arguments_object(script_ctx_t *ctx, call_frame_t *frame) ArgumentsInstance *args; HRESULT hres; - static const WCHAR caleeW[] = {'c','a','l','l','e','e',0}; - args = heap_alloc_zero(sizeof(*args)); if(!args) return E_OUTOFMEMORY; @@ -207,13 +200,13 @@ HRESULT setup_arguments_object(script_ctx_t *ctx, call_frame_t *frame) args->argc = frame->argc; args->frame = frame; - hres = jsdisp_define_data_property(&args->jsdisp, lengthW, PROPF_WRITABLE | PROPF_CONFIGURABLE, + hres = jsdisp_define_data_property(&args->jsdisp, L"length", PROPF_WRITABLE | PROPF_CONFIGURABLE, jsval_number(args->argc)); if(SUCCEEDED(hres)) - hres = jsdisp_define_data_property(&args->jsdisp, caleeW, PROPF_WRITABLE | PROPF_CONFIGURABLE, + hres = jsdisp_define_data_property(&args->jsdisp, L"callee", PROPF_WRITABLE | PROPF_CONFIGURABLE, jsval_obj(&args->function->function.dispex)); if(SUCCEEDED(hres)) - hres = jsdisp_propput(frame->base_scope->jsobj, argumentsW, PROPF_WRITABLE, jsval_obj(&args->jsdisp)); + hres = jsdisp_propput(frame->base_scope->jsobj, L"arguments", PROPF_WRITABLE, jsval_obj(&args->jsdisp)); if(FAILED(hres)) { jsdisp_release(&args->jsdisp); return hres; @@ -232,7 +225,7 @@ void detach_arguments_object(jsdisp_t *args_disp) /* Reset arguments value to cut the reference cycle. Note that since all activation contexts have * their own arguments property, it's impossible to use prototype's one during name lookup */ - jsdisp_propput_name(frame->base_scope->jsobj, argumentsW, jsval_undefined()); + jsdisp_propput_name(frame->base_scope->jsobj, L"arguments", jsval_undefined()); arguments->frame = NULL; /* Don't bother coppying arguments if call frame holds the last reference. */ @@ -307,7 +300,7 @@ static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, unsigned *a DWORD length, i; HRESULT hres; - hres = jsdisp_propget_name(arg_array, lengthW, &val); + hres = jsdisp_propget_name(arg_array, L"length", &val); if(FAILED(hres)) return hres; @@ -673,10 +666,10 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, return hres; if(builtin_info) - hres = jsdisp_define_data_property(&function->function.dispex, lengthW, 0, + hres = jsdisp_define_data_property(&function->function.dispex, L"length", 0, jsval_number(function->function.length)); if(SUCCEEDED(hres)) - hres = jsdisp_define_data_property(&function->function.dispex, prototypeW, 0, jsval_obj(prototype)); + hres = jsdisp_define_data_property(&function->function.dispex, L"prototype", 0, jsval_obj(prototype)); if(FAILED(hres)) { jsdisp_release(&function->function.dispex); return hres; @@ -691,9 +684,7 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, static HRESULT set_constructor_prop(script_ctx_t *ctx, jsdisp_t *constr, jsdisp_t *prot) { - static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r',0}; - - return jsdisp_define_data_property(prot, constructorW, PROPF_WRITABLE | PROPF_CONFIGURABLE, + return jsdisp_define_data_property(prot, L"constructor", PROPF_WRITABLE | PROPF_CONFIGURABLE, jsval_obj(constr)); } @@ -795,7 +786,7 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod hres = create_function(ctx, NULL, &InterpretedFunctionVtbl, sizeof(InterpretedFunction), PROPF_CONSTR, FALSE, NULL, (void**)&function); if(SUCCEEDED(hres)) { - hres = jsdisp_define_data_property(&function->function.dispex, prototypeW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(&function->function.dispex, L"prototype", PROPF_WRITABLE, jsval_obj(prototype)); if(SUCCEEDED(hres)) hres = set_constructor_prop(ctx, &function->function.dispex, prototype); @@ -850,12 +841,7 @@ static HRESULT BindFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDis static HRESULT BindFunction_toString(FunctionInstance *function, jsstr_t **ret) { - static const WCHAR native_functionW[] = - {'\n','f','u','n','c','t','i','o','n','(',')',' ','{','\n', - ' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n', - '}','\n',0}; - - *ret = jsstr_alloc(native_functionW); + *ret = jsstr_alloc(L"\nfunction() {\n [native code]\n}\n"); return *ret ? S_OK : E_OUTOFMEMORY; } @@ -928,7 +914,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg static const WCHAR function_anonymousW[] = {'f','u','n','c','t','i','o','n',' ','a','n','o','n','y','m','o','u','s','('}; static const WCHAR function_beginW[] = {')',' ','{','\n'}; - static const WCHAR function_endW[] = {'\n','}',0}; + static const WCHAR function_endW[] = L"\n}"; if(argc) { params = heap_alloc(argc*sizeof(*params)); @@ -1038,22 +1024,20 @@ HRESULT init_function_constr(script_ctx_t *ctx, jsdisp_t *object_prototype) NativeFunction *prot, *constr; HRESULT hres; - static const WCHAR FunctionW[] = {'F','u','n','c','t','i','o','n',0}; - hres = create_function(ctx, &Function_info, &NativeFunctionVtbl, sizeof(NativeFunction), PROPF_CONSTR, TRUE, object_prototype, (void**)&prot); if(FAILED(hres)) return hres; prot->proc = FunctionProt_value; - prot->name = prototypeW; + prot->name = L"prototype"; hres = create_function(ctx, &FunctionInst_info, &NativeFunctionVtbl, sizeof(NativeFunction), PROPF_CONSTR|1, TRUE, &prot->function.dispex, (void**)&constr); if(SUCCEEDED(hres)) { constr->proc = FunctionConstr_value; - constr->name = FunctionW; - hres = jsdisp_define_data_property(&constr->function.dispex, prototypeW, 0, jsval_obj(&prot->function.dispex)); + constr->name = L"Function"; + hres = jsdisp_define_data_property(&constr->function.dispex, L"prototype", 0, jsval_obj(&prot->function.dispex)); if(SUCCEEDED(hres)) hres = set_constructor_prop(ctx, &constr->function.dispex, &prot->function.dispex); if(FAILED(hres)) diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c index d5aafe65037..735e188e1bd 100644 --- a/dlls/jscript/global.c +++ b/dlls/jscript/global.c @@ -27,32 +27,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); -static const WCHAR NaNW[] = {'N','a','N',0}; -static const WCHAR InfinityW[] = {'I','n','f','i','n','i','t','y',0}; -static const WCHAR ArrayW[] = {'A','r','r','a','y',0}; -static const WCHAR BooleanW[] = {'B','o','o','l','e','a','n',0}; -static const WCHAR DateW[] = {'D','a','t','e',0}; -static const WCHAR ErrorW[] = {'E','r','r','o','r',0}; -static const WCHAR EvalErrorW[] = {'E','v','a','l','E','r','r','o','r',0}; -static const WCHAR RangeErrorW[] = {'R','a','n','g','e','E','r','r','o','r',0}; -static const WCHAR ReferenceErrorW[] = {'R','e','f','e','r','e','n','c','e','E','r','r','o','r',0}; -static const WCHAR SyntaxErrorW[] = {'S','y','n','t','a','x','E','r','r','o','r',0}; -static const WCHAR TypeErrorW[] = {'T','y','p','e','E','r','r','o','r',0}; -static const WCHAR URIErrorW[] = {'U','R','I','E','r','r','o','r',0}; -static const WCHAR FunctionW[] = {'F','u','n','c','t','i','o','n',0}; -static const WCHAR NumberW[] = {'N','u','m','b','e','r',0}; -static const WCHAR ObjectW[] = {'O','b','j','e','c','t',0}; -static const WCHAR StringW[] = {'S','t','r','i','n','g',0}; -static const WCHAR RegExpW[] = {'R','e','g','E','x','p',0}; -static const WCHAR RegExpErrorW[] = {'R','e','g','E','x','p','E','r','r','o','r',0}; -static const WCHAR ActiveXObjectW[] = {'A','c','t','i','v','e','X','O','b','j','e','c','t',0}; -static const WCHAR VBArrayW[] = {'V','B','A','r','r','a','y',0}; -static const WCHAR EnumeratorW[] = {'E','n','u','m','e','r','a','t','o','r',0}; -static const WCHAR MathW[] = {'M','a','t','h',0}; -static const WCHAR JSONW[] = {'J','S','O','N',0}; - -static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0}; - static int uri_char_table[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 00-0f */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 10-1f */ @@ -527,14 +501,12 @@ static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - static const WCHAR JScriptW[] = {'J','S','c','r','i','p','t',0}; - TRACE("\n"); if(r) { jsstr_t *ret; - ret = jsstr_alloc(JScriptW); + ret = jsstr_alloc(L"JScript"); if(!ret) return E_OUTOFMEMORY; @@ -947,7 +919,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, FunctionW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Function", PROPF_WRITABLE, jsval_obj(ctx->function_constr)); if(FAILED(hres)) return hres; @@ -956,7 +928,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, ObjectW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Object", PROPF_WRITABLE, jsval_obj(ctx->object_constr)); if(FAILED(hres)) return hres; @@ -965,7 +937,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, ArrayW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Array", PROPF_WRITABLE, jsval_obj(ctx->array_constr)); if(FAILED(hres)) return hres; @@ -974,7 +946,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, BooleanW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Boolean", PROPF_WRITABLE, jsval_obj(ctx->bool_constr)); if(FAILED(hres)) return hres; @@ -983,7 +955,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, DateW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Date", PROPF_WRITABLE, jsval_obj(ctx->date_constr)); if(FAILED(hres)) return hres; @@ -992,7 +964,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, EnumeratorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Enumerator", PROPF_WRITABLE, jsval_obj(ctx->enumerator_constr)); if(FAILED(hres)) return hres; @@ -1001,42 +973,42 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, ErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Error", PROPF_WRITABLE, jsval_obj(ctx->error_constr)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, EvalErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"EvalError", PROPF_WRITABLE, jsval_obj(ctx->eval_error_constr)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, RangeErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"RangeError", PROPF_WRITABLE, jsval_obj(ctx->range_error_constr)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, ReferenceErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"ReferenceError", PROPF_WRITABLE, jsval_obj(ctx->reference_error_constr)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, RegExpErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"RegExpError", PROPF_WRITABLE, jsval_obj(ctx->regexp_error_constr)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, SyntaxErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"SyntaxError", PROPF_WRITABLE, jsval_obj(ctx->syntax_error_constr)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, TypeErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"TypeError", PROPF_WRITABLE, jsval_obj(ctx->type_error_constr)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, URIErrorW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"URIError", PROPF_WRITABLE, jsval_obj(ctx->uri_error_constr)); if(FAILED(hres)) return hres; @@ -1045,7 +1017,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, NumberW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"Number", PROPF_WRITABLE, jsval_obj(ctx->number_constr)); if(FAILED(hres)) return hres; @@ -1054,7 +1026,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, RegExpW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"RegExp", PROPF_WRITABLE, jsval_obj(ctx->regexp_constr)); if(FAILED(hres)) return hres; @@ -1063,7 +1035,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, StringW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"String", PROPF_WRITABLE, jsval_obj(ctx->string_constr)); if(FAILED(hres)) return hres; @@ -1072,7 +1044,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, VBArrayW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"VBArray", PROPF_WRITABLE, jsval_obj(ctx->vbarray_constr)); if(FAILED(hres)) return hres; @@ -1106,7 +1078,7 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, MathW, PROPF_WRITABLE, jsval_obj(math)); + hres = jsdisp_define_data_property(ctx->global, L"Math", PROPF_WRITABLE, jsval_obj(math)); jsdisp_release(math); if(FAILED(hres)) return hres; @@ -1118,7 +1090,7 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, JSONW, PROPF_WRITABLE, jsval_obj(json)); + hres = jsdisp_define_data_property(ctx->global, L"JSON", PROPF_WRITABLE, jsval_obj(json)); jsdisp_release(json); if(FAILED(hres)) return hres; @@ -1128,20 +1100,20 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, ActiveXObjectW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(ctx->global, L"ActiveXObject", PROPF_WRITABLE, jsval_obj(constr)); jsdisp_release(constr); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, undefinedW, const_flags, jsval_undefined()); + hres = jsdisp_define_data_property(ctx->global, L"undefined", const_flags, jsval_undefined()); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, NaNW, const_flags, jsval_number(NAN)); + hres = jsdisp_define_data_property(ctx->global, L"NaN", const_flags, jsval_number(NAN)); if(FAILED(hres)) return hres; - hres = jsdisp_define_data_property(ctx->global, InfinityW, const_flags, jsval_number(INFINITY)); + hres = jsdisp_define_data_property(ctx->global, L"Infinity", const_flags, jsval_number(INFINITY)); return hres; } diff --git a/dlls/jscript/json.c b/dlls/jscript/json.c index de10ceadd11..8f16ba22885 100644 --- a/dlls/jscript/json.c +++ b/dlls/jscript/json.c @@ -26,12 +26,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); -static const WCHAR nullW[] = {'n','u','l','l',0}; -static const WCHAR trueW[] = {'t','r','u','e',0}; -static const WCHAR falseW[] = {'f','a','l','s','e',0}; - -static const WCHAR toJSONW[] = {'t','o','J','S','O','N',0}; - typedef struct { const WCHAR *ptr; const WCHAR *end; @@ -107,19 +101,19 @@ static HRESULT parse_json_value(json_parse_ctx_t *ctx, jsval_t *r) /* JSONNullLiteral */ case 'n': - if(!is_keyword(ctx, nullW)) + if(!is_keyword(ctx, L"null")) break; *r = jsval_null(); return S_OK; /* JSONBooleanLiteral */ case 't': - if(!is_keyword(ctx, trueW)) + if(!is_keyword(ctx, L"true")) break; *r = jsval_bool(TRUE); return S_OK; case 'f': - if(!is_keyword(ctx, falseW)) + if(!is_keyword(ctx, L"false")) break; *r = jsval_bool(FALSE); return S_OK; @@ -476,9 +470,8 @@ static HRESULT json_quote(stringify_ctx_t *ctx, const WCHAR *ptr, size_t len) break; default: if(*ptr < ' ') { - static const WCHAR formatW[] = {'\\','u','%','0','4','x',0}; WCHAR buf[7]; - swprintf(buf, ARRAY_SIZE(buf), formatW, *ptr); + swprintf(buf, ARRAY_SIZE(buf), L"\\u%04x", *ptr); if(!append_string(ctx, buf)) return E_OUTOFMEMORY; }else { @@ -538,10 +531,10 @@ static HRESULT stringify_array(stringify_ctx_t *ctx, jsdisp_t *obj) hres = stringify(ctx, val); if(FAILED(hres)) return hres; - if(hres == S_FALSE && !append_string(ctx, nullW)) + if(hres == S_FALSE && !append_string(ctx, L"null")) return E_OUTOFMEMORY; }else if(hres == DISP_E_UNKNOWNNAME) { - if(!append_string(ctx, nullW)) + if(!append_string(ctx, L"null")) return E_OUTOFMEMORY; }else { return hres; @@ -668,7 +661,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val) if(!obj) return S_FALSE; - hres = jsdisp_get_id(obj, toJSONW, 0, &id); + hres = jsdisp_get_id(obj, L"toJSON", 0, &id); jsdisp_release(obj); if(hres == S_OK) FIXME("Use toJSON.\n"); @@ -682,11 +675,11 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val) switch(jsval_type(value)) { case JSV_NULL: - if(!append_string(ctx, nullW)) + if(!append_string(ctx, L"null")) hres = E_OUTOFMEMORY; break; case JSV_BOOL: - if(!append_string(ctx, get_bool(value) ? trueW : falseW)) + if(!append_string(ctx, get_bool(value) ? L"true" : L"false")) hres = E_OUTOFMEMORY; break; case JSV_STRING: { @@ -714,7 +707,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val) hres = ptr && !append_string_len(ctx, ptr, jsstr_length(str)) ? E_OUTOFMEMORY : S_OK; jsstr_release(str); }else { - if(!append_string(ctx, nullW)) + if(!append_string(ctx, L"null")) hres = E_OUTOFMEMORY; } break; diff --git a/dlls/jscript/jsregexp.c b/dlls/jscript/jsregexp.c index 709f00fa160..f80452d0c0b 100644 --- a/dlls/jscript/jsregexp.c +++ b/dlls/jscript/jsregexp.c @@ -352,11 +352,6 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input_str, DWORD i; HRESULT hres = S_OK; - static const WCHAR indexW[] = {'i','n','d','e','x',0}; - static const WCHAR inputW[] = {'i','n','p','u','t',0}; - static const WCHAR lastIndexW[] = {'l','a','s','t','I','n','d','e','x',0}; - static const WCHAR zeroW[] = {'0',0}; - input = jsstr_flatten(input_str); if(!input) return E_OUTOFMEMORY; @@ -382,15 +377,15 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input_str, } while(SUCCEEDED(hres)) { - hres = jsdisp_propput_name(array, indexW, jsval_number(result->cp-input-result->match_len)); + hres = jsdisp_propput_name(array, L"index", jsval_number(result->cp-input-result->match_len)); if(FAILED(hres)) break; - hres = jsdisp_propput_name(array, lastIndexW, jsval_number(result->cp-input)); + hres = jsdisp_propput_name(array, L"lastIndex", jsval_number(result->cp-input)); if(FAILED(hres)) break; - hres = jsdisp_propput_name(array, inputW, jsval_string(jsstr_addref(input_str))); + hres = jsdisp_propput_name(array, L"input", jsval_string(jsstr_addref(input_str))); if(FAILED(hres)) break; @@ -399,7 +394,7 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input_str, hres = E_OUTOFMEMORY; break; } - hres = jsdisp_propput_name(array, zeroW, jsval_string(str)); + hres = jsdisp_propput_name(array, L"0", jsval_string(str)); jsstr_release(str); break; } @@ -698,10 +693,6 @@ HRESULT create_regexp_var(script_ctx_t *ctx, jsval_t src_arg, jsval_t *flags_arg HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, jsstr_t *jsstr, jsval_t *r) { - static const WCHAR indexW[] = {'i','n','d','e','x',0}; - static const WCHAR inputW[] = {'i','n','p','u','t',0}; - static const WCHAR lastIndexW[] = {'l','a','s','t','I','n','d','e','x',0}; - RegExpInstance *regexp = regexp_from_jsdisp(re); match_result_t *match_result; unsigned match_cnt, i; @@ -778,16 +769,16 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, jsstr_t *jsstr, jsv } while(SUCCEEDED(hres)) { - hres = jsdisp_propput_name(array, indexW, jsval_number(match_result[match_cnt-1].index)); + hres = jsdisp_propput_name(array, L"index", jsval_number(match_result[match_cnt-1].index)); if(FAILED(hres)) break; - hres = jsdisp_propput_name(array, lastIndexW, + hres = jsdisp_propput_name(array, L"lastIndex", jsval_number(match_result[match_cnt-1].index + match_result[match_cnt-1].length)); if(FAILED(hres)) break; - hres = jsdisp_propput_name(array, inputW, jsval_string(jsstr)); + hres = jsdisp_propput_name(array, L"input", jsval_string(jsstr)); break; } @@ -973,13 +964,11 @@ HRESULT create_regexp_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi RegExpInstance *regexp; HRESULT hres; - static const WCHAR RegExpW[] = {'R','e','g','E','x','p',0}; - hres = alloc_regexp(ctx, object_prototype, ®exp); if(FAILED(hres)) return hres; - hres = create_builtin_constructor(ctx, RegExpConstr_value, RegExpW, &RegExpConstr_info, + hres = create_builtin_constructor(ctx, RegExpConstr_value, L"RegExp", &RegExpConstr_info, PROPF_CONSTR|2, ®exp->dispex, ret); jsdisp_release(®exp->dispex); diff --git a/dlls/jscript/jsstr.c b/dlls/jscript/jsstr.c index abd960a8a02..0d73f4be13a 100644 --- a/dlls/jscript/jsstr.c +++ b/dlls/jscript/jsstr.c @@ -315,15 +315,13 @@ HRESULT jsstr_to_bstr(jsstr_t *str, BSTR *r) BOOL init_strings(void) { - static const WCHAR NaNW[] = { 'N','a','N',0 }; - static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0}; WCHAR *ptr; if(!(empty_str = jsstr_alloc_buf(0, &ptr))) return FALSE; - if(!(nan_str = jsstr_alloc(NaNW))) + if(!(nan_str = jsstr_alloc(L"NaN"))) return FALSE; - if(!(undefined_str = jsstr_alloc(undefinedW))) + if(!(undefined_str = jsstr_alloc(L"undefined"))) return FALSE; if(!(null_bstr_str = jsstr_alloc_buf(0, &ptr))) return FALSE; diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index b12addda794..b71a99e372a 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -388,9 +388,6 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsval_t *ret, hint_t hint) DISPID id; HRESULT hres; - static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; - static const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',0}; - if(!get_object(val)) { *ret = jsval_null(); return S_OK; @@ -405,7 +402,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsval_t *ret, hint_t hint) /* Native implementation doesn't throw TypeErrors, returns strange values */ - hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? toStringW : valueOfW, 0, &id); + hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? L"toString" : L"valueOf", 0, &id); if(SUCCEEDED(hres)) { hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, 0, NULL, &prim); if(FAILED(hres)) { @@ -421,7 +418,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsval_t *ret, hint_t hint) } } - hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? valueOfW : toStringW, 0, &id); + hres = jsdisp_get_id(jsdisp, hint == HINT_STRING ? L"valueOf" : L"toString", 0, &id); if(SUCCEEDED(hres)) { hres = jsdisp_call(jsdisp, id, DISPATCH_METHOD, 0, NULL, &prim); if(FAILED(hres)) { @@ -712,12 +709,10 @@ HRESULT to_uint32(script_ctx_t *ctx, jsval_t val, UINT32 *ret) HRESULT double_to_string(double n, jsstr_t **str) { - static const WCHAR InfinityW[] = {'-','I','n','f','i','n','i','t','y',0}; - if(isnan(n)) { *str = jsstr_nan(); }else if(isinf(n)) { - *str = jsstr_alloc(n<0 ? InfinityW : InfinityW+1); + *str = jsstr_alloc(n<0 ? L"-Infinity" : L"-Infinity"+1); }else if(is_int32(n)) { WCHAR buf[12]; _ltow_s(n, buf, ARRAY_SIZE(buf), 10); @@ -744,16 +739,12 @@ HRESULT double_to_string(double n, jsstr_t **str) /* ECMA-262 3rd Edition 9.8 */ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsstr_t **str) { - static const WCHAR nullW[] = {'n','u','l','l',0}; - static const WCHAR trueW[] = {'t','r','u','e',0}; - static const WCHAR falseW[] = {'f','a','l','s','e',0}; - switch(jsval_type(val)) { case JSV_UNDEFINED: *str = jsstr_undefined(); return S_OK; case JSV_NULL: - *str = jsstr_alloc(nullW); + *str = jsstr_alloc(L"null"); break; case JSV_NUMBER: return double_to_string(get_number(val), str); @@ -773,7 +764,7 @@ HRESULT to_string(script_ctx_t *ctx, jsval_t val, jsstr_t **str) return hres; } case JSV_BOOL: - *str = jsstr_alloc(get_bool(val) ? trueW : falseW); + *str = jsstr_alloc(get_bool(val) ? L"true" : L"false"); break; default: FIXME("unsupported %s\n", debugstr_jsval(val)); diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index 9a583e33393..efed1038a95 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -159,10 +159,8 @@ static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval) static BOOL skip_html_comment(parser_ctx_t *ctx) { - const WCHAR html_commentW[] = {'<','!','-','-',0}; - if(!ctx->is_html || ctx->ptr+3 >= ctx->end || - memcmp(ctx->ptr, html_commentW, sizeof(WCHAR)*4)) + memcmp(ctx->ptr, L"