Jacek Caban : jscript: Added Number constructor implementation.

Alexandre Julliard julliard at winehq.org
Mon Sep 22 07:04:01 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun Sep 21 15:37:15 2008 +0200

jscript: Added Number constructor implementation.

---

 dlls/jscript/number.c     |   40 ++++++++++++++++++++++++++++++++++++++--
 dlls/jscript/tests/api.js |    2 ++
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c
index 108cfff..ebdbcf7 100644
--- a/dlls/jscript/number.c
+++ b/dlls/jscript/number.c
@@ -133,8 +133,44 @@ static const builtin_info_t Number_info = {
 static HRESULT NumberConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    VARIANT num;
+    HRESULT hres;
+
+    TRACE("\n");
+
+    switch(flags) {
+    case DISPATCH_CONSTRUCT: {
+        DispatchEx *obj;
+
+        switch(arg_cnt(dp)) {
+        case 0:
+            V_VT(&num) = VT_I4;
+            V_I4(&num) = 0;
+            break;
+        case 1:
+            hres = to_number(dispex->ctx, get_arg(dp, 0), ei, &num);
+            if(FAILED(hres))
+                return hres;
+            break;
+        default:
+            FIXME("unimplemented args\n");
+            return E_NOTIMPL;
+        }
+
+        hres = create_number(dispex->ctx, &num, &obj);
+        if(FAILED(hres))
+            return hres;
+
+        V_VT(retv) = VT_DISPATCH;
+        V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(obj);
+        break;
+    }
+    default:
+        FIXME("unimplemented flags %x\n", flags);
+        return E_NOTIMPL;
+    }
+
+    return S_OK;
 }
 
 static HRESULT alloc_number(script_ctx_t *ctx, BOOL use_constr, NumberInstance **ret)
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 78c0425..715b8dd 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -84,4 +84,6 @@ ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
 tmp = arr.toString("test");
 ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
 
+var num = new Number(2);
+
 reportSuccess();




More information about the wine-cvs mailing list