Jacek Caban : jscript: Use prototype for builtin String properties.

Alexandre Julliard julliard at winehq.org
Tue Jul 24 14:39:36 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Jul 24 13:17:41 2012 +0200

jscript: Use prototype for builtin String properties.

---

 dlls/jscript/string.c     |   15 ++++++++++++++-
 dlls/jscript/tests/api.js |    7 +++++++
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index 9b23005..4921f8b 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -1536,6 +1536,19 @@ static const builtin_info_t String_info = {
     NULL
 };
 
+static const builtin_prop_t StringInst_props[] = {
+    {lengthW,                String_length,                0}
+};
+
+static const builtin_info_t StringInst_info = {
+    JSCLASS_STRING,
+    {NULL, String_value, 0},
+    sizeof(StringInst_props)/sizeof(*StringInst_props),
+    StringInst_props,
+    String_destructor,
+    NULL
+};
+
 /* ECMA-262 3rd Edition    15.5.3.2 */
 static HRESULT StringConstr_fromCharCode(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
         unsigned argc, VARIANT *argv, VARIANT *retv, jsexcept_t *ei)
@@ -1635,7 +1648,7 @@ static HRESULT string_alloc(script_ctx_t *ctx, jsdisp_t *object_prototype, Strin
     if(object_prototype)
         hres = init_dispex(&string->dispex, ctx, &String_info, object_prototype);
     else
-        hres = init_dispex_from_constr(&string->dispex, ctx, &String_info, ctx->string_constr);
+        hres = init_dispex_from_constr(&string->dispex, ctx, &StringInst_info, ctx->string_constr);
     if(FAILED(hres)) {
         heap_free(string);
         return hres;
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 9bc083d..c998fa6 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -239,6 +239,13 @@ ok(!RegExp.hasOwnProperty('exec'), "RegExp.hasOwnProperty('exec') is true");
 ok(!RegExp.hasOwnProperty('source'), "RegExp.hasOwnProperty('source') is true");
 ok(RegExp.prototype.hasOwnProperty('source'), "RegExp.prototype.hasOwnProperty('source') is false");
 
+obj = new String();
+ok(!obj.hasOwnProperty('charAt'), "obj.hasOwnProperty('charAt') is true");
+ok(obj.hasOwnProperty('length'), "obj.hasOwnProperty('length') is false");
+ok(!String.hasOwnProperty('charAt'), "String.hasOwnProperty('charAt') is true");
+ok(String.prototype.hasOwnProperty('charAt'), "String.prototype.hasOwnProperty('charAt') is false");
+ok(String.prototype.hasOwnProperty('length'), "String.prototype.hasOwnProperty('length') is false");
+
 tmp = "" + new Object();
 ok(tmp === "[object Object]", "'' + new Object() = " + tmp);
 (tmp = new Array).f = Object.prototype.toString;




More information about the wine-cvs mailing list