Piotr Caban : jscript: Make Array.join generic.

Alexandre Julliard julliard at winehq.org
Mon Jan 18 10:58:52 CST 2010


Module: wine
Branch: master
Commit: db137cc975cd05451f5235ebe948fc640204be84
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=db137cc975cd05451f5235ebe948fc640204be84

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Jan 15 08:17:50 2010 +0100

jscript: Make Array.join generic.

---

 dlls/jscript/array.c      |   16 +++++++---------
 dlls/jscript/tests/api.js |   11 +++++++++++
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c
index bb54493..5acfa01 100644
--- a/dlls/jscript/array.c
+++ b/dlls/jscript/array.c
@@ -342,20 +342,18 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co
 }
 
 /* ECMA-262 3rd Edition    15.4.4.5 */
-static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
+static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
 {
+    DispatchEx *jsthis;
     DWORD length;
     HRESULT hres;
 
     TRACE("\n");
 
-    if(is_vclass(jsthis, JSCLASS_ARRAY)) {
-        length = array_from_vdisp(jsthis)->length;
-    }else {
-        FIXME("dispid is not Array\n");
-        return E_NOTIMPL;
-    }
+    hres = get_length(ctx, vthis, ei, &jsthis, &length);
+    if(FAILED(hres))
+        return hres;
 
     if(arg_cnt(dp)) {
         BSTR sep;
@@ -364,11 +362,11 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
         if(FAILED(hres))
             return hres;
 
-        hres = array_join(ctx, jsthis->u.jsdisp, length, sep, retv, ei, caller);
+        hres = array_join(ctx, jsthis, length, sep, retv, ei, caller);
 
         SysFreeString(sep);
     }else {
-        hres = array_join(ctx, jsthis->u.jsdisp, length, default_separatorW, retv, ei, caller);
+        hres = array_join(ctx, jsthis, length, default_separatorW, retv, ei, caller);
     }
 
     return hres;
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 69deab2..40193a7 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -654,6 +654,16 @@ ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
 tmp = arr.toString("test");
 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
 
+arr = new Object();
+arr.length = 3;
+arr[0] = "aa";
+arr[2] = 2;
+arr[7] = 3;
+arr.join = Array.prototype.join;
+tmp = arr.join(",");
+ok(arr.length === 3, "arr.length = " + arr.length);
+ok(tmp === "aa,,2", "tmp = " + tmp);
+
 arr = [5,true,2,-1,3,false,"2.5"];
 tmp = arr.sort(function(x,y) { return y-x; });
 ok(tmp === arr, "tmp !== arr");
@@ -1880,6 +1890,7 @@ testArrayHostThis("slice");
 testArrayHostThis("splice");
 testArrayHostThis("unshift");
 testArrayHostThis("reverse");
+testArrayHostThis("join");
 
 function testObjectInherit(obj, constr, ts, tls, vo) {
     ok(obj instanceof Object, "obj is not instance of Object");




More information about the wine-cvs mailing list