jscript: Added disp_delete_name helper and use it in interp_delete.

This commit is contained in:
Jacek Caban 2012-11-30 13:02:19 +01:00 committed by Alexandre Julliard
parent e6fc8d9b0c
commit 466fae6444
3 changed files with 45 additions and 20 deletions

View File

@ -1498,6 +1498,49 @@ HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret)
return S_OK;
}
HRESULT disp_delete_name(script_ctx_t *ctx, IDispatch *disp, jsstr_t *name, BOOL *ret)
{
IDispatchEx *dispex;
jsdisp_t *jsdisp;
HRESULT hres;
jsdisp = iface_to_jsdisp((IUnknown*)disp);
if(jsdisp) {
dispex_prop_t *prop;
*ret = TRUE;
hres = find_prop_name(jsdisp, string_hash(name->str), name->str, &prop);
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(SUCCEEDED(hres)) {
BSTR bstr;
bstr = SysAllocStringLen(name->str, jsstr_length(name));
if(bstr) {
hres = IDispatchEx_DeleteMemberByName(dispex, bstr, make_grfdex(ctx, fdexNameCaseSensitive));
SysFreeString(bstr);
*ret = TRUE;
}else {
hres = E_OUTOFMEMORY;
}
IDispatchEx_Release(dispex);
}else {
hres = S_OK;
ret = FALSE;
}
return hres;
}
HRESULT jsdisp_is_own_prop(jsdisp_t *obj, const WCHAR *name, BOOL *ret)
{
dispex_prop_t *prop;

View File

@ -1592,7 +1592,6 @@ static HRESULT interp_mod(exec_ctx_t *ctx)
static HRESULT interp_delete(exec_ctx_t *ctx)
{
jsval_t objv, namev;
IDispatchEx *dispex;
IDispatch *obj;
jsstr_t *name;
BOOL ret;
@ -1617,25 +1616,7 @@ static HRESULT interp_delete(exec_ctx_t *ctx)
return hres;
}
hres = IDispatch_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex);
if(SUCCEEDED(hres)) {
BSTR bstr;
bstr = SysAllocStringLen(name->str, jsstr_length(name));
if(bstr) {
hres = IDispatchEx_DeleteMemberByName(dispex, bstr, make_grfdex(ctx->script, fdexNameCaseSensitive));
SysFreeString(bstr);
ret = TRUE;
}else {
hres = E_OUTOFMEMORY;
}
IDispatchEx_Release(dispex);
}else {
hres = S_OK;
ret = FALSE;
}
hres = disp_delete_name(ctx->script, obj, name, &ret);
IDispatch_Release(obj);
jsstr_release(name);
if(FAILED(hres))

View File

@ -276,6 +276,7 @@ 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 disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*);
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;