jscript: Use wide-char string literals.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
085f3738a8
commit
59b9747644
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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, ®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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -31,42 +31,6 @@ typedef struct {
|
|||
jsstr_t *str;
|
||||
} StringInstance;
|
||||
|
||||
static const WCHAR lengthW[] = {'l','e','n','g','t','h',0};
|
||||
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};
|
||||
static const WCHAR anchorW[] = {'a','n','c','h','o','r',0};
|
||||
static const WCHAR bigW[] = {'b','i','g',0};
|
||||
static const WCHAR blinkW[] = {'b','l','i','n','k',0};
|
||||
static const WCHAR boldW[] = {'b','o','l','d',0};
|
||||
static const WCHAR charAtW[] = {'c','h','a','r','A','t',0};
|
||||
static const WCHAR charCodeAtW[] = {'c','h','a','r','C','o','d','e','A','t',0};
|
||||
static const WCHAR concatW[] = {'c','o','n','c','a','t',0};
|
||||
static const WCHAR fixedW[] = {'f','i','x','e','d',0};
|
||||
static const WCHAR fontcolorW[] = {'f','o','n','t','c','o','l','o','r',0};
|
||||
static const WCHAR fontsizeW[] = {'f','o','n','t','s','i','z','e',0};
|
||||
static const WCHAR indexOfW[] = {'i','n','d','e','x','O','f',0};
|
||||
static const WCHAR italicsW[] = {'i','t','a','l','i','c','s',0};
|
||||
static const WCHAR lastIndexOfW[] = {'l','a','s','t','I','n','d','e','x','O','f',0};
|
||||
static const WCHAR linkW[] = {'l','i','n','k',0};
|
||||
static const WCHAR matchW[] = {'m','a','t','c','h',0};
|
||||
static const WCHAR replaceW[] = {'r','e','p','l','a','c','e',0};
|
||||
static const WCHAR searchW[] = {'s','e','a','r','c','h',0};
|
||||
static const WCHAR sliceW[] = {'s','l','i','c','e',0};
|
||||
static const WCHAR smallW[] = {'s','m','a','l','l',0};
|
||||
static const WCHAR splitW[] = {'s','p','l','i','t',0};
|
||||
static const WCHAR strikeW[] = {'s','t','r','i','k','e',0};
|
||||
static const WCHAR subW[] = {'s','u','b',0};
|
||||
static const WCHAR substringW[] = {'s','u','b','s','t','r','i','n','g',0};
|
||||
static const WCHAR substrW[] = {'s','u','b','s','t','r',0};
|
||||
static const WCHAR supW[] = {'s','u','p',0};
|
||||
static const WCHAR toLowerCaseW[] = {'t','o','L','o','w','e','r','C','a','s','e',0};
|
||||
static const WCHAR toUpperCaseW[] = {'t','o','U','p','p','e','r','C','a','s','e',0};
|
||||
static const WCHAR toLocaleLowerCaseW[] = {'t','o','L','o','c','a','l','e','L','o','w','e','r','C','a','s','e',0};
|
||||
static const WCHAR toLocaleUpperCaseW[] = {'t','o','L','o','c','a','l','e','U','p','p','e','r','C','a','s','e',0};
|
||||
static const WCHAR trimW[] = {'t','r','i','m',0};
|
||||
static const WCHAR localeCompareW[] = {'l','o','c','a','l','e','C','o','m','p','a','r','e',0};
|
||||
static const WCHAR fromCharCodeW[] = {'f','r','o','m','C','h','a','r','C','o','d','e',0};
|
||||
|
||||
static inline StringInstance *string_from_jsdisp(jsdisp_t *jsdisp)
|
||||
{
|
||||
return CONTAINING_RECORD(jsdisp, StringInstance, dispex);
|
||||
|
@ -255,31 +219,25 @@ static HRESULT do_attribute_tag_format(script_ctx_t *ctx, vdisp_t *jsthis, unsig
|
|||
static HRESULT String_anchor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR fontW[] = {'A',0};
|
||||
static const WCHAR colorW[] = {'N','A','M','E',0};
|
||||
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, L"A", L"NAME");
|
||||
}
|
||||
|
||||
static HRESULT String_big(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR bigtagW[] = {'B','I','G',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, bigtagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"BIG");
|
||||
}
|
||||
|
||||
static HRESULT String_blink(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR blinktagW[] = {'B','L','I','N','K',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, blinktagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"BLINK");
|
||||
}
|
||||
|
||||
static HRESULT String_bold(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR boldtagW[] = {'B',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, boldtagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"B");
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 15.5.4.5 */
|
||||
|
@ -456,26 +414,19 @@ static HRESULT String_concat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
|
|||
static HRESULT String_fixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR fixedtagW[] = {'T','T',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, fixedtagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"TT");
|
||||
}
|
||||
|
||||
static HRESULT String_fontcolor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR fontW[] = {'F','O','N','T',0};
|
||||
static const WCHAR colorW[] = {'C','O','L','O','R',0};
|
||||
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, L"FONT", L"COLOR");
|
||||
}
|
||||
|
||||
static HRESULT String_fontsize(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR fontW[] = {'F','O','N','T',0};
|
||||
static const WCHAR colorW[] = {'S','I','Z','E',0};
|
||||
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, L"FONT", L"SIZE");
|
||||
}
|
||||
|
||||
static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
|
@ -542,8 +493,7 @@ static HRESULT String_indexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
|
|||
static HRESULT String_italics(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR italicstagW[] = {'I',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, italicstagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"I");
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 15.5.4.8 */
|
||||
|
@ -612,10 +562,7 @@ static HRESULT String_lastIndexOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
|
|||
static HRESULT String_link(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR fontW[] = {'A',0};
|
||||
static const WCHAR colorW[] = {'H','R','E','F',0};
|
||||
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, fontW, colorW);
|
||||
return do_attribute_tag_format(ctx, jsthis, argc, argv, r, L"A", L"HREF");
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 15.5.4.10 */
|
||||
|
@ -1123,8 +1070,7 @@ static HRESULT String_slice(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
|
|||
static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR smalltagW[] = {'S','M','A','L','L',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, smalltagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"SMALL");
|
||||
}
|
||||
|
||||
static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
|
@ -1290,15 +1236,13 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
|
|||
static HRESULT String_strike(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR striketagW[] = {'S','T','R','I','K','E',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, striketagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"STRIKE");
|
||||
}
|
||||
|
||||
static HRESULT String_sub(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR subtagW[] = {'S','U','B',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, subtagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"SUB");
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 15.5.4.15 */
|
||||
|
@ -1418,8 +1362,7 @@ static HRESULT String_substr(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
|
|||
static HRESULT String_sup(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
jsval_t *r)
|
||||
{
|
||||
static const WCHAR suptagW[] = {'S','U','P',0};
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, suptagW);
|
||||
return do_attributeless_tag_format(ctx, jsthis, r, L"SUP");
|
||||
}
|
||||
|
||||
static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||
|
@ -1590,40 +1533,40 @@ static HRESULT String_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
|
|||
}
|
||||
|
||||
static const builtin_prop_t String_props[] = {
|
||||
{anchorW, String_anchor, PROPF_METHOD|1},
|
||||
{bigW, String_big, PROPF_METHOD},
|
||||
{blinkW, String_blink, PROPF_METHOD},
|
||||
{boldW, String_bold, PROPF_METHOD},
|
||||
{charAtW, String_charAt, PROPF_METHOD|1},
|
||||
{charCodeAtW, String_charCodeAt, PROPF_METHOD|1},
|
||||
{concatW, String_concat, PROPF_METHOD|1},
|
||||
{fixedW, String_fixed, PROPF_METHOD},
|
||||
{fontcolorW, String_fontcolor, PROPF_METHOD|1},
|
||||
{fontsizeW, String_fontsize, PROPF_METHOD|1},
|
||||
{indexOfW, String_indexOf, PROPF_METHOD|2},
|
||||
{italicsW, String_italics, PROPF_METHOD},
|
||||
{lastIndexOfW, String_lastIndexOf, PROPF_METHOD|2},
|
||||
{lengthW, NULL,0, String_get_length},
|
||||
{linkW, String_link, PROPF_METHOD|1},
|
||||
{localeCompareW, String_localeCompare, PROPF_METHOD|1},
|
||||
{matchW, String_match, PROPF_METHOD|1},
|
||||
{replaceW, String_replace, PROPF_METHOD|1},
|
||||
{searchW, String_search, PROPF_METHOD},
|
||||
{sliceW, String_slice, PROPF_METHOD},
|
||||
{smallW, String_small, PROPF_METHOD},
|
||||
{splitW, String_split, PROPF_METHOD|2},
|
||||
{strikeW, String_strike, PROPF_METHOD},
|
||||
{subW, String_sub, PROPF_METHOD},
|
||||
{substrW, String_substr, PROPF_METHOD|2},
|
||||
{substringW, String_substring, PROPF_METHOD|2},
|
||||
{supW, String_sup, PROPF_METHOD},
|
||||
{toLocaleLowerCaseW, String_toLocaleLowerCase, PROPF_METHOD},
|
||||
{toLocaleUpperCaseW, String_toLocaleUpperCase, PROPF_METHOD},
|
||||
{toLowerCaseW, String_toLowerCase, PROPF_METHOD},
|
||||
{toStringW, String_toString, PROPF_METHOD},
|
||||
{toUpperCaseW, String_toUpperCase, PROPF_METHOD},
|
||||
{trimW, String_trim, PROPF_ES5|PROPF_METHOD},
|
||||
{valueOfW, String_valueOf, PROPF_METHOD}
|
||||
{L"anchor", String_anchor, PROPF_METHOD|1},
|
||||
{L"big", String_big, PROPF_METHOD},
|
||||
{L"blink", String_blink, PROPF_METHOD},
|
||||
{L"bold", String_bold, PROPF_METHOD},
|
||||
{L"charAt", String_charAt, PROPF_METHOD|1},
|
||||
{L"charCodeAt", String_charCodeAt, PROPF_METHOD|1},
|
||||
{L"concat", String_concat, PROPF_METHOD|1},
|
||||
{L"fixed", String_fixed, PROPF_METHOD},
|
||||
{L"fontcolor", String_fontcolor, PROPF_METHOD|1},
|
||||
{L"fontsize", String_fontsize, PROPF_METHOD|1},
|
||||
{L"indexOf", String_indexOf, PROPF_METHOD|2},
|
||||
{L"italics", String_italics, PROPF_METHOD},
|
||||
{L"lastIndexOf", String_lastIndexOf, PROPF_METHOD|2},
|
||||
{L"length", NULL,0, String_get_length},
|
||||
{L"link", String_link, PROPF_METHOD|1},
|
||||
{L"localeCompare", String_localeCompare, PROPF_METHOD|1},
|
||||
{L"match", String_match, PROPF_METHOD|1},
|
||||
{L"replace", String_replace, PROPF_METHOD|1},
|
||||
{L"search", String_search, PROPF_METHOD},
|
||||
{L"slice", String_slice, PROPF_METHOD},
|
||||
{L"small", String_small, PROPF_METHOD},
|
||||
{L"split", String_split, PROPF_METHOD|2},
|
||||
{L"strike", String_strike, PROPF_METHOD},
|
||||
{L"sub", String_sub, PROPF_METHOD},
|
||||
{L"substr", String_substr, PROPF_METHOD|2},
|
||||
{L"substring", String_substring, PROPF_METHOD|2},
|
||||
{L"sup", String_sup, PROPF_METHOD},
|
||||
{L"toLocaleLowerCase", String_toLocaleLowerCase, PROPF_METHOD},
|
||||
{L"toLocaleUpperCase", String_toLocaleUpperCase, PROPF_METHOD},
|
||||
{L"toLowerCase", String_toLowerCase, PROPF_METHOD},
|
||||
{L"toString", String_toString, PROPF_METHOD},
|
||||
{L"toUpperCase", String_toUpperCase, PROPF_METHOD},
|
||||
{L"trim", String_trim, PROPF_ES5|PROPF_METHOD},
|
||||
{L"valueOf", String_valueOf, PROPF_METHOD}
|
||||
};
|
||||
|
||||
static const builtin_info_t String_info = {
|
||||
|
@ -1636,7 +1579,7 @@ static const builtin_info_t String_info = {
|
|||
};
|
||||
|
||||
static const builtin_prop_t StringInst_props[] = {
|
||||
{lengthW, NULL,0, String_get_length}
|
||||
{L"length", NULL,0, String_get_length}
|
||||
};
|
||||
|
||||
static const builtin_info_t StringInst_info = {
|
||||
|
@ -1754,7 +1697,7 @@ static HRESULT string_alloc(script_ctx_t *ctx, jsdisp_t *object_prototype, jsstr
|
|||
}
|
||||
|
||||
static const builtin_prop_t StringConstr_props[] = {
|
||||
{fromCharCodeW, StringConstr_fromCharCode, PROPF_METHOD},
|
||||
{L"fromCharCode", StringConstr_fromCharCode, PROPF_METHOD},
|
||||
};
|
||||
|
||||
static const builtin_info_t StringConstr_info = {
|
||||
|
@ -1771,13 +1714,11 @@ HRESULT create_string_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi
|
|||
StringInstance *string;
|
||||
HRESULT hres;
|
||||
|
||||
static const WCHAR StringW[] = {'S','t','r','i','n','g',0};
|
||||
|
||||
hres = string_alloc(ctx, object_prototype, jsstr_empty(), &string);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = create_builtin_constructor(ctx, StringConstr_value, StringW, &StringConstr_info,
|
||||
hres = create_builtin_constructor(ctx, StringConstr_value, L"String", &StringConstr_info,
|
||||
PROPF_CONSTR|1, &string->dispex, ret);
|
||||
|
||||
jsdisp_release(&string->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;
|
||||
|
|
Loading…
Reference in New Issue