Jacek Caban : jscript: Added support for constructor property.
Alexandre Julliard
julliard at winehq.org
Mon Feb 8 11:06:05 CST 2010
Module: wine
Branch: master
Commit: 9fd4f4a44a5704a839103bfed7e03b1206d31086
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9fd4f4a44a5704a839103bfed7e03b1206d31086
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Feb 5 23:17:35 2010 +0100
jscript: Added support for constructor property.
---
dlls/jscript/dispex.c | 17 +++++++++++++++++
dlls/jscript/tests/lang.js | 5 +++++
dlls/jscript/tests/regexp.js | 1 +
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index c420f54..6894eae 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -803,6 +803,7 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui
dispex_prop_t *prop;
HRESULT hres;
+ static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r'};
static const WCHAR prototypeW[] = {'p','r','o','t','o','t','y','p','e',0};
hres = find_prop_name_prot(constr, prototypeW, &prop);
@@ -827,6 +828,22 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui
if(prot)
jsdisp_release(prot);
+ if(FAILED(hres))
+ return hres;
+
+ hres = ensure_prop_name(dispex, constructorW, FALSE, 0, &prop);
+ if(SUCCEEDED(hres)) {
+ jsexcept_t jsexcept;
+ VARIANT var;
+
+ V_VT(&var) = VT_DISPATCH;
+ V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(constr);
+ memset(&jsexcept, 0, sizeof(jsexcept));
+ hres = prop_put(dispex, prop, &var, &jsexcept, NULL/*FIXME*/);
+ }
+ if(FAILED(hres))
+ jsdisp_release(dispex);
+
return hres;
}
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index d91b1f2..495762e 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -116,6 +116,7 @@ ok(tmp === 1, "tmp = " + tmp);
var obj1 = new Object();
ok(typeof(obj1) === "object", "typeof(obj1) is not object");
+ok(obj1.constructor === Object, "unexpected obj1.constructor");
obj1.test = true;
obj1.func = function () {
ok(this === obj1, "this is not obj1");
@@ -144,6 +145,7 @@ testConstr1.prototype.pvar = 1;
var obj2 = new testConstr1(true);
ok(typeof(obj2) === "object", "typeof(obj2) is not object");
+ok(obj2.constructor === testConstr1, "unexpected obj2.constructor");
ok(obj2.pvar === 1, "obj2.pvar is not 1");
testConstr1.prototype.pvar = 2;
@@ -209,6 +211,7 @@ if(false) {
var obj3 = { prop1: 1, prop2: typeof(false) };
ok(obj3.prop1 === 1, "obj3.prop1 is not 1");
ok(obj3.prop2 === "boolean", "obj3.prop2 is not \"boolean\"");
+ok(obj3.constructor === Object, "unexpected obj3.constructor");
{
var blockVar = 1;
@@ -422,8 +425,10 @@ ok(+"3e3" === 3000, "+'3e3' !== 3000");
tmp = new Number(1);
ok(+tmp === 1, "+(new Number(1)) = " + (+tmp));
+ok(tmp.constructor === Number, "unexpected tmp.constructor");
tmp = new String("1");
ok(+tmp === 1, "+(new String('1')) = " + (+tmp));
+ok(tmp.constructor === String, "unexpected tmp.constructor");
ok("" + 0 === "0", "\"\" + 0 !== \"0\"");
ok("" + 123 === "123", "\"\" + 123 !== \"123\"");
diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js
index d09d787..fac1112 100644
--- a/dlls/jscript/tests/regexp.js
+++ b/dlls/jscript/tests/regexp.js
@@ -100,6 +100,7 @@ m = "abcabc".match(re = /ca/);
ok(typeof(m) === "object", "typeof m is not object");
ok(m.length === 1, "m.length is not 1");
ok(m["0"] === "ca", "m[0] is not \"ca\"");
+ok(m.constructor === Array, "unexpected m.constructor");
ok(re.lastIndex === 4, "re.lastIndex = " + re.lastIndex);
m = "abcabc".match(/ab/);
More information about the wine-cvs
mailing list