[JSCRIPT] Sync with Wine Staging 4.0. CORE-15682

This commit is contained in:
Amine Khaldi 2019-01-26 13:11:40 +01:00
parent 9a0babd145
commit 660f7b9090
50 changed files with 1562 additions and 1242 deletions

View file

@ -36,6 +36,7 @@ typedef struct {
static const WCHAR lengthW[] = {'l','e','n','g','t','h',0};
static const WCHAR concatW[] = {'c','o','n','c','a','t',0};
static const WCHAR forEachW[] = {'f','o','r','E','a','c','h',0};
static const WCHAR joinW[] = {'j','o','i','n',0};
static const WCHAR popW[] = {'p','o','p',0};
static const WCHAR pushW[] = {'p','u','s','h',0};
@ -950,6 +951,47 @@ static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flag
return E_NOTIMPL;
}
static HRESULT Array_forEach(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r)
{
jsval_t value, args[3], res;
jsdisp_t *jsthis;
unsigned length, i;
HRESULT hres;
TRACE("\n");
/* FIXME: Check IsCallable */
if(argc != 1 || !is_object_instance(argv[0])) {
FIXME("Unsupported arguments\n");
return E_NOTIMPL;
}
hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres))
return hres;
for(i = 0; i < length; i++) {
hres = jsdisp_get_idx(jsthis, i, &value);
if(hres == DISP_E_UNKNOWNNAME)
continue;
if(FAILED(hres))
return hres;
args[0] = value;
args[1] = jsval_number(i);
args[2] = jsval_obj(jsthis);
hres = disp_call_value(ctx, get_object(argv[0]), NULL, DISPATCH_METHOD, ARRAY_SIZE(args), args, &res);
jsval_release(value);
if(FAILED(hres))
return hres;
jsval_release(res);
}
if(r) *r = jsval_undefined();
return S_OK;
}
static HRESULT Array_indexOf(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r)
{
@ -1023,7 +1065,7 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
return hres;
if(argc) {
buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1;
buf_end = buf + ARRAY_SIZE(buf)-1;
*buf_end-- = 0;
i = length;
@ -1103,7 +1145,8 @@ static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
static const builtin_prop_t Array_props[] = {
{concatW, Array_concat, PROPF_METHOD|1},
{indexOfW, Array_indexOf, PROPF_ES5|PROPF_METHOD|1},
{forEachW, Array_forEach, PROPF_METHOD|PROPF_ES5|1},
{indexOfW, Array_indexOf, PROPF_METHOD|PROPF_ES5|1},
{joinW, Array_join, PROPF_METHOD|1},
{lengthW, NULL,0, Array_get_length, Array_set_length},
{popW, Array_pop, PROPF_METHOD},
@ -1121,7 +1164,7 @@ static const builtin_prop_t Array_props[] = {
static const builtin_info_t Array_info = {
JSCLASS_ARRAY,
{NULL, NULL,0, Array_get_value},
sizeof(Array_props)/sizeof(*Array_props),
ARRAY_SIZE(Array_props),
Array_props,
Array_destructor,
Array_on_put
@ -1134,7 +1177,7 @@ static const builtin_prop_t ArrayInst_props[] = {
static const builtin_info_t ArrayInst_info = {
JSCLASS_ARRAY,
{NULL, NULL,0, Array_get_value},
sizeof(ArrayInst_props)/sizeof(*ArrayInst_props),
ARRAY_SIZE(ArrayInst_props),
ArrayInst_props,
Array_destructor,
Array_on_put
@ -1241,7 +1284,7 @@ static const builtin_prop_t ArrayConstr_props[] = {
static const builtin_info_t ArrayConstr_info = {
JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE,
sizeof(ArrayConstr_props)/sizeof(*ArrayConstr_props),
ARRAY_SIZE(ArrayConstr_props),
ArrayConstr_props,
NULL,
NULL

View file

@ -121,7 +121,7 @@ static const builtin_prop_t Bool_props[] = {
static const builtin_info_t Bool_info = {
JSCLASS_BOOLEAN,
{NULL, Bool_value, 0},
sizeof(Bool_props)/sizeof(*Bool_props),
ARRAY_SIZE(Bool_props),
Bool_props,
NULL,
NULL

View file

@ -609,7 +609,7 @@ static HRESULT compile_new_expression(compiler_ctx_t *ctx, call_expression_t *ex
if(FAILED(hres))
return hres;
return push_instr(ctx, OP_push_ret) ? S_OK : E_OUTOFMEMORY;
return push_instr(ctx, OP_push_acc) ? S_OK : E_OUTOFMEMORY;
}
static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *expr, BOOL emit_ret)
@ -651,7 +651,7 @@ static HRESULT compile_call_expression(compiler_ctx_t *ctx, call_expression_t *e
if(FAILED(hres))
return hres;
return !emit_ret || push_instr(ctx, OP_push_ret) ? S_OK : E_OUTOFMEMORY;
return !emit_ret || push_instr(ctx, OP_push_acc) ? S_OK : E_OUTOFMEMORY;
}
static HRESULT compile_delete_expression(compiler_ctx_t *ctx, unary_expression_t *expr)
@ -693,7 +693,7 @@ 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: {
const WCHAR fixmeW[] = {'F','I','X','M','E',0};
static const WCHAR fixmeW[] = {'F','I','X','M','E',0};
WARN("invalid delete, unimplemented exception message\n");
@ -888,8 +888,7 @@ static HRESULT compile_array_literal(compiler_ctx_t *ctx, array_literal_expressi
static HRESULT compile_object_literal(compiler_ctx_t *ctx, property_value_expression_t *expr)
{
prop_val_t *iter;
unsigned instr;
property_definition_t *iter;
BSTR name;
HRESULT hres;
@ -905,11 +904,9 @@ static HRESULT compile_object_literal(compiler_ctx_t *ctx, property_value_expres
if(FAILED(hres))
return hres;
instr = push_instr(ctx, OP_obj_prop);
if(!instr)
return E_OUTOFMEMORY;
instr_ptr(ctx, instr)->u.arg->bstr = name;
hres = push_instr_bstr_uint(ctx, OP_obj_prop, name, iter->type);
if(FAILED(hres))
return hres;
}
return S_OK;
@ -1999,7 +1996,7 @@ static HRESULT visit_expression(compiler_ctx_t *ctx, expression_t *expr)
hres = visit_expression(ctx, ((member_expression_t*)expr)->expression);
break;
case EXPR_PROPVAL: {
prop_val_t *iter;
property_definition_t *iter;
for(iter = ((property_value_expression_t*)expr)->property_list; iter; iter = iter->next) {
hres = visit_expression(ctx, iter->value);
if(FAILED(hres))

View file

@ -523,10 +523,10 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset,
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
week[0] = 0;
GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week, sizeof(week)/sizeof(*week));
GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week, ARRAY_SIZE(week));
month[0] = 0;
GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month, sizeof(month)/sizeof(*month));
GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month, ARRAY_SIZE(month));
year = year_from_time(time);
if(year<0) {
@ -732,10 +732,10 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsva
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
week[0] = 0;
GetLocaleInfoW(lcid_en, week_ids[(int)week_day(date->time)], week, sizeof(week)/sizeof(*week));
GetLocaleInfoW(lcid_en, week_ids[(int)week_day(date->time)], week, ARRAY_SIZE(week));
month[0] = 0;
GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(date->time)], month, sizeof(month)/sizeof(*month));
GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(date->time)], month, ARRAY_SIZE(month));
year = year_from_time(date->time);
if(year<0) {
@ -809,10 +809,10 @@ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r)
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
week[0] = 0;
GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week, sizeof(week)/sizeof(*week));
GetLocaleInfoW(lcid_en, week_ids[(int)week_day(time)], week, ARRAY_SIZE(week));
month[0] = 0;
GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month, sizeof(month)/sizeof(*month));
GetLocaleInfoW(lcid_en, month_ids[(int)month_from_time(time)], month, ARRAY_SIZE(month));
year = year_from_time(time);
if(year<0) {
@ -1983,7 +1983,7 @@ static const builtin_prop_t Date_props[] = {
static const builtin_info_t Date_info = {
JSCLASS_DATE,
{NULL, NULL,0, Date_get_value},
sizeof(Date_props)/sizeof(*Date_props),
ARRAY_SIZE(Date_props),
Date_props,
NULL,
NULL
@ -2037,7 +2037,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
LOCALE_SMONTHNAME1, LOCALE_SDAYNAME7, LOCALE_SDAYNAME1,
LOCALE_SDAYNAME2, LOCALE_SDAYNAME3, LOCALE_SDAYNAME4,
LOCALE_SDAYNAME5, LOCALE_SDAYNAME6 };
WCHAR *strings[sizeof(string_ids)/sizeof(DWORD)];
WCHAR *strings[ARRAY_SIZE(string_ids)];
WCHAR *parse;
int input_len, parse_len = 0, nest_level = 0, i, size;
int year = 0, month = 0, day = 0, hour = 0, min = 0, sec = 0;
@ -2088,7 +2088,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
/* FIXME: Cache strings */
lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT);
for(i=0; i<sizeof(string_ids)/sizeof(DWORD); i++) {
for(i=0; i<ARRAY_SIZE(string_ids); i++) {
size = GetLocaleInfoW(lcid_en, string_ids[i], NULL, 0);
strings[i] = heap_alloc((size+1)*sizeof(WCHAR));
if(!strings[i]) {
@ -2269,7 +2269,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
for(size=i; parse[size]>='A' && parse[size]<='Z'; size++);
size -= i;
for(j=0; j<sizeof(string_ids)/sizeof(DWORD); j++)
for(j=0; j<ARRAY_SIZE(string_ids); j++)
if(!strncmpiW(&parse[i], strings[j], size)) break;
if(j < 12) {
@ -2277,7 +2277,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
set_month = TRUE;
month = 11-j;
}
else if(j == sizeof(string_ids)/sizeof(DWORD)) break;
else if(j == ARRAY_SIZE(string_ids)) break;
i += size;
}
@ -2302,7 +2302,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
*ret = NAN;
}
for(i=0; i<sizeof(string_ids)/sizeof(DWORD); i++)
for(i=0; i<ARRAY_SIZE(string_ids); i++)
heap_free(strings[i]);
heap_free(parse);
@ -2522,7 +2522,7 @@ static const builtin_prop_t DateConstr_props[] = {
static const builtin_info_t DateConstr_info = {
JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE,
sizeof(DateConstr_props)/sizeof(*DateConstr_props),
ARRAY_SIZE(DateConstr_props),
DateConstr_props,
NULL,
NULL

View file

@ -91,7 +91,7 @@ static BOOL decode_dword(const WCHAR *p, DWORD *ret)
DWORD i;
for(i=0; i<6; i++) {
if(p[i] >= sizeof(digits)/sizeof(*digits) || digits[p[i]] == 0xff)
if(p[i] >= ARRAY_SIZE(digits) || digits[p[i]] == 0xff)
return FALSE;
}
if(p[6] != '=' || p[7] != '=')
@ -117,10 +117,10 @@ HRESULT decode_source(WCHAR *code)
static const WCHAR decode_endW[] = {'^','#','~','@'};
while(*src) {
if(!strncmpW(src, decode_beginW, sizeof(decode_beginW)/sizeof(*decode_beginW))) {
if(!strncmpW(src, decode_beginW, ARRAY_SIZE(decode_beginW))) {
DWORD len, i, j=0, csum, s=0;
src += sizeof(decode_beginW)/sizeof(*decode_beginW);
src += ARRAY_SIZE(decode_beginW);
if(!decode_dword(src, &len))
return JS_E_INVALID_CHAR;
@ -165,9 +165,9 @@ HRESULT decode_source(WCHAR *code)
return JS_E_INVALID_CHAR;
src += 8;
if(strncmpW(src, decode_endW, sizeof(decode_endW)/sizeof(*decode_endW)))
if(strncmpW(src, decode_endW, ARRAY_SIZE(decode_endW)))
return JS_E_INVALID_CHAR;
src += sizeof(decode_endW)/sizeof(*decode_endW);
src += ARRAY_SIZE(decode_endW);
}else {
*dst++ = *src++;
}

View file

@ -1290,7 +1290,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
dp.rgdispidNamedArgs = NULL;
}
if(dp.cArgs > sizeof(buf)/sizeof(*buf)) {
if(dp.cArgs > ARRAY_SIZE(buf)) {
dp.rgvarg = heap_alloc(dp.cArgs*sizeof(VARIANT));
if(!dp.rgvarg) {
if(dispex)

View file

@ -390,9 +390,10 @@ static inline jsval_t steal_ret(call_frame_t *frame)
return r;
}
static inline void clear_ret(call_frame_t *frame)
static inline void clear_acc(script_ctx_t *ctx)
{
jsval_release(steal_ret(frame));
jsval_release(ctx->acc);
ctx->acc = jsval_undefined();
}
static HRESULT scope_push(scope_chain_t *scope, jsdisp_t *jsobj, IDispatch *obj, scope_chain_t **ret)
@ -1160,7 +1161,6 @@ static HRESULT interp_refval(script_ctx_t *ctx)
static HRESULT interp_new(script_ctx_t *ctx)
{
const unsigned argc = get_op_uint(ctx, 0);
call_frame_t *frame = ctx->call_ctx;
jsval_t constr;
TRACE("%d\n", argc);
@ -1176,9 +1176,9 @@ static HRESULT interp_new(script_ctx_t *ctx)
else if(!get_object(constr))
return throw_type_error(ctx, JS_E_INVALID_PROPERTY, NULL);
clear_ret(frame);
clear_acc(ctx);
return disp_call_value(ctx, get_object(constr), NULL, DISPATCH_CONSTRUCT | DISPATCH_JSCRIPT_CALLEREXECSSOURCE,
argc, stack_args(ctx, argc), &frame->ret);
argc, stack_args(ctx, argc), &ctx->acc);
}
/* ECMA-262 3rd Edition 11.2.3 */
@ -1186,7 +1186,6 @@ static HRESULT interp_call(script_ctx_t *ctx)
{
const unsigned argn = get_op_uint(ctx, 0);
const int do_ret = get_op_int(ctx, 1);
call_frame_t *frame = ctx->call_ctx;
jsval_t obj;
TRACE("%d %d\n", argn, do_ret);
@ -1195,9 +1194,9 @@ static HRESULT interp_call(script_ctx_t *ctx)
if(!is_object_instance(obj))
return throw_type_error(ctx, JS_E_INVALID_PROPERTY, NULL);
clear_ret(frame);
clear_acc(ctx);
return disp_call_value(ctx, get_object(obj), NULL, DISPATCH_METHOD | DISPATCH_JSCRIPT_CALLEREXECSSOURCE,
argn, stack_args(ctx, argn), do_ret ? &frame->ret : NULL);
argn, stack_args(ctx, argn), do_ret ? &ctx->acc : NULL);
}
/* ECMA-262 3rd Edition 11.2.3 */
@ -1205,7 +1204,6 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
{
const unsigned argn = get_op_uint(ctx, 0);
const int do_ret = get_op_int(ctx, 1);
call_frame_t *frame = ctx->call_ctx;
exprval_t ref;
TRACE("%d %d\n", argn, do_ret);
@ -1213,9 +1211,9 @@ static HRESULT interp_call_member(script_ctx_t *ctx)
if(!stack_topn_exprval(ctx, argn, &ref))
return throw_type_error(ctx, ref.u.hres, NULL);
clear_ret(frame);
clear_acc(ctx);
return exprval_call(ctx, &ref, DISPATCH_METHOD | DISPATCH_JSCRIPT_CALLEREXECSSOURCE,
argn, stack_args(ctx, argn), do_ret ? &frame->ret : NULL);
argn, stack_args(ctx, argn), do_ret ? &ctx->acc : NULL);
}
/* ECMA-262 3rd Edition 11.1.1 */
@ -1452,6 +1450,7 @@ static HRESULT interp_new_obj(script_ctx_t *ctx)
static HRESULT interp_obj_prop(script_ctx_t *ctx)
{
const BSTR name = get_op_bstr(ctx, 0);
unsigned type = get_op_uint(ctx, 1);
jsdisp_t *obj;
jsval_t val;
HRESULT hres;
@ -1463,7 +1462,28 @@ static HRESULT interp_obj_prop(script_ctx_t *ctx)
assert(is_object_instance(stack_top(ctx)));
obj = as_jsdisp(get_object(stack_top(ctx)));
hres = jsdisp_propput_name(obj, name, val);
if(type == PROPERTY_DEFINITION_VALUE) {
hres = jsdisp_propput_name(obj, name, val);
}else {
property_desc_t desc = {PROPF_ENUMERABLE | PROPF_CONFIGURABLE};
jsdisp_t *func;
assert(is_object_instance(val));
func = iface_to_jsdisp(get_object(val));
desc.mask = desc.flags;
if(type == PROPERTY_DEFINITION_GETTER) {
desc.explicit_getter = TRUE;
desc.getter = func;
}else {
desc.explicit_setter = TRUE;
desc.setter = func;
}
hres = jsdisp_define_property(obj, name, &desc);
jsdisp_release(func);
}
jsval_release(val);
return hres;
}
@ -2605,16 +2625,15 @@ static HRESULT interp_setret(script_ctx_t *ctx)
return S_OK;
}
static HRESULT interp_push_ret(script_ctx_t *ctx)
static HRESULT interp_push_acc(script_ctx_t *ctx)
{
call_frame_t *frame = ctx->call_ctx;
HRESULT hres;
TRACE("\n");
hres = stack_push(ctx, frame->ret);
hres = stack_push(ctx, ctx->acc);
if(SUCCEEDED(hres))
frame->ret = jsval_undefined();
ctx->acc = jsval_undefined();
return hres;
}
@ -2801,8 +2820,8 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, jsval_t *r)
assert(frame->scope == frame->base_scope);
if(return_to_interp) {
clear_ret(frame->prev_frame);
frame->prev_frame->ret = steal_ret(frame);
jsval_release(ctx->acc);
ctx->acc = steal_ret(frame);
}else if(r) {
*r = steal_ret(frame);
}

View file

@ -68,15 +68,15 @@
X(new, 1, ARG_UINT, 0) \
X(new_obj, 1, 0,0) \
X(null, 1, 0,0) \
X(obj_prop, 1, ARG_BSTR, 0) \
X(obj_prop, 1, ARG_BSTR, ARG_UINT) \
X(or, 1, 0,0) \
X(pop, 1, ARG_UINT, 0) \
X(pop_except, 0, ARG_ADDR, 0) \
X(pop_scope, 1, 0,0) \
X(postinc, 1, ARG_INT, 0) \
X(preinc, 1, ARG_INT, 0) \
X(push_acc, 1, 0,0) \
X(push_except,1, ARG_ADDR, ARG_UINT) \
X(push_ret, 1, 0,0) \
X(push_scope, 1, 0,0) \
X(regexp, 1, ARG_STR, ARG_UINT) \
X(rshift, 1, 0,0) \
@ -131,6 +131,12 @@ typedef struct {
} u;
} instr_t;
typedef enum {
PROPERTY_DEFINITION_VALUE,
PROPERTY_DEFINITION_GETTER,
PROPERTY_DEFINITION_SETTER
} property_definition_type_t;
typedef struct {
BSTR name;
int ref;

View file

@ -144,7 +144,7 @@ static const builtin_prop_t Error_props[] = {
static const builtin_info_t Error_info = {
JSCLASS_ERROR,
{NULL, Error_value, 0},
sizeof(Error_props)/sizeof(*Error_props),
ARRAY_SIZE(Error_props),
Error_props,
NULL,
NULL
@ -348,7 +348,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, jsdisp_t *object_prototype)
jsstr_t *str;
HRESULT hres;
for(i=0; i < sizeof(names)/sizeof(names[0]); i++) {
for(i=0; i < ARRAY_SIZE(names); i++) {
hres = alloc_error(ctx, i==0 ? object_prototype : NULL, NULL, &err);
if(FAILED(hres))
return hres;
@ -385,7 +385,7 @@ static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, j
return error;
buf[0] = '\0';
LoadStringW(jscript_hinstance, HRESULT_CODE(error), buf, sizeof(buf)/sizeof(WCHAR));
LoadStringW(jscript_hinstance, HRESULT_CODE(error), buf, ARRAY_SIZE(buf));
if(str) pos = strchrW(buf, '|');
if(pos) {

View file

@ -304,12 +304,12 @@ static HRESULT function_to_string(FunctionInstance *function, jsstr_t **ret)
WCHAR *ptr;
name_len = strlenW(function->name);
str = jsstr_alloc_buf((sizeof(native_prefixW)+sizeof(native_suffixW))/sizeof(WCHAR) + name_len, &ptr);
str = jsstr_alloc_buf(ARRAY_SIZE(native_prefixW) + ARRAY_SIZE(native_suffixW) + name_len, &ptr);
if(!str)
return E_OUTOFMEMORY;
memcpy(ptr, native_prefixW, sizeof(native_prefixW));
memcpy(ptr += sizeof(native_prefixW)/sizeof(WCHAR), function->name, name_len*sizeof(WCHAR));
memcpy(ptr += ARRAY_SIZE(native_prefixW), function->name, name_len*sizeof(WCHAR));
memcpy(ptr + name_len, native_suffixW, sizeof(native_suffixW));
}else {
str = jsstr_alloc_len(function->func_code->source, function->func_code->source_len);
@ -593,7 +593,7 @@ static const builtin_prop_t Function_props[] = {
static const builtin_info_t Function_info = {
JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE,
sizeof(Function_props)/sizeof(*Function_props),
ARRAY_SIZE(Function_props),
Function_props,
Function_destructor,
NULL
@ -607,7 +607,7 @@ static const builtin_prop_t FunctionInst_props[] = {
static const builtin_info_t FunctionInst_info = {
JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE,
sizeof(FunctionInst_props)/sizeof(*FunctionInst_props),
ARRAY_SIZE(FunctionInst_props),
FunctionInst_props,
Function_destructor,
NULL
@ -764,11 +764,11 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg
}
if(SUCCEEDED(hres)) {
len += (sizeof(function_anonymousW) + sizeof(function_beginW) + sizeof(function_endW)) / sizeof(WCHAR);
len += ARRAY_SIZE(function_anonymousW) + ARRAY_SIZE(function_beginW) + ARRAY_SIZE(function_endW);
str = heap_alloc(len*sizeof(WCHAR));
if(str) {
memcpy(str, function_anonymousW, sizeof(function_anonymousW));
ptr = str + sizeof(function_anonymousW)/sizeof(WCHAR);
ptr = str + ARRAY_SIZE(function_anonymousW);
if(argc > 1) {
while(1) {
ptr += jsstr_flush(params[j], ptr);
@ -779,7 +779,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg
}
}
memcpy(ptr, function_beginW, sizeof(function_beginW));
ptr += sizeof(function_beginW)/sizeof(WCHAR);
ptr += ARRAY_SIZE(function_beginW);
if(argc)
ptr += jsstr_flush(params[argc-1], ptr);
memcpy(ptr, function_endW, sizeof(function_endW));

View file

@ -964,7 +964,7 @@ static const builtin_prop_t JSGlobal_props[] = {
static const builtin_info_t JSGlobal_info = {
JSCLASS_GLOBAL,
{NULL, NULL, 0},
sizeof(JSGlobal_props)/sizeof(*JSGlobal_props),
ARRAY_SIZE(JSGlobal_props),
JSGlobal_props,
NULL,
NULL

View file

@ -69,6 +69,7 @@ void script_release(script_ctx_t *ctx)
if(--ctx->ref)
return;
jsval_release(ctx->acc);
clear_ei(ctx);
if(ctx->cc)
release_cc(ctx->cc);
@ -715,6 +716,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface)
ctx->version = This->version;
ctx->html_mode = This->html_mode;
ctx->ei.val = jsval_undefined();
ctx->acc = jsval_undefined();
heap_pool_init(&ctx->tmp_heap);
hres = create_jscaller(ctx);

View file

@ -92,10 +92,12 @@ extern HINSTANCE jscript_hinstance DECLSPEC_HIDDEN;
#define PROPF_ARGMASK 0x00ff
#define PROPF_METHOD 0x0100
#define PROPF_ENUMERABLE 0x0200
#define PROPF_CONSTR 0x0400
#define PROPF_CONSTR 0x0200
#define PROPF_ENUMERABLE 0x0400
#define PROPF_WRITABLE 0x0800
#define PROPF_CONFIGURABLE 0x1000
#define PROPF_ALL (PROPF_ENUMERABLE | PROPF_WRITABLE | PROPF_CONFIGURABLE)
#define PROPF_VERSION_MASK 0x01ff0000
#define PROPF_VERSION_SHIFT 16
@ -424,6 +426,7 @@ struct _script_ctx_t {
jsval_t *stack;
unsigned stack_size;
unsigned stack_top;
jsval_t acc;
jsstr_t *last_match;
match_result_t match_parens[9];

View file

@ -487,7 +487,7 @@ static HRESULT json_quote(stringify_ctx_t *ctx, const WCHAR *ptr, size_t len)
break;
default:
if(*ptr < ' ') {
const WCHAR formatW[] = {'\\','u','%','0','4','x',0};
static const WCHAR formatW[] = {'\\','u','%','0','4','x',0};
WCHAR buf[7];
sprintfW(buf, formatW, *ptr);
if(!append_string(ctx, buf))
@ -836,7 +836,7 @@ static const builtin_prop_t JSON_props[] = {
static const builtin_info_t JSON_info = {
JSCLASS_JSON,
{NULL, NULL, 0},
sizeof(JSON_props)/sizeof(*JSON_props),
ARRAY_SIZE(JSON_props),
JSON_props,
NULL,
NULL

View file

@ -96,7 +96,7 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp,
}
if(!(rem_flags & REM_NO_CTX_UPDATE)) {
DWORD i, n = min(sizeof(ctx->match_parens)/sizeof(ctx->match_parens[0]), ret->paren_count);
DWORD i, n = min(ARRAY_SIZE(ctx->match_parens), ret->paren_count);
for(i=0; i < n; i++) {
if(ret->parens[i].index == -1) {
@ -108,7 +108,7 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp,
}
}
if(n < sizeof(ctx->match_parens)/sizeof(ctx->match_parens[0]))
if(n < ARRAY_SIZE(ctx->match_parens))
memset(ctx->match_parens+n, 0, sizeof(ctx->match_parens) - n*sizeof(ctx->match_parens[0]));
}
@ -595,7 +595,7 @@ static const builtin_prop_t RegExp_props[] = {
static const builtin_info_t RegExp_info = {
JSCLASS_REGEXP,
{NULL, RegExp_value, 0},
sizeof(RegExp_props)/sizeof(*RegExp_props),
ARRAY_SIZE(RegExp_props),
RegExp_props,
RegExp_destructor,
NULL
@ -612,7 +612,7 @@ static const builtin_prop_t RegExpInst_props[] = {
static const builtin_info_t RegExpInst_info = {
JSCLASS_REGEXP,
{NULL, RegExp_value, 0},
sizeof(RegExpInst_props)/sizeof(*RegExpInst_props),
ARRAY_SIZE(RegExpInst_props),
RegExpInst_props,
RegExp_destructor,
NULL
@ -995,7 +995,7 @@ static const builtin_prop_t RegExpConstr_props[] = {
static const builtin_info_t RegExpConstr_info = {
JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE,
sizeof(RegExpConstr_props)/sizeof(*RegExpConstr_props),
ARRAY_SIZE(RegExpConstr_props),
RegExpConstr_props,
NULL,
NULL

View file

@ -526,8 +526,8 @@ static HRESULT str_to_number(jsstr_t *str, double *ret)
ptr++;
}
if(!strncmpW(ptr, infinityW, sizeof(infinityW)/sizeof(WCHAR))) {
ptr += sizeof(infinityW)/sizeof(WCHAR);
if(!strncmpW(ptr, infinityW, ARRAY_SIZE(infinityW))) {
ptr += ARRAY_SIZE(infinityW);
while(*ptr && isspaceW(*ptr))
ptr++;
@ -701,7 +701,7 @@ static jsstr_t *int_to_string(int i)
i = -i;
}
p = buf + sizeof(buf)/sizeof(*buf)-1;
p = buf + ARRAY_SIZE(buf)-1;
*p-- = 0;
while(i) {
*p-- = i%10 + '0';
@ -718,7 +718,7 @@ static jsstr_t *int_to_string(int i)
HRESULT double_to_string(double n, jsstr_t **str)
{
const WCHAR InfinityW[] = {'-','I','n','f','i','n','i','t','y',0};
static const WCHAR InfinityW[] = {'-','I','n','f','i','n','i','t','y',0};
if(isnan(n)) {
*str = jsstr_nan();
@ -748,9 +748,9 @@ 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)
{
const WCHAR nullW[] = {'n','u','l','l',0};
const WCHAR trueW[] = {'t','r','u','e',0};
const WCHAR falseW[] = {'f','a','l','s','e',0};
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:

View file

@ -64,4 +64,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Array længde skal være et endeligt positivt heltal"
IDS_ARRAY_EXPECTED "Array objekt forventet"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -63,4 +63,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Größe des Array muss eine endliche, positive Ganzzahl sein"
IDS_ARRAY_EXPECTED "Array-Objekt erwartet"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -61,4 +61,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Array length must be a finite positive integer"
IDS_ARRAY_EXPECTED "Array object expected"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -64,4 +64,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "La longitud del arreglo debe ser un entero positivo finito"
IDS_ARRAY_EXPECTED "Objeto Arreglo esperado"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -66,4 +66,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "La longueur d'un tableau doit être un entier positif"
IDS_ARRAY_EXPECTED "Objet tableau attendu"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -63,4 +63,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Array length must be a finite positive integer"
IDS_ARRAY_EXPECTED "אובייקט מערך היה צפוי"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -64,4 +64,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "A tömb hosszának egy véges pozitív egész számnak kell lennie"
IDS_ARRAY_EXPECTED "Tömb objektumot vártam"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -65,4 +65,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "La lunghezza dell'array deve essere un intero finito e positivo"
IDS_ARRAY_EXPECTED "Richiesto un oggetto array"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -65,4 +65,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "配列の長さは有限の正整数でなければなりません"
IDS_ARRAY_EXPECTED "配列オブジェクトを期待していました"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -65,4 +65,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "배열 길이는 반드시 한정된 양의 정수이어야 합니다"
IDS_ARRAY_EXPECTED "배열 객체가 필요합니다"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -64,4 +64,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Masyvo dydis turi būti teigiamas sveikasis skaičius"
IDS_ARRAY_EXPECTED "Tikėtasi masyvo objekto"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -63,4 +63,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Array lengte moet een eindig, positief geheel getal zijn"
IDS_ARRAY_EXPECTED "Array object verwacht"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -63,4 +63,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Rekkens lengde må være et endelig, positivt tall"
IDS_ARRAY_EXPECTED "Forventet rekke-objekt"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -61,4 +61,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precyzja jest poza zakresem"
IDS_INVALID_LENGTH "Długość tablicy musi być skończoną dodatnią liczbą stałą"
IDS_ARRAY_EXPECTED "Oczekiwany obiekt tablicowy"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -64,6 +64,10 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Tamanho do vetor tem que ser um inteiro finito positivo"
IDS_ARRAY_EXPECTED "Objeto Array esperado"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}
LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE
@ -111,4 +115,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Tamanho do vector tem de ser um inteiro finito positivo"
IDS_ARRAY_EXPECTED "Objecto Array esperado"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -66,4 +66,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precizia este în afara limitelor admise"
IDS_INVALID_LENGTH "Lungimea unei matrice trebuie să fie un număr întreg pozitiv"
IDS_ARRAY_EXPECTED "Era așteptat un obiect matrice"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -65,4 +65,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Точность вне диапазона"
IDS_INVALID_LENGTH "Длиной массива должно быть конечное положительное число"
IDS_ARRAY_EXPECTED "Предполагается наличие объекта 'Array'"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -63,4 +63,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Dožina polja mora bit pozitivno celo število"
IDS_ARRAY_EXPECTED "Pričakujem Array objekt"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -64,4 +64,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Gjatësia e një grupi duhet të jetë një numër i plotë pozitiv i caktuar"
IDS_ARRAY_EXPECTED "Objekti Array Pritej"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -61,4 +61,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Duyarlılık aralık dışında."
IDS_INVALID_LENGTH "Dizi büyüklüğü bir sonlu artı tam sayı olmalı."
IDS_ARRAY_EXPECTED "Dizi nesnesi bekleniyordu."
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -65,4 +65,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "Precision is out of range"
IDS_INVALID_LENGTH "Довжиною масиву повинне бути скінченне додатнє ціле число"
IDS_ARRAY_EXPECTED "Очікується об'єкт Array"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -65,6 +65,10 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "精度是超出范围"
IDS_INVALID_LENGTH "数组长度必须为一个有限的正整数"
IDS_ARRAY_EXPECTED "预期的数组对象"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
@ -112,4 +116,8 @@ STRINGTABLE
IDS_PRECISION_OUT_OF_RANGE "精度是超出範圍"
IDS_INVALID_LENGTH "陣列長度必須為一個有限的正整數"
IDS_ARRAY_EXPECTED "預期的陣列物件"
IDS_INVALID_WRITABLE_PROP_DESC "'writable' attribute on the property descriptor cannot be set to 'true' on this object"
IDS_NONCONFIGURABLE_REDEFINED "Cannot redefine non-configurable property '|'"
IDS_NONWRITABLE_MODIFIED "Cannot modify non-writable property '|'"
IDS_PROP_DESC_MISMATCH "Property cannot have both accessors and a value"
}

View file

@ -32,6 +32,12 @@
#include "wine/debug.h"
#include "wine/unicode.h"
#ifdef __REACTOS__
/* FIXME: Inspect - For some reason these exist in the generated header but are not picked up */
#define kGET (270)
#define kSET (272)
#endif
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
static const WCHAR breakW[] = {'b','r','e','a','k',0};
@ -46,12 +52,14 @@ static const WCHAR falseW[] = {'f','a','l','s','e',0};
static const WCHAR finallyW[] = {'f','i','n','a','l','l','y',0};
static const WCHAR forW[] = {'f','o','r',0};
static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
static const WCHAR getW[] = {'g','e','t',0};
static const WCHAR ifW[] = {'i','f',0};
static const WCHAR inW[] = {'i','n',0};
static const WCHAR instanceofW[] = {'i','n','s','t','a','n','c','e','o','f',0};
static const WCHAR newW[] = {'n','e','w',0};
static const WCHAR nullW[] = {'n','u','l','l',0};
static const WCHAR returnW[] = {'r','e','t','u','r','n',0};
static const WCHAR setW[] = {'s','e','t',0};
static const WCHAR switchW[] = {'s','w','i','t','c','h',0};
static const WCHAR thisW[] = {'t','h','i','s',0};
static const WCHAR throwW[] = {'t','h','r','o','w',0};
@ -70,11 +78,12 @@ static const struct {
const WCHAR *word;
int token;
BOOL no_nl;
unsigned min_version;
} keywords[] = {
{breakW, kBREAK, TRUE},
{breakW, kBREAK, TRUE},
{caseW, kCASE},
{catchW, kCATCH},
{continueW, kCONTINUE, TRUE},
{continueW, kCONTINUE, TRUE},
{defaultW, kDEFAULT},
{deleteW, kDELETE},
{doW, kDO},
@ -83,12 +92,14 @@ static const struct {
{finallyW, kFINALLY},
{forW, kFOR},
{functionW, kFUNCTION},
{getW, kGET, FALSE, SCRIPTLANGUAGEVERSION_ES5},
{ifW, kIF},
{inW, kIN},
{instanceofW, kINSTANCEOF},
{newW, kNEW},
{nullW, kNULL},
{returnW, kRETURN, TRUE},
{returnW, kRETURN, TRUE},
{setW, kSET, FALSE, SCRIPTLANGUAGEVERSION_ES5},
{switchW, kSWITCH},
{thisW, kTHIS},
{throwW, kTHROW},
@ -162,13 +173,19 @@ static int hex_to_int(WCHAR c)
static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval)
{
int min = 0, max = sizeof(keywords)/sizeof(keywords[0])-1, r, i;
int min = 0, max = ARRAY_SIZE(keywords)-1, r, i;
while(min <= max) {
i = (min+max)/2;
r = check_keyword(ctx, keywords[i].word, lval);
if(!r) {
if(ctx->script->version < keywords[i].min_version) {
TRACE("ignoring keyword %s in incompatible mode\n",
debugstr_w(keywords[i].word));
ctx->ptr -= strlenW(keywords[i].word);
return 0;
}
ctx->implicit_nl_semicolon = keywords[i].no_nl;
return keywords[i].token;
}

View file

@ -522,7 +522,7 @@ static const builtin_prop_t Math_props[] = {
static const builtin_info_t Math_info = {
JSCLASS_MATH,
{NULL, NULL, 0},
sizeof(Math_props)/sizeof(*Math_props),
ARRAY_SIZE(Math_props),
Math_props,
NULL,
NULL
@ -558,7 +558,7 @@ HRESULT create_math(script_ctx_t *ctx, jsdisp_t **ret)
return hres;
}
for(i=0; i < sizeof(constants)/sizeof(*constants); i++) {
for(i=0; i < ARRAY_SIZE(constants); i++) {
hres = jsdisp_define_data_property(math, constants[i].name, 0,
jsval_number(constants[i].val));
if(FAILED(hres)) {

View file

@ -524,7 +524,7 @@ static const builtin_prop_t Number_props[] = {
static const builtin_info_t Number_info = {
JSCLASS_NUMBER,
{NULL, NULL,0, Number_get_value},
sizeof(Number_props)/sizeof(*Number_props),
ARRAY_SIZE(Number_props),
Number_props,
NULL,
NULL

View file

@ -252,7 +252,7 @@ static const builtin_prop_t Object_props[] = {
static const builtin_info_t Object_info = {
JSCLASS_OBJECT,
{NULL, NULL,0, Object_get_value},
sizeof(Object_props)/sizeof(*Object_props),
ARRAY_SIZE(Object_props),
Object_props,
Object_destructor,
NULL
@ -493,23 +493,23 @@ static HRESULT Object_getOwnPropertyDescriptor(script_ctx_t *ctx, vdisp_t *jsthi
return hres;
if(prop_desc.explicit_getter || prop_desc.explicit_setter) {
hres = jsdisp_propput_name(desc_obj, getW, prop_desc.getter
? jsval_obj(prop_desc.getter) : jsval_undefined());
hres = jsdisp_define_data_property(desc_obj, getW, PROPF_ALL,
prop_desc.getter ? jsval_obj(prop_desc.getter) : jsval_undefined());
if(SUCCEEDED(hres))
hres = jsdisp_propput_name(desc_obj, setW, prop_desc.setter
? jsval_obj(prop_desc.setter) : jsval_undefined());
hres = jsdisp_define_data_property(desc_obj, setW, PROPF_ALL,
prop_desc.setter ? jsval_obj(prop_desc.setter) : jsval_undefined());
}else {
hres = jsdisp_propput_name(desc_obj, valueW, prop_desc.value);
if(SUCCEEDED(hres))
hres = jsdisp_propput_name(desc_obj, writableW,
jsval_bool(!!(prop_desc.flags & PROPF_WRITABLE)));
hres = jsdisp_define_data_property(desc_obj, writableW, PROPF_ALL,
jsval_bool(!!(prop_desc.flags & PROPF_WRITABLE)));
}
if(SUCCEEDED(hres))
hres = jsdisp_propput_name(desc_obj, enumerableW,
jsval_bool(!!(prop_desc.flags & PROPF_ENUMERABLE)));
hres = jsdisp_define_data_property(desc_obj, enumerableW, PROPF_ALL,
jsval_bool(!!(prop_desc.flags & PROPF_ENUMERABLE)));
if(SUCCEEDED(hres))
hres = jsdisp_propput_name(desc_obj, configurableW,
jsval_bool(!!(prop_desc.flags & PROPF_CONFIGURABLE)));
hres = jsdisp_define_data_property(desc_obj, configurableW, PROPF_ALL,
jsval_bool(!!(prop_desc.flags & PROPF_CONFIGURABLE)));
release_property_descriptor(&prop_desc);
if(SUCCEEDED(hres) && r)
@ -528,7 +528,7 @@ static const builtin_prop_t ObjectConstr_props[] = {
static const builtin_info_t ObjectConstr_info = {
JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE,
sizeof(ObjectConstr_props)/sizeof(*ObjectConstr_props),
ARRAY_SIZE(ObjectConstr_props),
ObjectConstr_props,
NULL,
NULL

View file

@ -360,16 +360,17 @@ typedef struct {
int length;
} array_literal_expression_t;
typedef struct _prop_val_t {
typedef struct _property_definition_t {
unsigned type;
literal_t *name;
expression_t *value;
struct _prop_val_t *next;
} prop_val_t;
struct _property_definition_t *next;
} property_definition_t;
typedef struct {
expression_t expr;
prop_val_t *property_list;
property_definition_t *property_list;
} property_value_expression_t;
BOOL try_parse_ccval(parser_ctx_t*,ccval_t*) DECLSPEC_HIDDEN;

File diff suppressed because it is too large Load diff

View file

@ -57,39 +57,41 @@ extern int parser_debug;
kIF = 267,
kFINALLY = 268,
kFOR = 269,
kIN = 270,
kINSTANCEOF = 271,
kNEW = 272,
kNULL = 273,
kRETURN = 274,
kSWITCH = 275,
kTHIS = 276,
kTHROW = 277,
kTRUE = 278,
kFALSE = 279,
kTRY = 280,
kTYPEOF = 281,
kVAR = 282,
kVOID = 283,
kWHILE = 284,
kWITH = 285,
tANDAND = 286,
tOROR = 287,
tINC = 288,
tDEC = 289,
tHTMLCOMMENT = 290,
kDIVEQ = 291,
kDCOL = 292,
tIdentifier = 293,
tAssignOper = 294,
tEqOper = 295,
tShiftOper = 296,
tRelOper = 297,
tNumericLiteral = 298,
tBooleanLiteral = 299,
tStringLiteral = 300,
tEOF = 301,
LOWER_THAN_ELSE = 302
kGET = 270,
kIN = 271,
kSET = 272,
kINSTANCEOF = 273,
kNEW = 274,
kNULL = 275,
kRETURN = 276,
kSWITCH = 277,
kTHIS = 278,
kTHROW = 279,
kTRUE = 280,
kFALSE = 281,
kTRY = 282,
kTYPEOF = 283,
kVAR = 284,
kVOID = 285,
kWHILE = 286,
kWITH = 287,
tANDAND = 288,
tOROR = 289,
tINC = 290,
tDEC = 291,
tHTMLCOMMENT = 292,
kDIVEQ = 293,
kDCOL = 294,
tIdentifier = 295,
tAssignOper = 296,
tEqOper = 297,
tShiftOper = 298,
tRelOper = 299,
tNumericLiteral = 300,
tBooleanLiteral = 301,
tStringLiteral = 302,
tEOF = 303,
LOWER_THAN_ELSE = 304
};
#endif
@ -98,7 +100,7 @@ extern int parser_debug;
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 145 "parser.y" /* yacc.c:1909 */
#line 147 "parser.y" /* yacc.c:1909 */
int ival;
const WCHAR *srcptr;
@ -113,13 +115,14 @@ union YYSTYPE
const WCHAR *identifier;
struct _parameter_list_t *parameter_list;
struct _property_list_t *property_list;
property_definition_t *property_definition;
source_elements_t *source_elements;
statement_t *statement;
struct _statement_list_t *statement_list;
struct _variable_list_t *variable_list;
variable_declaration_t *variable_declaration;
#line 123 "parser.tab.h" /* yacc.c:1909 */
#line 126 "parser.tab.h" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1

View file

@ -41,12 +41,14 @@ static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*);
static literal_t *new_null_literal(parser_ctx_t*);
typedef struct _property_list_t {
prop_val_t *head;
prop_val_t *tail;
property_definition_t *head;
property_definition_t *tail;
} property_list_t;
static property_list_t *new_property_list(parser_ctx_t*,literal_t*,expression_t*);
static property_list_t *property_list_add(parser_ctx_t*,property_list_t*,literal_t*,expression_t*);
static property_definition_t *new_property_definition(parser_ctx_t *ctx, property_definition_type_t,
literal_t *name, expression_t *value);
static property_list_t *new_property_list(parser_ctx_t*,property_definition_t*);
static property_list_t *property_list_add(parser_ctx_t*,property_list_t*,property_definition_t*);
typedef struct _element_list_t {
array_element_t *head;
@ -156,6 +158,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
const WCHAR *identifier;
struct _parameter_list_t *parameter_list;
struct _property_list_t *property_list;
property_definition_t *property_definition;
source_elements_t *source_elements;
statement_t *statement;
struct _statement_list_t *statement_list;
@ -164,7 +167,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
}
/* keywords */
%token <identifier> kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kFUNCTION kIF kFINALLY kFOR kIN
%token <identifier> kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kFUNCTION kIF kFINALLY kFOR kGET kIN kSET
%token <identifier> kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ kDCOL
@ -221,6 +224,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%type <expr> CallExpression
%type <expr> MemberExpression
%type <expr> PrimaryExpression
%type <expr> GetterSetterMethod
%type <identifier> Identifier_opt
%type <variable_list> VariableDeclarationList
%type <variable_list> VariableDeclarationListNoIn
@ -237,9 +241,10 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
%type <ival> Elision Elision_opt
%type <element_list> ElementList
%type <property_list> PropertyNameAndValueList
%type <property_definition> PropertyDefinition
%type <literal> PropertyName
%type <literal> BooleanLiteral
%type <srcptr> KFunction
%type <srcptr> KFunction left_bracket
%type <ival> AssignOper
%type <identifier> IdentifierName ReservedAsIdentifier
@ -778,15 +783,35 @@ ObjectLiteral
: '{' '}' { $$ = new_prop_and_value_expression(ctx, NULL); }
| '{' PropertyNameAndValueList '}'
{ $$ = new_prop_and_value_expression(ctx, $2); }
| '{' PropertyNameAndValueList ',' '}'
{
if(ctx->script->version < 2) {
WARN("Trailing comma in object literal is illegal in legacy mode.\n");
YYABORT;
}
$$ = new_prop_and_value_expression(ctx, $2);
}
/* ECMA-262 3rd Edition 11.1.5 */
PropertyNameAndValueList
: PropertyName ':' AssignmentExpression
{ $$ = new_property_list(ctx, $1, $3); }
| PropertyNameAndValueList ',' PropertyName ':' AssignmentExpression
{ $$ = property_list_add(ctx, $1, $3, $5); }
: PropertyDefinition { $$ = new_property_list(ctx, $1); }
| PropertyNameAndValueList ',' PropertyDefinition
{ $$ = property_list_add(ctx, $1, $3); }
/* ECMA-262 3rd Edition 11.1.5 */
/* ECMA-262 5.1 Edition 12.2.6 */
PropertyDefinition
: PropertyName ':' AssignmentExpression
{ $$ = new_property_definition(ctx, PROPERTY_DEFINITION_VALUE, $1, $3); }
| kGET PropertyName GetterSetterMethod
{ $$ = new_property_definition(ctx, PROPERTY_DEFINITION_GETTER, $2, $3); }
| kSET PropertyName GetterSetterMethod
{ $$ = new_property_definition(ctx, PROPERTY_DEFINITION_SETTER, $2, $3); }
GetterSetterMethod
: left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, NULL, $2, $5, NULL, $1, $6-$1); }
/* Ecma-262 3rd Edition 11.1.5 */
PropertyName
: IdentifierName { $$ = new_string_literal(ctx, $1); }
| tStringLiteral { $$ = new_string_literal(ctx, $1); }
@ -823,12 +848,14 @@ ReservedAsIdentifier
| kFINALLY { $$ = $1; }
| kFOR { $$ = $1; }
| kFUNCTION { $$ = $1; }
| kGET { $$ = $1; }
| kIF { $$ = $1; }
| kIN { $$ = $1; }
| kINSTANCEOF { $$ = $1; }
| kNEW { $$ = $1; }
| kNULL { $$ = $1; }
| kRETURN { $$ = $1; }
| kSET { $$ = $1; }
| kSWITCH { $$ = $1; }
| kTHIS { $$ = $1; }
| kTHROW { $$ = $1; }
@ -862,7 +889,7 @@ semicolon_opt
| error { if(!allow_auto_semicolon(ctx)) {YYABORT;} }
left_bracket
: '('
: '(' { $$ = ctx->ptr; }
| error { set_error(ctx, JS_E_MISSING_LBRACKET); YYABORT; }
right_bracket
@ -913,10 +940,12 @@ static literal_t *new_null_literal(parser_ctx_t *ctx)
return ret;
}
static prop_val_t *new_prop_val(parser_ctx_t *ctx, literal_t *name, expression_t *value)
static property_definition_t *new_property_definition(parser_ctx_t *ctx, property_definition_type_t type,
literal_t *name, expression_t *value)
{
prop_val_t *ret = parser_alloc(ctx, sizeof(prop_val_t));
property_definition_t *ret = parser_alloc(ctx, sizeof(property_definition_t));
ret->type = type;
ret->name = name;
ret->value = value;
ret->next = NULL;
@ -924,19 +953,16 @@ static prop_val_t *new_prop_val(parser_ctx_t *ctx, literal_t *name, expression_t
return ret;
}
static property_list_t *new_property_list(parser_ctx_t *ctx, literal_t *name, expression_t *value)
static property_list_t *new_property_list(parser_ctx_t *ctx, property_definition_t *prop)
{
property_list_t *ret = parser_alloc_tmp(ctx, sizeof(property_list_t));
ret->head = ret->tail = new_prop_val(ctx, name, value);
ret->head = ret->tail = prop;
return ret;
}
static property_list_t *property_list_add(parser_ctx_t *ctx, property_list_t *list, literal_t *name, expression_t *value)
static property_list_t *property_list_add(parser_ctx_t *ctx, property_list_t *list, property_definition_t *prop)
{
list->tail = list->tail->next = new_prop_val(ctx, name, value);
list->tail = list->tail->next = prop;
return list;
}

View file

@ -103,4 +103,4 @@
#endif
#ifdef LANGUAGE_ZH_CN
#include "lang/jscript_Zh.rc"
#endif
#endif

View file

@ -943,7 +943,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
}else {
static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d'};
hres = strbuf_append(&ret, undefinedW, sizeof(undefinedW)/sizeof(WCHAR));
hres = strbuf_append(&ret, undefinedW, ARRAY_SIZE(undefinedW));
if(FAILED(hres))
break;
}
@ -1140,17 +1140,32 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
TRACE("\n");
if(argc != 1 && argc != 2) {
FIXME("unsupported argc %u\n", argc);
return E_NOTIMPL;
}
hres = get_string_flat_val(ctx, jsthis, &jsstr, &str);
if(FAILED(hres))
return hres;
length = jsstr_length(jsstr);
if(!argc || (is_undefined(argv[0]) && ctx->version >= SCRIPTLANGUAGEVERSION_ES5)) {
if(!r)
return S_OK;
hres = create_array(ctx, 0, &array);
if(FAILED(hres))
return hres;
/* NOTE: according to spec, we should respect limit argument here (if provided).
* We have a test showing that it's broken in native IE. */
hres = jsdisp_propput_idx(array, 0, jsval_string(jsstr));
if(FAILED(hres)) {
jsdisp_release(array);
return hres;
}
*r = jsval_obj(array);
return S_OK;
}
if(argc > 1 && !is_undefined(argv[1])) {
hres = to_uint32(ctx, argv[1], &limit);
if(FAILED(hres)) {
@ -1595,7 +1610,7 @@ static const builtin_prop_t String_props[] = {
static const builtin_info_t String_info = {
JSCLASS_STRING,
{NULL, NULL,0, String_get_value},
sizeof(String_props)/sizeof(*String_props),
ARRAY_SIZE(String_props),
String_props,
String_destructor,
NULL
@ -1608,7 +1623,7 @@ static const builtin_prop_t StringInst_props[] = {
static const builtin_info_t StringInst_info = {
JSCLASS_STRING,
{NULL, NULL,0, String_get_value},
sizeof(StringInst_props)/sizeof(*StringInst_props),
ARRAY_SIZE(StringInst_props),
StringInst_props,
String_destructor,
NULL,
@ -1726,7 +1741,7 @@ static const builtin_prop_t StringConstr_props[] = {
static const builtin_info_t StringConstr_info = {
JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE,
sizeof(StringConstr_props)/sizeof(*StringConstr_props),
ARRAY_SIZE(StringConstr_props),
StringConstr_props,
NULL,
NULL

View file

@ -258,7 +258,7 @@ static const builtin_prop_t VBArray_props[] = {
static const builtin_info_t VBArray_info = {
JSCLASS_VBARRAY,
{NULL, VBArray_value, 0},
sizeof(VBArray_props)/sizeof(*VBArray_props),
ARRAY_SIZE(VBArray_props),
VBArray_props,
VBArray_destructor,
NULL

View file

@ -85,7 +85,7 @@ reactos/dll/win32/inseng # Synced to WineStaging-3.3
reactos/dll/win32/iphlpapi # Out of sync
reactos/dll/win32/itircl # Synced to WineStaging-3.3
reactos/dll/win32/itss # Synced to WineStaging-3.17
reactos/dll/win32/jscript # Synced to WineStaging-3.9
reactos/dll/win32/jscript # Synced to WineStaging-4.0
reactos/dll/win32/jsproxy # Synced to WineStaging-3.3
reactos/dll/win32/loadperf # Synced to WineStaging-3.3
reactos/dll/win32/lz32 # Synced to WineStaging-3.3