jscript: Added arguments.callee implementation.
authorJacek Caban <jacek@codeweavers.com>
Sun, 20 Sep 2009 18:58:27 +0000 (20:58 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 22 Sep 2009 14:16:25 +0000 (16:16 +0200)
dlls/jscript/function.c
dlls/jscript/tests/lang.js

index 83de7caeb1622fccd386d5caf177b37f48679ce1..e2f1b3743b00b200a2bf0a2afb34336d9744b185 100644 (file)
@@ -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;
 
index bc771109a21cba8f2f22f08a3b093d6fb39e2204..b6458d426e8ee365c876c0ef11294e8d698bb960 100644 (file)
@@ -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;
 }