Jacek Caban : jscript: Properly set Number.prototyp.constructor.

Alexandre Julliard julliard at winehq.org
Mon Jul 16 14:14:29 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Jul 16 15:30:54 2012 +0200

jscript: Properly set Number.prototyp.constructor.

---

 dlls/jscript/function.c    |   25 +++++++++++++++++++++++++
 dlls/jscript/jscript.h     |    2 ++
 dlls/jscript/number.c      |    2 +-
 dlls/jscript/tests/lang.js |    2 ++
 4 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 618831b..765efcc 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -639,6 +639,31 @@ HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc,
     return S_OK;
 }
 
+HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name,
+        const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret)
+{
+    jsdisp_t *constr;
+    VARIANT v;
+    HRESULT hres;
+
+    static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r',0};
+
+    hres = create_builtin_function(ctx, value_proc, name, builtin_info, flags, prototype, &constr);
+    if(FAILED(hres))
+        return hres;
+
+    V_VT(&v) = VT_DISPATCH;
+    V_DISPATCH(&v) = to_disp(constr);
+    hres = jsdisp_propput_name(prototype, constructorW, &v, NULL);
+    if(FAILED(hres)) {
+        jsdisp_release(constr);
+        return hres;
+    }
+
+    *ret = constr;
+    return S_OK;
+}
+
 HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_code_t *func_code,
         scope_chain_t *scope_chain, jsdisp_t **ret)
 {
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 11b6ec9..ca91ee6 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -225,6 +225,8 @@ VARIANT_BOOL jsdisp_is_own_prop(jsdisp_t *obj, BSTR name) DECLSPEC_HIDDEN;
 
 HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
         jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
+HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD,
+        jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
 HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
 HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,VARIANT*,VARIANT*,jsexcept_t*);
 
diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c
index c62d985..d2de790 100644
--- a/dlls/jscript/number.c
+++ b/dlls/jscript/number.c
@@ -625,7 +625,7 @@ HRESULT create_number_constr(script_ctx_t *ctx, jsdisp_t *object_prototype, jsdi
         return hres;
 
     number->value = 0;
-    hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL,
+    hres = create_builtin_constructor(ctx, NumberConstr_value, NumberW, NULL,
             PROPF_CONSTR|1, &number->dispex, ret);
 
     jsdisp_release(&number->dispex);
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index 308e0c9..75306f1 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -91,6 +91,8 @@ ok(Function.prototype.prototype === undefined, "Function.prototype.prototype is
 ok(Date.prototype !== undefined, "Date.prototype is undefined");
 ok(Date.prototype.prototype === undefined, "Date.prototype is not undefined");
 
+ok(Number.prototype.constructor === Number, "Number.prototype.constructor !== Number");
+
 Function.prototype.test = true;
 ok(testFunc1.test === true, "testFunc1.test !== true");
 ok(Function.test === true, "Function.test !== true");




More information about the wine-cvs mailing list