Commit 9d4e93cf authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Pass a jsval as the 'this' to jsdisp_call_value.

parent 3805eef4
...@@ -631,7 +631,7 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval ...@@ -631,7 +631,7 @@ static HRESULT sort_cmp(script_ctx_t *ctx, jsdisp_t *cmp_func, jsval_t v1, jsval
jsval_t res; jsval_t res;
double n; double n;
hres = jsdisp_call_value(cmp_func, NULL, DISPATCH_METHOD, 2, args, &res); hres = jsdisp_call_value(cmp_func, jsval_undefined(), DISPATCH_METHOD, 2, args, &res);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
......
...@@ -462,7 +462,7 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, jsval_t *r) ...@@ -462,7 +462,7 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, jsval_t *r)
break; break;
case PROP_ACCESSOR: case PROP_ACCESSOR:
if(prop->u.accessor.getter) { if(prop->u.accessor.getter) {
hres = jsdisp_call_value(prop->u.accessor.getter, to_disp(This), hres = jsdisp_call_value(prop->u.accessor.getter, jsval_obj(This),
DISPATCH_METHOD, 0, NULL, r); DISPATCH_METHOD, 0, NULL, r);
}else { }else {
*r = jsval_undefined(); *r = jsval_undefined();
...@@ -529,7 +529,7 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val) ...@@ -529,7 +529,7 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val)
TRACE("no setter\n"); TRACE("no setter\n");
return S_OK; return S_OK;
} }
return jsdisp_call_value(prop->u.accessor.setter, to_disp(This), DISPATCH_METHOD, 1, &val, NULL); return jsdisp_call_value(prop->u.accessor.setter, jsval_obj(This), DISPATCH_METHOD, 1, &val, NULL);
case PROP_IDX: case PROP_IDX:
if(!This->builtin_info->idx_put) { if(!This->builtin_info->idx_put) {
TRACE("no put_idx\n"); TRACE("no put_idx\n");
...@@ -1602,16 +1602,18 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc ...@@ -1602,16 +1602,18 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
case DISPATCH_METHOD: case DISPATCH_METHOD:
case DISPATCH_CONSTRUCT: { case DISPATCH_CONSTRUCT: {
jsval_t *argv, buf[6], r; jsval_t *argv, buf[6], r;
IDispatch *passed_this;
unsigned argc; unsigned argc;
hres = convert_params(This->ctx, pdp, buf, &argc, &argv); hres = convert_params(This->ctx, pdp, buf, &argc, &argv);
if(FAILED(hres)) if(FAILED(hres))
break; break;
passed_this = get_this(pdp);
if(prop) if(prop)
hres = invoke_prop_func(This, get_this(pdp), prop, wFlags, argc, argv, pvarRes ? &r : NULL, pspCaller); hres = invoke_prop_func(This, passed_this, prop, wFlags, argc, argv, pvarRes ? &r : NULL, pspCaller);
else else
hres = jsdisp_call_value(This, get_this(pdp), wFlags, argc, argv, pvarRes ? &r : NULL); hres = jsdisp_call_value(This, passed_this ? jsval_disp(passed_this) : jsval_undefined(), wFlags, argc, argv, pvarRes ? &r : NULL);
if(argv != buf) if(argv != buf)
free(argv); free(argv);
...@@ -1991,14 +1993,14 @@ HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID * ...@@ -1991,14 +1993,14 @@ HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID *
return DISP_E_UNKNOWNNAME; return DISP_E_UNKNOWNNAME;
} }
HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) HRESULT jsdisp_call_value(jsdisp_t *jsfunc, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
HRESULT hres; HRESULT hres;
assert(!(flags & ~(DISPATCH_METHOD|DISPATCH_CONSTRUCT|DISPATCH_JSCRIPT_INTERNAL_MASK))); assert(!(flags & ~(DISPATCH_METHOD|DISPATCH_CONSTRUCT|DISPATCH_JSCRIPT_INTERNAL_MASK)));
if(is_class(jsfunc, JSCLASS_FUNCTION)) { if(is_class(jsfunc, JSCLASS_FUNCTION)) {
hres = Function_invoke(jsfunc, jsthis, flags, argc, argv, r); hres = Function_invoke(jsfunc, vthis, flags, argc, argv, r);
}else { }else {
if(!jsfunc->builtin_info->call) { if(!jsfunc->builtin_info->call) {
WARN("Not a function\n"); WARN("Not a function\n");
...@@ -2009,7 +2011,7 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig ...@@ -2009,7 +2011,7 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig
return E_UNEXPECTED; return E_UNEXPECTED;
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK; flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
hres = jsfunc->builtin_info->call(jsfunc->ctx, jsthis ? jsval_disp(jsthis) : jsval_null(), flags, argc, argv, r); hres = jsfunc->builtin_info->call(jsfunc->ctx, vthis, flags, argc, argv, r);
} }
return hres; return hres;
} }
...@@ -2202,7 +2204,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W ...@@ -2202,7 +2204,7 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
jsdisp = iface_to_jsdisp(disp); jsdisp = iface_to_jsdisp(disp);
if(jsdisp && jsdisp->ctx == ctx) { if(jsdisp && jsdisp->ctx == ctx) {
hres = jsdisp_call_value(jsdisp, jsthis, flags, argc, argv, r); hres = jsdisp_call_value(jsdisp, jsthis ? jsval_disp(jsthis) : jsval_undefined(), flags, argc, argv, r);
jsdisp_release(jsdisp); jsdisp_release(jsdisp);
return hres; return hres;
} }
......
...@@ -247,12 +247,11 @@ void detach_arguments_object(jsdisp_t *args_disp) ...@@ -247,12 +247,11 @@ void detach_arguments_object(jsdisp_t *args_disp)
jsdisp_release(frame->arguments_obj); jsdisp_release(frame->arguments_obj);
} }
HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) HRESULT Function_invoke(jsdisp_t *func_this, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
jsval_t vthis;
TRACE("func %p this %p\n", func_this, jsthis); TRACE("func %p this %s\n", func_this, debugstr_jsval(vthis));
assert(is_class(func_this, JSCLASS_FUNCTION)); assert(is_class(func_this, JSCLASS_FUNCTION));
function = function_from_jsdisp(func_this); function = function_from_jsdisp(func_this);
...@@ -262,10 +261,6 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi ...@@ -262,10 +261,6 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi
return E_UNEXPECTED; return E_UNEXPECTED;
} }
if(jsthis)
vthis = jsval_disp(jsthis);
else
vthis = function->dispex.ctx->version < SCRIPTLANGUAGEVERSION_ES5 ? jsval_null() : jsval_undefined();
return function->vtbl->call(function->dispex.ctx, function, vthis, flags, argc, argv, r); return function->vtbl->call(function->dispex.ctx, function, vthis, flags, argc, argv, r);
} }
......
...@@ -226,7 +226,7 @@ HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,js ...@@ -226,7 +226,7 @@ HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,js
HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT disp_call_name(script_ctx_t*,IDispatch*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT disp_call_name(script_ctx_t*,IDispatch*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT disp_call_value(script_ctx_t*,IDispatch*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_value(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call_value(jsdisp_t*,jsval_t,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call(jsdisp_t*,DISPID,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_call_name(jsdisp_t*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,jsval_t*) DECLSPEC_HIDDEN; HRESULT disp_propget(script_ctx_t*,IDispatch*,DISPID,jsval_t*) DECLSPEC_HIDDEN;
...@@ -255,7 +255,7 @@ HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,cons ...@@ -255,7 +255,7 @@ HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,cons
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD, HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT Function_invoke(jsdisp_t*,jsval_t,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT Function_value(script_ctx_t*,jsval_t,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT Function_value(script_ctx_t*,jsval_t,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
......
...@@ -775,7 +775,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsdisp_t *object, const WCHAR *na ...@@ -775,7 +775,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsdisp_t *object, const WCHAR *na
} }
args[0] = jsval_string(name_str); args[0] = jsval_string(name_str);
args[1] = value; args[1] = value;
hres = jsdisp_call_value(ctx->replacer, to_disp(object), DISPATCH_METHOD, ARRAY_SIZE(args), args, &v); hres = jsdisp_call_value(ctx->replacer, jsval_obj(object), DISPATCH_METHOD, ARRAY_SIZE(args), args, &v);
jsstr_release(name_str); jsstr_release(name_str);
jsval_release(value); jsval_release(value);
if(FAILED(hres)) if(FAILED(hres))
......
...@@ -702,7 +702,7 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func, ...@@ -702,7 +702,7 @@ static HRESULT rep_call(script_ctx_t *ctx, jsdisp_t *func,
} }
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = jsdisp_call_value(func, NULL, DISPATCH_METHOD, argc, argv, &val); hres = jsdisp_call_value(func, jsval_undefined(), DISPATCH_METHOD, argc, argv, &val);
for(i=0; i <= match->paren_count; i++) for(i=0; i <= match->paren_count; i++)
jsstr_release(get_string(argv[i])); jsstr_release(get_string(argv[i]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment