Jacek Caban : jscript: Added propertyIsEnumerable implementation.

Alexandre Julliard julliard at winehq.org
Mon Nov 5 13:32:25 CST 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Nov  5 15:04:19 2012 +0100

jscript: Added propertyIsEnumerable implementation.

---

 dlls/jscript/dispex.c  |   13 +++++++++++++
 dlls/jscript/jscript.h |    1 +
 dlls/jscript/object.c  |   30 ++++++++++++++++++++++++++++--
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index b01619e..f68a031 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -1444,3 +1444,16 @@ HRESULT jsdisp_is_own_prop(jsdisp_t *obj, const WCHAR *name, BOOL *ret)
     *ret = prop && (prop->type == PROP_JSVAL || prop->type == PROP_BUILTIN);
     return S_OK;
 }
+
+HRESULT jsdisp_is_enumerable(jsdisp_t *obj, const WCHAR *name, BOOL *ret)
+{
+    dispex_prop_t *prop;
+    HRESULT hres;
+
+    hres = find_prop_name(obj, string_hash(name), name, &prop);
+    if(FAILED(hres))
+        return hres;
+
+    *ret = prop && (prop->flags & PROPF_ENUM) && prop->type != PROP_PROTREF;
+    return S_OK;
+}
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 18ac1db..6b7c5a1 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -273,6 +273,7 @@ HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
 HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
 HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
 HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
+HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) 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;
diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c
index 6c585f7..34c572f 100644
--- a/dlls/jscript/object.c
+++ b/dlls/jscript/object.c
@@ -160,8 +160,34 @@ static HRESULT Object_hasOwnProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
 static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
         jsval_t *r)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    jsstr_t *name;
+    BOOL ret;
+    HRESULT hres;
+
+    TRACE("\n");
+
+    if(argc != 1) {
+        FIXME("argc %d not supported\n", argc);
+        return E_NOTIMPL;
+    }
+
+    if(!is_jsdisp(jsthis)) {
+        FIXME("Host object this\n");
+        return E_FAIL;
+    }
+
+    hres = to_string(ctx, argv[0], &name);
+    if(FAILED(hres))
+        return hres;
+
+    hres = jsdisp_is_enumerable(jsthis->u.jsdisp, name->str, &ret);
+    jsstr_release(name);
+    if(FAILED(hres))
+        return hres;
+
+    if(r)
+        *r = jsval_bool(ret);
+    return S_OK;
 }
 
 static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,




More information about the wine-cvs mailing list