[PATCH 8/9] jscript: Pass jsval "this" to function calls instead of a dispatch.
Jacek Caban
jacek at codeweavers.com
Fri Dec 3 09:04:13 CST 2021
On 12/3/21 2:57 PM, Gabriel Ivăncescu wrote:
> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
> ---
> dlls/jscript/function.c | 57 ++++++++++++++++++++++-------------------
> 1 file changed, 31 insertions(+), 26 deletions(-)
>
> diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
> index 43f2441..80b8d9c 100644
> --- a/dlls/jscript/function.c
> +++ b/dlls/jscript/function.c
> @@ -35,7 +35,7 @@ typedef struct {
> } FunctionInstance;
>
> struct _function_vtbl_t {
> - HRESULT (*call)(script_ctx_t*,FunctionInstance*,IDispatch*,unsigned,unsigned,jsval_t*,jsval_t*);
> + HRESULT (*call)(script_ctx_t*,FunctionInstance*,jsval_t,unsigned,unsigned,jsval_t*,jsval_t*);
> HRESULT (*toString)(FunctionInstance*,jsstr_t**);
> function_code_t* (*get_code)(FunctionInstance*);
> void (*destructor)(FunctionInstance*);
> @@ -256,7 +256,7 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi
> assert(is_class(func_this, JSCLASS_FUNCTION));
> function = function_from_jsdisp(func_this);
>
> - return function->vtbl->call(function->dispex.ctx, function, jsthis, flags, argc, argv, r);
> + return function->vtbl->call(function->dispex.ctx, function, jsval_disp(jsthis), flags, argc, argv, r);
> }
>
> static HRESULT Function_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
> @@ -331,8 +331,8 @@ static HRESULT Function_apply(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsi
> FunctionInstance *function;
> jsval_t *args = NULL;
> unsigned i, cnt = 0;
> - IDispatch *this_obj = NULL;
> HRESULT hres = S_OK;
> + jsval_t this_val;
>
> TRACE("\n");
>
> @@ -341,11 +341,15 @@ static HRESULT Function_apply(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsi
>
> if(argc) {
> if(!is_undefined(argv[0]) && !is_null(argv[0])) {
> + IDispatch *this_obj;
> hres = to_object(ctx, argv[0], &this_obj);
> if(FAILED(hres))
> return hres;
> - }
> - }
> + this_val = jsval_disp(this_obj);
> + }else
> + this_val = argv[0];
> + }else
> + this_val = jsval_undefined();
According to spec, this we should just always pass the original argument.
Jacek
More information about the wine-devel
mailing list