[JSCRIPT] Sync with Wine Staging 1.7.47. CORE-9924

svn path=/trunk/; revision=68446
This commit is contained in:
Amine Khaldi 2015-07-19 22:36:25 +00:00
parent b4eaf61627
commit b76ad047da
13 changed files with 1113 additions and 1011 deletions

View file

@ -854,7 +854,7 @@ static HRESULT compile_function_expression(compiler_ctx_t *ctx, function_express
ctx->func_tail = ctx->func_tail ? (ctx->func_tail->next = expr) : (ctx->func_head = expr);
/* FIXME: not exactly right */
if(expr->identifier) {
if(expr->identifier && !expr->event_target) {
ctx->func->func_cnt++;
return push_instr_bstr(ctx, OP_ident, expr->identifier);
}
@ -1857,10 +1857,18 @@ static HRESULT compile_function(compiler_ctx_t *ctx, source_elements_t *source,
func->instr_off = off;
if(func_expr && func_expr->identifier) {
func->name = compiler_alloc_bstr(ctx, func_expr->identifier);
if(!func->name)
return E_OUTOFMEMORY;
if(func_expr) {
if(func_expr->identifier) {
func->name = compiler_alloc_bstr(ctx, func_expr->identifier);
if(!func->name)
return E_OUTOFMEMORY;
}
if(func_expr->event_target) {
func->event_target = compiler_alloc_bstr(ctx, func_expr->event_target);
if(!func->event_target)
return E_OUTOFMEMORY;
}
}
if(func_expr) {

View file

@ -2121,7 +2121,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
}
}
else if(parse[i]=='-' || parse[i]=='/') {
/* Short date */
/* Short or long date */
if(set_day || set_month || set_year) break;
set_day = TRUE;
set_month = TRUE;
@ -2141,6 +2141,13 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) {
if(parse[i]<'0' || parse[i]>'9') break;
year = atoiW(&parse[i]);
while(parse[i]>='0' && parse[i]<='9') i++;
if(tmp >= 70){
/* long date */
month = day - 1;
day = year;
year = tmp;
}
}
else if(tmp<0) break;
else if(tmp<70) {

View file

@ -500,14 +500,16 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re
TRACE("%s\n", debugstr_w(identifier));
for(scope = ctx->exec_ctx->scope_chain; scope; scope = scope->next) {
if(scope->jsobj)
hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
else
hres = disp_get_id(ctx, scope->obj, identifier, identifier, fdexNameImplicit, &id);
if(SUCCEEDED(hres)) {
exprval_set_idref(ret, scope->obj, id);
return S_OK;
if(ctx->exec_ctx) {
for(scope = ctx->exec_ctx->scope_chain; scope; scope = scope->next) {
if(scope->jsobj)
hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
else
hres = disp_get_id(ctx, scope->obj, identifier, identifier, fdexNameImplicit, &id);
if(SUCCEEDED(hres)) {
exprval_set_idref(ret, scope->obj, id);
return S_OK;
}
}
}
@ -2493,6 +2495,43 @@ static HRESULT enter_bytecode(script_ctx_t *ctx, bytecode_t *code, function_code
return S_OK;
}
static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdisp_t *func_obj)
{
IBindEventHandler *target;
exprval_t exprval;
IDispatch *disp;
jsval_t v;
HRESULT hres;
hres = identifier_eval(ctx, func->event_target, &exprval);
if(FAILED(hres))
return hres;
hres = exprval_to_value(ctx, &exprval, &v);
exprval_release(&exprval);
if(FAILED(hres))
return hres;
if(!is_object_instance(v)) {
FIXME("Can't bind to %s\n", debugstr_jsval(v));
jsval_release(v);
}
disp = get_object(v);
hres = IDispatch_QueryInterface(disp, &IID_IBindEventHandler, (void**)&target);
if(SUCCEEDED(hres)) {
hres = IBindEventHandler_BindHandler(target, func->name, (IDispatch*)&func_obj->IDispatchEx_iface);
IBindEventHandler_Release(target);
if(FAILED(hres))
WARN("BindEvent failed: %08x\n", hres);
}else {
FIXME("No IBindEventHandler, not yet supported binding\n");
}
IDispatch_Release(disp);
return hres;
}
HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BOOL from_eval, jsval_t *ret)
{
exec_ctx_t *prev_ctx;
@ -2510,7 +2549,10 @@ HRESULT exec_source(exec_ctx_t *ctx, bytecode_t *code, function_code_t *func, BO
if(FAILED(hres))
return hres;
hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, jsval_obj(func_obj));
if(func->funcs[i].event_target)
hres = bind_event_target(ctx->script, func->funcs+i, func_obj);
else
hres = jsdisp_propput_name(ctx->var_disp, func->funcs[i].name, jsval_obj(func_obj));
jsdisp_release(func_obj);
if(FAILED(hres))
return hres;

View file

@ -129,6 +129,7 @@ typedef struct {
typedef struct _function_code_t {
BSTR name;
BSTR event_target;
unsigned instr_off;
const WCHAR *source;

View file

@ -787,7 +787,11 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
return hres;
}
if(!is_started(This->ctx)) {
/*
* Although pvarResult is not really used without SCRIPTTEXT_ISEXPRESSION flag, if it's not NULL,
* script is executed immediately, even if it's not in started state yet.
*/
if(!pvarResult && !is_started(This->ctx)) {
if(This->queue_tail)
This->queue_tail = This->queue_tail->next = code;
else
@ -796,9 +800,13 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
}
hres = exec_global_code(This, code);
release_bytecode(code);
return hres;
if(FAILED(hres))
return hres;
if(pvarResult)
V_VT(pvarResult) = VT_EMPTY;
return S_OK;
}
static const IActiveScriptParseVtbl JScriptParseVtbl = {

View file

@ -298,7 +298,7 @@ HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
HRESULT disp_delete(IDispatch*,DISPID,BOOL*) DECLSPEC_HIDDEN;
HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*);
HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*) DECLSPEC_HIDDEN;
HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;

View file

@ -578,7 +578,6 @@ static int next_token(parser_ctx_t *ctx, void *lval)
case ',':
case '~':
case '?':
case ':':
return *ctx->ptr++;
case '}':
@ -774,6 +773,13 @@ static int next_token(parser_ctx_t *ctx, void *lval)
}
return '/';
case ':':
if(++ctx->ptr < ctx->end && *ctx->ptr == ':') {
ctx->ptr++;
return kDCOL;
}
return ':';
case '\"':
case '\'':
return parse_string_literal(ctx, lval, *ctx->ptr);

View file

@ -287,6 +287,7 @@ struct _source_elements_t {
typedef struct _function_expression_t {
expression_t expr;
const WCHAR *identifier;
const WCHAR *event_target;
parameter_t *parameter_list;
source_elements_t *source_elements;
const WCHAR *src_str;

File diff suppressed because it is too large Load diff

View file

@ -78,17 +78,18 @@ extern int parser_debug;
tDEC = 288,
tHTMLCOMMENT = 289,
kDIVEQ = 290,
kFUNCTION = 291,
tIdentifier = 292,
tAssignOper = 293,
tEqOper = 294,
tShiftOper = 295,
tRelOper = 296,
tNumericLiteral = 297,
tBooleanLiteral = 298,
tStringLiteral = 299,
tEOF = 300,
LOWER_THAN_ELSE = 301
kDCOL = 291,
kFUNCTION = 292,
tIdentifier = 293,
tAssignOper = 294,
tEqOper = 295,
tShiftOper = 296,
tRelOper = 297,
tNumericLiteral = 298,
tBooleanLiteral = 299,
tStringLiteral = 300,
tEOF = 301,
LOWER_THAN_ELSE = 302
};
#endif
@ -118,7 +119,7 @@ union YYSTYPE
struct _variable_list_t *variable_list;
variable_declaration_t *variable_declaration;
#line 122 "parser.tab.h" /* yacc.c:1909 */
#line 123 "parser.tab.h" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1

View file

@ -114,7 +114,7 @@ static parameter_list_t *parameter_list_add(parser_ctx_t*,parameter_list_t*,cons
static void *new_expression(parser_ctx_t *ctx,expression_type_t,size_t);
static expression_t *new_function_expression(parser_ctx_t*,const WCHAR*,parameter_list_t*,
source_elements_t*,const WCHAR*,DWORD);
source_elements_t*,const WCHAR*,const WCHAR*,DWORD);
static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expression_t*,expression_t*);
static expression_t *new_unary_expression(parser_ctx_t*,expression_type_t,expression_t*);
static expression_t *new_conditional_expression(parser_ctx_t*,expression_t*,expression_t*,expression_t*);
@ -160,7 +160,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state
/* keywords */
%token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN
%token kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ
%token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ kDCOL
%token <srcptr> kFUNCTION '}'
@ -258,8 +258,12 @@ SourceElements
/* ECMA-262 3rd Edition 13 */
FunctionExpression
: KFunction Identifier_opt left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, $2, $4, $7, $1, $8-$1+1); }
: KFunction left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, NULL, $3, $6, NULL, $1, $7-$1+1); }
| KFunction tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, $2, $4, $7, NULL, $1, $8-$1+1); }
| KFunction tIdentifier kDCOL tIdentifier left_bracket FormalParameterList_opt right_bracket '{' FunctionBody '}'
{ $$ = new_function_expression(ctx, $4, $6, $9, $2, $1, $10-$1+1); }
KFunction
: kFUNCTION { $$ = $1; }
@ -1294,14 +1298,15 @@ static parameter_list_t *parameter_list_add(parser_ctx_t *ctx, parameter_list_t
return list;
}
static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *identifier,
parameter_list_t *parameter_list, source_elements_t *source_elements, const WCHAR *src_str, DWORD src_len)
static expression_t *new_function_expression(parser_ctx_t *ctx, const WCHAR *identifier, parameter_list_t *parameter_list,
source_elements_t *source_elements, const WCHAR *event_target, const WCHAR *src_str, DWORD src_len)
{
function_expression_t *ret = new_expression(ctx, EXPR_FUNC, sizeof(*ret));
ret->identifier = identifier;
ret->parameter_list = parameter_list ? parameter_list->head : NULL;
ret->source_elements = source_elements;
ret->event_target = event_target;
ret->src_str = src_str;
ret->src_len = src_len;
ret->next = NULL;

View file

@ -1128,7 +1128,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
match_state_t match_result, *match_ptr = &match_result;
DWORD length, i, match_len = 0;
const WCHAR *ptr, *ptr2, *str, *match_str = NULL;
unsigned limit = UINT32_MAX;
unsigned limit = ~0u;
jsdisp_t *array, *regexp = NULL;
jsstr_t *jsstr, *match_jsstr, *tmp_str;
HRESULT hres;

View file

@ -88,7 +88,7 @@ reactos/dll/win32/inseng # Synced to WineStaging-1.7.47
reactos/dll/win32/iphlpapi # Out of sync
reactos/dll/win32/itircl # Synced to WineStaging-1.7.37
reactos/dll/win32/itss # Synced to WineStaging-1.7.37
reactos/dll/win32/jscript # Synced to WineStaging-1.7.37
reactos/dll/win32/jscript # Synced to WineStaging-1.7.47
reactos/dll/win32/jsproxy # Synced to WineStaging-1.7.37
reactos/dll/win32/loadperf # Synced to WineStaging-1.7.37
reactos/dll/win32/localspl # Synced to WineStaging-1.7.37