Module: wine Branch: master Commit: 02615bb45f626b72e31c30368c96dabeb6744cf2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=02615bb45f626b72e31c30368c...
Author: Jacek Caban jacek@codeweavers.com Date: Sun Sep 20 20:58:27 2009 +0200
jscript: Added arguments.callee implementation.
---
dlls/jscript/function.c | 13 +++++++++++-- dlls/jscript/tests/lang.js | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 83de7ca..e2f1b37 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -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;
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index bc77110..b6458d4 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -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; }