Jacek Caban : jscript: Set parameters on function call.
Alexandre Julliard
julliard at winehq.org
Thu Sep 11 08:00:47 CDT 2008
Module: wine
Branch: master
Commit: 0d33508954880b31f8b70b24ebb229195fdd05db
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0d33508954880b31f8b70b24ebb229195fdd05db
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Sep 10 21:06:25 2008 +0200
jscript: Set parameters on function call.
---
dlls/jscript/function.c | 30 ++++++++++++++++++++++++++++++
dlls/jscript/tests/lang.js | 4 ++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 3cd63f5..c58f002 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 b21a9e8..19430fe 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;
}
More information about the wine-cvs
mailing list