Module: wine Branch: master Commit: 9b4267b04d4f84042931c0cfb7c848fd22a6dbc4 URL: https://source.winehq.org/git/wine.git/?a=commit;h=9b4267b04d4f84042931c0cfb...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Aug 21 12:31:08 2019 +0200
jscript: Support enumerating own properties.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/dispex.c | 54 +++++++++++++++++++++++++++++--------------------- dlls/jscript/jscript.h | 1 + 2 files changed, 32 insertions(+), 23 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index b1f2914..da23d18 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -870,34 +870,14 @@ static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BS static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid) { jsdisp_t *This = impl_from_IDispatchEx(iface); - dispex_prop_t *iter; HRESULT hres;
TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
- if(id == DISPID_STARTENUM) { - hres = fill_protrefs(This); - if(FAILED(hres)) - return hres; - } - - if(id+1>=0 && id+1<This->prop_cnt) { - iter = &This->props[id+1]; - }else { + hres = jsdisp_next_prop(This, id, FALSE, pid); + if(hres == S_FALSE) *pid = DISPID_STARTENUM; - return S_FALSE; - } - - while(iter < This->props + This->prop_cnt) { - if(iter->name && (get_flags(This, iter) & PROPF_ENUMERABLE) && iter->type!=PROP_DELETED) { - *pid = prop_to_id(This, iter); - return S_OK; - } - iter++; - } - - *pid = DISPID_STARTENUM; - return S_FALSE; + return hres; }
static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk) @@ -1563,6 +1543,34 @@ HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret) return S_OK; }
+HRESULT jsdisp_next_prop(jsdisp_t *obj, DISPID id, BOOL own_only, DISPID *ret) +{ + dispex_prop_t *iter; + HRESULT hres; + + if(id == DISPID_STARTENUM && !own_only) { + hres = fill_protrefs(obj); + if(FAILED(hres)) + return hres; + } + + if(id + 1 < 0 || id+1 >= obj->prop_cnt) + return S_FALSE; + + for(iter = &obj->props[id + 1]; iter < obj->props + obj->prop_cnt; iter++) { + if(!iter->name || iter->type == PROP_DELETED) + continue; + if(own_only && iter->type == PROP_PROTREF) + continue; + if(!(get_flags(obj, iter) & PROPF_ENUMERABLE)) + continue; + *ret = prop_to_id(obj, iter); + return S_OK; + } + + return S_FALSE; +} + HRESULT disp_delete_name(script_ctx_t *ctx, IDispatch *disp, jsstr_t *name, BOOL *ret) { IDispatchEx *dispex; diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 1fbd957..2dd73d6 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -297,6 +297,7 @@ HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN; HRESULT jsdisp_get_own_property(jsdisp_t*,const WCHAR*,BOOL,property_desc_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_define_property(jsdisp_t*,const WCHAR*,property_desc_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_define_data_property(jsdisp_t*,const WCHAR*,unsigned,jsval_t) DECLSPEC_HIDDEN; +HRESULT jsdisp_next_prop(jsdisp_t*,DISPID,BOOL,DISPID*) 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;