jscript: Set parameters on function call.
This commit is contained in:
parent
dd9f8f7dbc
commit
0d33508954
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue