From 37c2d43e28ec5f3188dbdf2c0866dbf1b41315b4 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 23 Sep 2009 16:19:29 +0200 Subject: [PATCH] jscript: Allow this_obj to be host object in call_function. --- dlls/jscript/function.c | 14 ++++---------- dlls/jscript/tests/run.c | 4 ++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index e68222bf863..74c4e47018a 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -281,21 +281,15 @@ static HRESULT call_function(script_ctx_t *ctx, FunctionInstance *function, IDis HRESULT hres; if(function->value_proc) { - DispatchEx *jsthis = NULL; vdisp_t vthis; - if(this_obj) { - jsthis = iface_to_jsdisp((IUnknown*)this_obj); - if(!jsthis) - FIXME("this_obj is not DispatchEx\n"); - } + if(this_obj) + set_disp(&vthis, this_obj); + else + set_jsdisp(&vthis, ctx->script_disp); - set_jsdisp(&vthis, jsthis ? jsthis : ctx->script_disp); hres = function->value_proc(ctx, &vthis, DISPATCH_METHOD, args, retv, ei, caller); vdisp_release(&vthis); - - if(jsthis) - jsdisp_release(jsthis); }else { hres = invoke_source(ctx, function, this_obj ? this_obj : (IDispatch*)_IDispatchEx_(ctx->script_disp), args, retv, ei, caller); diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c index 786624cc738..1cfee4f26b0 100644 --- a/dlls/jscript/tests/run.c +++ b/dlls/jscript/tests/run.c @@ -912,6 +912,10 @@ static void run_tests(void) parse_script_a("ok(String(testObj) === '1', 'wrong testObj value');"); CHECK_CALLED(testobj_value); + SET_EXPECT(testobj_value); + parse_script_a("ok(String.prototype.concat.call(testObj, ' OK') === '1 OK', 'wrong concat result');"); + CHECK_CALLED(testobj_value); + run_from_res("lang.js"); run_from_res("api.js"); run_from_res("regexp.js");