Jacek Caban : jscript: Added to_object(number) implementation.

Alexandre Julliard julliard at winehq.org
Wed Sep 17 07:14:47 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep 16 20:45:45 2008 +0200

jscript: Added to_object(number) implementation.

---

 dlls/jscript/jscript.h     |    1 +
 dlls/jscript/jsutils.c     |    8 ++++++++
 dlls/jscript/number.c      |   17 +++++++++++++++++
 dlls/jscript/tests/lang.js |    4 ++++
 4 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 8f14e63..4b384c7 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -135,6 +135,7 @@ HRESULT create_array(script_ctx_t*,DWORD,DispatchEx**);
 HRESULT create_regexp_str(script_ctx_t*,const WCHAR*,DWORD,const WCHAR*,DWORD,DispatchEx**);
 HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,DispatchEx**);
 HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,DispatchEx**);
+HRESULT create_number(script_ctx_t*,VARIANT*,DispatchEx**);
 
 HRESULT to_primitive(script_ctx_t*,VARIANT*,jsexcept_t*,VARIANT*);
 HRESULT to_boolean(VARIANT*,VARIANT_BOOL*);
diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c
index 01b0ef7..616369e 100644
--- a/dlls/jscript/jsutils.c
+++ b/dlls/jscript/jsutils.c
@@ -260,6 +260,14 @@ HRESULT to_object(exec_ctx_t *ctx, VARIANT *v, IDispatch **disp)
 
         *disp = (IDispatch*)_IDispatchEx_(dispex);
         break;
+    case VT_I4:
+    case VT_R8:
+        hres = create_number(ctx->parser->script, v, &dispex);
+        if(FAILED(hres))
+            return hres;
+
+        *disp = (IDispatch*)_IDispatchEx_(dispex);
+        break;
     case VT_DISPATCH:
         IDispatch_AddRef(V_DISPATCH(v));
         *disp = V_DISPATCH(v);
diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c
index b4db863..108cfff 100644
--- a/dlls/jscript/number.c
+++ b/dlls/jscript/number.c
@@ -24,6 +24,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript);
 
 typedef struct {
     DispatchEx dispex;
+
+    VARIANT num;
 } NumberInstance;
 
 static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
@@ -165,3 +167,18 @@ HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx **ret)
     jsdisp_release(&number->dispex);
     return hres;
 }
+
+HRESULT create_number(script_ctx_t *ctx, VARIANT *num, DispatchEx **ret)
+{
+    NumberInstance *number;
+    HRESULT hres;
+
+    hres = alloc_number(ctx, TRUE, &number);
+    if(FAILED(hres))
+        return hres;
+
+    number->num = *num;
+
+    *ret = &number->dispex;
+    return S_OK;
+}
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 3ca57c0..e099df9 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -239,6 +239,10 @@ ok("".test === true, "\"\".test is not true");
 Boolean.prototype.test = true;
 ok(true.test === true, "true.test is not true");
 
+Number.prototype.test = true;
+ok((0).test === true, "(0).test is not true");
+ok((0.5).test === true, "(0.5).test is not true");
+
 var state = "";
 try {
     ok(state === "", "try: state = " + state);




More information about the wine-cvs mailing list