From 0d33508954880b31f8b70b24ebb229195fdd05db Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 10 Sep 2008 21:06:25 +0200 Subject: [PATCH] jscript: Set parameters on function call. --- dlls/jscript/function.c | 30 ++++++++++++++++++++++++++++++ dlls/jscript/tests/lang.js | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 3cd63f5924c..c58f002971a 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -64,6 +64,30 @@ static IDispatch *get_this(DISPPARAMS *dp) return NULL; } +static HRESULT init_parameters(DispatchEx *var_disp, FunctionInstance *function, LCID lcid, DISPPARAMS *dp, + jsexcept_t *ei, IServiceProvider *caller) +{ + parameter_t *param; + VARIANT var_empty; + DWORD cargs, i=0; + HRESULT hres; + + V_VT(&var_empty) = VT_EMPTY; + cargs = dp->cArgs - dp->cNamedArgs; + + for(param = function->parameters; param; param = param->next) { + hres = jsdisp_propput_name(var_disp, param->identifier, lcid, + i < cargs ? dp->rgvarg + dp->cArgs-1 - i : &var_empty, + ei, caller); + if(FAILED(hres)) + return hres; + + i++; + } + + return S_OK; +} + static HRESULT create_var_disp(FunctionInstance *function, LCID lcid, DISPPARAMS *dp, jsexcept_t *ei, IServiceProvider *caller, DispatchEx **ret) { @@ -74,6 +98,12 @@ static HRESULT create_var_disp(FunctionInstance *function, LCID lcid, DISPPARAMS if(FAILED(hres)) return hres; + hres = init_parameters(var_disp, function, lcid, dp, ei, caller); + if(FAILED(hres)) { + jsdisp_release(var_disp); + return hres; + } + *ret = var_disp; return S_OK; } diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index b21a9e899e8..19430fe4827 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -41,6 +41,10 @@ ok(trueVar, "trueVar is not true"); ok(ScriptEngine.length === 0, "ScriptEngine.length is not 0"); function testFunc1(x, y) { + ok(this !== undefined, "this is undefined"); + ok(x === true, "x is not 1"); + ok(y === "test", "y is not \"test\""); + return true; }