Commit 59b97476 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

jscript: Use wide-char string literals.

parent 085f3738
......@@ -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);
......
......@@ -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);
......
......@@ -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");
}
}
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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))
......
......@@ -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))
......
......@@ -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;
......
......@@ -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, &regexp);
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, &regexp->dispex, ret);
jsdisp_release(&regexp->dispex);
......
......@@ -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;
......
......@@ -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");
}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));
......
......@@ -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"<!--", sizeof(WCHAR)*4))
return FALSE;
ctx->nl = TRUE;
......
......@@ -317,7 +317,6 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
if(log_radix==0)
buf[idx] = 0;
else {
static const WCHAR formatW[] = {'(','e','%','c','%','d',')',0};
WCHAR ch;
if(log_radix<0) {
......@@ -325,7 +324,7 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
ch = '-';
}
else ch = '+';
swprintf(&buf[idx], ARRAY_SIZE(buf) - idx, formatW, ch, (int)log_radix);
swprintf(&buf[idx], ARRAY_SIZE(buf) - idx, L"(e%c%d)", ch, (int)log_radix);
}
}
else buf[idx] = '\0';
......@@ -608,14 +607,12 @@ HRESULT create_number_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi
NumberInstance *number;
HRESULT hres;
static const WCHAR NumberW[] = {'N','u','m','b','e','r',0};
hres = alloc_number(ctx, object_prototype, &number);
if(FAILED(hres))
return hres;
number->value = 0;
hres = create_builtin_constructor(ctx, NumberConstr_value, NumberW, NULL,
hres = create_builtin_constructor(ctx, NumberConstr_value, L"Number", NULL,
PROPF_CONSTR|1, &number->dispex, ret);
jsdisp_release(&number->dispex);
......
......@@ -326,13 +326,11 @@ HRESULT create_vbarray_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsd
VBArrayInstance *vbarray;
HRESULT hres;
static const WCHAR VBArrayW[] = {'V','B','A','r','r','a','y',0};
hres = alloc_vbarray(ctx, object_prototype, &vbarray);
if(FAILED(hres))
return hres;
hres = create_builtin_constructor(ctx, VBArrayConstr_value, VBArrayW, NULL, PROPF_CONSTR|1, &vbarray->dispex, ret);
hres = create_builtin_constructor(ctx, VBArrayConstr_value, L"VBArray", NULL, PROPF_CONSTR|1, &vbarray->dispex, ret);
jsdisp_release(&vbarray->dispex);
return hres;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment