jscript: Set arguments object on function call.
This commit is contained in:
parent
0d33508954
commit
68d4f489f2
|
@ -883,6 +883,16 @@ HRESULT jsdisp_propput_name(DispatchEx *obj, const WCHAR *name, LCID lcid, VARIA
|
|||
return prop_put(obj, prop, lcid, &dp, ei, caller);
|
||||
}
|
||||
|
||||
HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, LCID lcid, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller)
|
||||
{
|
||||
WCHAR buf[12];
|
||||
|
||||
static const WCHAR formatW[] = {'%','d',0};
|
||||
|
||||
sprintfW(buf, formatW, idx);
|
||||
return jsdisp_propput_name(obj, buf, lcid, val, ei, caller);
|
||||
}
|
||||
|
||||
HRESULT disp_propput(IDispatch *disp, DISPID id, LCID lcid, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller)
|
||||
{
|
||||
DISPID dispid = DISPID_PROPERTYPUT;
|
||||
|
|
|
@ -88,17 +88,52 @@ static HRESULT init_parameters(DispatchEx *var_disp, FunctionInstance *function,
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT init_arguments(DispatchEx *arg_disp, FunctionInstance *function, LCID lcid, DISPPARAMS *dp,
|
||||
jsexcept_t *ei, IServiceProvider *caller)
|
||||
{
|
||||
VARIANT var;
|
||||
DWORD i;
|
||||
HRESULT hres;
|
||||
|
||||
for(i=0; i < dp->cArgs-dp->cNamedArgs; i++) {
|
||||
hres = jsdisp_propput_idx(arg_disp, i, lcid, dp->rgvarg+dp->cArgs-1-i, ei, caller);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
}
|
||||
|
||||
V_VT(&var) = VT_I4;
|
||||
V_I4(&var) = dp->cArgs - dp->cNamedArgs;
|
||||
return jsdisp_propput_name(arg_disp, lengthW, lcid, &var, ei, caller);
|
||||
}
|
||||
|
||||
static HRESULT create_var_disp(FunctionInstance *function, LCID lcid, DISPPARAMS *dp, jsexcept_t *ei,
|
||||
IServiceProvider *caller, DispatchEx **ret)
|
||||
{
|
||||
DispatchEx *var_disp;
|
||||
DispatchEx *var_disp, *arg_disp;
|
||||
HRESULT hres;
|
||||
|
||||
static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0};
|
||||
|
||||
hres = create_dispex(function->dispex.ctx, NULL, NULL, &var_disp);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = init_parameters(var_disp, function, lcid, dp, ei, caller);
|
||||
hres = create_dispex(function->dispex.ctx, NULL, NULL, &arg_disp);
|
||||
if(SUCCEEDED(hres)) {
|
||||
hres = init_arguments(arg_disp, function, lcid, dp, ei, caller);
|
||||
if(SUCCEEDED(hres)) {
|
||||
VARIANT var;
|
||||
|
||||
V_VT(&var) = VT_DISPATCH;
|
||||
V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(arg_disp);
|
||||
hres = jsdisp_propput_name(var_disp, argumentsW, lcid, &var, ei, caller);
|
||||
}
|
||||
|
||||
jsdisp_release(arg_disp);
|
||||
}
|
||||
|
||||
if(SUCCEEDED(hres))
|
||||
hres = init_parameters(var_disp, function, lcid, dp, ei, caller);
|
||||
if(FAILED(hres)) {
|
||||
jsdisp_release(var_disp);
|
||||
return hres;
|
||||
|
|
|
@ -109,7 +109,7 @@ HRESULT jsdisp_call_value(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,jsexcept_t*
|
|||
HRESULT disp_propget(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
HRESULT disp_propput(IDispatch*,DISPID,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
HRESULT jsdisp_set_prototype(DispatchEx*,DispatchEx*);
|
||||
HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,LCID,VARIANT*,jsexcept_t*,IServiceProvider*);
|
||||
|
||||
HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,DWORD,DispatchEx*,DispatchEx**);
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ function testFunc1(x, y) {
|
|||
ok(this !== undefined, "this is undefined");
|
||||
ok(x === true, "x is not 1");
|
||||
ok(y === "test", "y is not \"test\"");
|
||||
ok(arguments.length === 2, "arguments.length is not 2");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue