Jacek Caban : jscript: Added disp_delete helper and use it in interp_delete_ident.

Alexandre Julliard julliard at winehq.org
Fri Nov 30 13:48:21 CST 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Nov 30 13:02:05 2012 +0100

jscript: Added disp_delete helper and use it in interp_delete_ident.

---

 dlls/jscript/dispex.c  |   36 ++++++++++++++++++++++++++++++++++++
 dlls/jscript/engine.c  |   15 ++++-----------
 dlls/jscript/jscript.h |    1 +
 3 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index 640e954..d7ff77d 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -1462,6 +1462,42 @@ HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx)
     return delete_prop(prop);
 }
 
+HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret)
+{
+    IDispatchEx *dispex;
+    jsdisp_t *jsdisp;
+    HRESULT hres;
+
+    jsdisp = iface_to_jsdisp((IUnknown*)disp);
+    if(jsdisp) {
+        dispex_prop_t *prop;
+
+        *ret = TRUE;
+        prop = get_prop(jsdisp, id);
+        if(prop)
+            hres = delete_prop(prop);
+        else
+            hres = DISP_E_MEMBERNOTFOUND;
+
+        jsdisp_release(jsdisp);
+        return hres;
+    }
+
+    hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
+    if(FAILED(hres)) {
+        *ret = FALSE;
+        return S_OK;
+    }
+
+    hres = IDispatchEx_DeleteMemberByDispID(dispex, id);
+    IDispatchEx_Release(dispex);
+    if(FAILED(hres))
+        return hres;
+
+    *ret = TRUE;
+    return S_OK;
+}
+
 HRESULT jsdisp_is_own_prop(jsdisp_t *obj, const WCHAR *name, BOOL *ret)
 {
     dispex_prop_t *prop;
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index f4dcc0f..20791bf 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -1648,9 +1648,8 @@ static HRESULT interp_delete(exec_ctx_t *ctx)
 static HRESULT interp_delete_ident(exec_ctx_t *ctx)
 {
     const BSTR arg = get_op_bstr(ctx, 0);
-    IDispatchEx *dispex;
     exprval_t exprval;
-    BOOL ret = FALSE;
+    BOOL ret;
     HRESULT hres;
 
     TRACE("%s\n", debugstr_w(arg));
@@ -1665,16 +1664,10 @@ static HRESULT interp_delete_ident(exec_ctx_t *ctx)
         return E_NOTIMPL;
     }
 
-    hres = IDispatch_QueryInterface(exprval.u.idref.disp, &IID_IDispatchEx, (void**)&dispex);
+    hres = disp_delete(exprval.u.idref.disp, exprval.u.idref.id, &ret);
     IDispatch_Release(exprval.u.idref.disp);
-    if(SUCCEEDED(hres)) {
-        hres = IDispatchEx_DeleteMemberByDispID(dispex, exprval.u.idref.id);
-        IDispatchEx_Release(dispex);
-        if(FAILED(hres))
-            return hres;
-
-        ret = TRUE;
-    }
+    if(FAILED(hres))
+        return ret;
 
     return stack_push(ctx, jsval_bool(ret));
 }
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 1c84823..147cc1a 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -275,6 +275,7 @@ HRESULT jsdisp_propput_idx(jsdisp_t*,DWORD,jsval_t) DECLSPEC_HIDDEN;
 HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN;
 HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
 HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN;
+HRESULT disp_delete(IDispatch*,DISPID,BOOL*) 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;




More information about the wine-cvs mailing list