jscript: Added disp_delete_name helper and use it in interp_delete.
This commit is contained in:
parent
e6fc8d9b0c
commit
466fae6444
@ -1498,6 +1498,49 @@ HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret)
|
|||||||
return S_OK;
|
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)
|
HRESULT jsdisp_is_own_prop(jsdisp_t *obj, const WCHAR *name, BOOL *ret)
|
||||||
{
|
{
|
||||||
dispex_prop_t *prop;
|
dispex_prop_t *prop;
|
||||||
|
@ -1592,7 +1592,6 @@ static HRESULT interp_mod(exec_ctx_t *ctx)
|
|||||||
static HRESULT interp_delete(exec_ctx_t *ctx)
|
static HRESULT interp_delete(exec_ctx_t *ctx)
|
||||||
{
|
{
|
||||||
jsval_t objv, namev;
|
jsval_t objv, namev;
|
||||||
IDispatchEx *dispex;
|
|
||||||
IDispatch *obj;
|
IDispatch *obj;
|
||||||
jsstr_t *name;
|
jsstr_t *name;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
@ -1617,25 +1616,7 @@ static HRESULT interp_delete(exec_ctx_t *ctx)
|
|||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = IDispatch_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex);
|
hres = disp_delete_name(ctx->script, obj, name, &ret);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDispatch_Release(obj);
|
IDispatch_Release(obj);
|
||||||
jsstr_release(name);
|
jsstr_release(name);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
|
@ -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_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN;
|
||||||
HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) 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(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_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN;
|
||||||
HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) 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 jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user