Commit 02615bb4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added arguments.callee implementation.

parent 86ad4c97
......@@ -100,7 +100,7 @@ static const builtin_info_t Arguments_info = {
NULL
};
static HRESULT create_arguments(script_ctx_t *ctx, LCID lcid, DISPPARAMS *dp,
static HRESULT create_arguments(script_ctx_t *ctx, IDispatch *calee, LCID lcid, DISPPARAMS *dp,
jsexcept_t *ei, IServiceProvider *caller, DispatchEx **ret)
{
DispatchEx *args;
......@@ -108,6 +108,8 @@ static HRESULT create_arguments(script_ctx_t *ctx, LCID lcid, DISPPARAMS *dp,
DWORD i;
HRESULT hres;
static const WCHAR caleeW[] = {'c','a','l','l','e','e',0};
args = heap_alloc_zero(sizeof(DispatchEx));
if(!args)
return E_OUTOFMEMORY;
......@@ -128,6 +130,12 @@ static HRESULT create_arguments(script_ctx_t *ctx, LCID lcid, DISPPARAMS *dp,
V_VT(&var) = VT_I4;
V_I4(&var) = arg_cnt(dp);
hres = jsdisp_propput_name(args, lengthW, lcid, &var, ei, caller);
if(SUCCEEDED(hres)) {
V_VT(&var) = VT_DISPATCH;
V_DISPATCH(&var) = calee;
hres = jsdisp_propput_name(args, caleeW, lcid, &var, ei, caller);
}
}
if(FAILED(hres)) {
......@@ -151,7 +159,8 @@ static HRESULT create_var_disp(FunctionInstance *function, LCID lcid, DISPPARAMS
if(FAILED(hres))
return hres;
hres = create_arguments(function->dispex.ctx, lcid, dp, ei, caller, &arg_disp);
hres = create_arguments(function->dispex.ctx, (IDispatch*)_IDispatchEx_(&function->dispex),
lcid, dp, ei, caller, &arg_disp);
if(SUCCEEDED(hres)) {
VARIANT var;
......
......@@ -68,6 +68,7 @@ function testFunc1(x, y) {
ok(arguments.length === 2, "arguments.length is not 2");
ok(arguments["0"] === true, "arguments[0] is not true");
ok(arguments["1"] === "test", "arguments[1] is not \"test\"");
ok(arguments.callee === testFunc1, "arguments.calee !== testFunc1");
return true;
}
......@@ -116,6 +117,7 @@ obj1.func = function () {
ok(this.test === true, "this.test is not true");
ok(arguments.length === 1, "arguments.length is not 1");
ok(arguments["0"] === true, "arguments[0] is not true");
ok(typeof(arguments.callee) === "function", "typeof(arguments.calee) = " + typeof(arguments.calee));
return "test";
};
......@@ -128,6 +130,7 @@ function testConstr1() {
ok(this !== undefined, "this is undefined");
ok(arguments.length === 1, "arguments.length is not 1");
ok(arguments["0"] === true, "arguments[0] is not 1");
ok(arguments.callee === testConstr1, "arguments.calee !== testConstr1");
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment