From: Gabriel Ivăncescu gabrielopcode@gmail.com
No-op, but this describes the intent better, as we're not enumerating enumerable props only, we're filling them for enumeration done on jscript side (this is not called during enumeration itself, but as a prequel), and will be needed later.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 99 +++++++++++++++++++++------------------- dlls/jscript/function.c | 16 +++---- dlls/jscript/jscript.h | 4 +- dlls/jscript/jsdisp.idl | 3 +- dlls/jscript/string.c | 22 ++++----- dlls/mshtml/dispex.c | 45 +++++++++++------- dlls/mshtml/htmlwindow.c | 7 ++- 7 files changed, 107 insertions(+), 89 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 058945d1a5f..5c72640a599 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -501,21 +501,6 @@ HRESULT jsdisp_index_lookup(jsdisp_t *obj, const WCHAR *name, unsigned length, s return S_OK; }
-HRESULT jsdisp_next_index(jsdisp_t *obj, unsigned length, unsigned id, struct property_info *desc) -{ - if(id + 1 == length) - return S_FALSE; - - desc->id = id + 1; - desc->flags = PROPF_ENUMERABLE; - if(obj->builtin_info->prop_put) - desc->flags |= PROPF_WRITABLE; - desc->name = NULL; - desc->index = desc->id; - desc->iid = 0; - return S_OK; -} - static IDispatch *get_this(DISPPARAMS *dp) { DWORD i; @@ -758,31 +743,10 @@ static HRESULT fill_props(jsdisp_t *obj) return hres; }
- if(obj->builtin_info->next_prop) { - struct property_info desc; - unsigned id = ~0; - WCHAR buf[12]; - - for(;;) { - hres = obj->builtin_info->next_prop(obj, id, &desc); - if(FAILED(hres)) - return hres; - if(hres == S_FALSE) - break; - - if(!desc.name) { - swprintf(buf, ARRAYSIZE(buf), L"%u", desc.index); - desc.name = buf; - } - - prop = lookup_dispex_prop(obj, string_hash(desc.name), desc.name, FALSE); - if(!prop) { - hres = update_external_prop(obj, desc.name, NULL, &desc, &prop); - if(FAILED(hres)) - return hres; - } - id = desc.id; - } + if(obj->builtin_info->fill_props) { + hres = obj->builtin_info->fill_props(obj); + if(FAILED(hres)) + return hres; }
return S_OK; @@ -2426,6 +2390,25 @@ static HRESULT WINAPI WineJSDispatch_DefineProperty(IWineJSDispatch *iface, cons return hres; }
+static HRESULT WINAPI WineJSDispatch_UpdateProperty(IWineJSDispatch *iface, struct property_info *desc) +{ + jsdisp_t *This = impl_from_IWineJSDispatch(iface); + const WCHAR *name = desc->name; + dispex_prop_t *prop; + HRESULT hres = S_OK; + WCHAR buf[12]; + + if(!name) { + swprintf(buf, ARRAYSIZE(buf), L"%u", desc->index); + name = buf; + } + + if(!(prop = lookup_dispex_prop(This, string_hash(name), name, FALSE))) + hres = update_external_prop(This, name, NULL, desc, &prop); + + return hres; +} + static HRESULT WINAPI WineJSDispatch_GetScriptGlobal(IWineJSDispatch *iface, IWineJSDispatchHost **ret) { jsdisp_t *This = impl_from_IWineJSDispatch(iface); @@ -2460,6 +2443,7 @@ static IWineJSDispatchVtbl DispatchExVtbl = { WineJSDispatch_Free, WineJSDispatch_GetPropertyFlags, WineJSDispatch_DefineProperty, + WineJSDispatch_UpdateProperty, WineJSDispatch_GetScriptGlobal, };
@@ -3095,6 +3079,27 @@ HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret) return S_OK; }
+HRESULT jsdisp_fill_indices(jsdisp_t *obj, unsigned length) +{ + struct property_info desc; + HRESULT hres; + + desc.flags = PROPF_ENUMERABLE; + if(obj->builtin_info->prop_put) + desc.flags |= PROPF_WRITABLE; + desc.name = NULL; + desc.iid = 0; + + for(desc.index = 0; desc.index < length; desc.index++) { + desc.id = desc.index; + hres = WineJSDispatch_UpdateProperty(&obj->IWineJSDispatch_iface, &desc); + if(FAILED(hres)) + return hres; + } + + return S_OK; +} + HRESULT jsdisp_next_prop(jsdisp_t *obj, DISPID id, enum jsdisp_enum_type enum_type, DISPID *ret) { dispex_prop_t *iter; @@ -3530,25 +3535,25 @@ static HRESULT HostObject_prop_put(jsdisp_t *jsdisp, unsigned idx, jsval_t v) return hres; }
-static HRESULT HostObject_next_prop(jsdisp_t *jsdisp, unsigned id, struct property_info *desc) +static HRESULT HostObject_prop_delete(jsdisp_t *jsdisp, unsigned id) { HostObject *This = HostObject_from_jsdisp(jsdisp);
- return IWineJSDispatchHost_NextProperty(This->host_iface, id, desc); + return IWineJSDispatchHost_DeleteProperty(This->host_iface, id); }
-static HRESULT HostObject_prop_delete(jsdisp_t *jsdisp, unsigned id) +static HRESULT HostObject_prop_config(jsdisp_t *jsdisp, unsigned id, unsigned flags) { HostObject *This = HostObject_from_jsdisp(jsdisp);
- return IWineJSDispatchHost_DeleteProperty(This->host_iface, id); + return IWineJSDispatchHost_ConfigureProperty(This->host_iface, id, flags); }
-static HRESULT HostObject_prop_config(jsdisp_t *jsdisp, unsigned id, unsigned flags) +static HRESULT HostObject_fill_props(jsdisp_t *jsdisp) { HostObject *This = HostObject_from_jsdisp(jsdisp);
- return IWineJSDispatchHost_ConfigureProperty(This->host_iface, id, flags); + return IWineJSDispatchHost_FillProperties(This->host_iface); }
static HRESULT HostObject_to_string(jsdisp_t *jsdisp, jsstr_t **ret) @@ -3573,9 +3578,9 @@ static const builtin_info_t HostObject_info = { .lookup_prop = HostObject_lookup_prop, .prop_get = HostObject_prop_get, .prop_put = HostObject_prop_put, - .next_prop = HostObject_next_prop, .prop_delete = HostObject_prop_delete, .prop_config = HostObject_prop_config, + .fill_props = HostObject_fill_props, .to_string = HostObject_to_string, };
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 54b8f5abe2f..ffb55af0922 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -137,12 +137,6 @@ static HRESULT Arguments_lookup_prop(jsdisp_t *jsdisp, const WCHAR *name, unsign return jsdisp_index_lookup(&arguments->jsdisp, name, arguments->argc, desc); }
-static HRESULT Arguments_next_prop(jsdisp_t *jsdisp, unsigned id, struct property_info *desc) -{ - ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp); - return jsdisp_next_index(&arguments->jsdisp, arguments->argc, id, desc); -} - static jsval_t *get_argument_ref(ArgumentsInstance *arguments, unsigned idx) { if(arguments->buf) @@ -179,6 +173,12 @@ static HRESULT Arguments_prop_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val) return S_OK; }
+static HRESULT Arguments_fill_props(jsdisp_t *jsdisp) +{ + ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp); + return jsdisp_fill_indices(&arguments->jsdisp, arguments->argc); +} + static HRESULT Arguments_gc_traverse(struct gc_ctx *gc_ctx, enum gc_traverse_op op, jsdisp_t *jsdisp) { ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp); @@ -240,9 +240,9 @@ static const builtin_info_t Arguments_info = { .props = Arguments_props, .destructor = Arguments_destructor, .lookup_prop = Arguments_lookup_prop, - .next_prop = Arguments_next_prop, .prop_get = Arguments_prop_get, .prop_put = Arguments_prop_put, + .fill_props = Arguments_fill_props, .gc_traverse = Arguments_gc_traverse };
@@ -251,9 +251,9 @@ static const builtin_info_t Arguments_ES5_info = { .call = Arguments_value, .destructor = Arguments_destructor, .lookup_prop = Arguments_lookup_prop, - .next_prop = Arguments_next_prop, .prop_get = Arguments_prop_get, .prop_put = Arguments_prop_put, + .fill_props = Arguments_fill_props, .gc_traverse = Arguments_gc_traverse };
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index d42dd3a8a8a..6f4266edd44 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -184,11 +184,11 @@ typedef struct { ULONG (*release)(jsdisp_t*); void (*on_put)(jsdisp_t*,const WCHAR*); HRESULT (*lookup_prop)(jsdisp_t*,const WCHAR*,unsigned,struct property_info*); - HRESULT (*next_prop)(jsdisp_t*,unsigned,struct property_info*); HRESULT (*prop_get)(jsdisp_t*,unsigned,jsval_t*); HRESULT (*prop_put)(jsdisp_t*,unsigned,jsval_t); HRESULT (*prop_delete)(jsdisp_t*,unsigned); HRESULT (*prop_config)(jsdisp_t*,unsigned,unsigned); + HRESULT (*fill_props)(jsdisp_t*); HRESULT (*to_string)(jsdisp_t*,jsstr_t**); HRESULT (*gc_traverse)(struct gc_ctx*,enum gc_traverse_op,jsdisp_t*); } builtin_info_t; @@ -263,7 +263,7 @@ HRESULT jsdisp_get_idx_id(jsdisp_t*,DWORD,DISPID*); HRESULT disp_delete(IDispatch*,DISPID,BOOL*); HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*); HRESULT jsdisp_index_lookup(jsdisp_t*,const WCHAR*,unsigned,struct property_info*); -HRESULT jsdisp_next_index(jsdisp_t*,unsigned,unsigned,struct property_info*); +HRESULT jsdisp_fill_indices(jsdisp_t*,unsigned); HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD); HRESULT jsdisp_get_own_property(jsdisp_t*,const WCHAR*,BOOL,property_desc_t*); HRESULT jsdisp_define_property(jsdisp_t*,const WCHAR*,property_desc_t*); diff --git a/dlls/jscript/jsdisp.idl b/dlls/jscript/jsdisp.idl index c55626fae66..a96214a98b6 100644 --- a/dlls/jscript/jsdisp.idl +++ b/dlls/jscript/jsdisp.idl @@ -53,6 +53,7 @@ interface IWineJSDispatch : IDispatchEx void Free(); HRESULT GetPropertyFlags(DISPID id, UINT32 *ret); HRESULT DefineProperty(const WCHAR *name, unsigned int flags, VARIANT *v); + HRESULT UpdateProperty(struct property_info *desc); HRESULT GetScriptGlobal(IWineJSDispatchHost **ret); }
@@ -65,13 +66,13 @@ interface IWineJSDispatchHost : IDispatchEx { HRESULT GetJSDispatch(IWineJSDispatch **ret); HRESULT LookupProperty(const WCHAR *name, DWORD flags, struct property_info *desc); - HRESULT NextProperty(DISPID id, struct property_info *desc); HRESULT GetProperty(DISPID id, LCID lcid, VARIANT *r, EXCEPINFO *ei, IServiceProvider *caller); HRESULT SetProperty(DISPID id, LCID lcid, VARIANT *v, EXCEPINFO *ei, IServiceProvider *caller); HRESULT DeleteProperty(DISPID id); HRESULT ConfigureProperty(DISPID id, UINT32 flags); HRESULT CallFunction(DISPID id, UINT32 iid, DWORD flags, DISPPARAMS *dp, VARIANT *ret, EXCEPINFO *ei, IServiceProvider *caller); HRESULT Construct(LCID lcid, DWORD flags, DISPPARAMS *dp, VARIANT *ret, EXCEPINFO *ei, IServiceProvider *caller); + HRESULT FillProperties(); HRESULT GetOuterDispatch(IWineJSDispatchHost **ret); HRESULT ToString(BSTR *str); } diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 968b74f9602..42a2c697fbc 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -1517,16 +1517,6 @@ static HRESULT String_lookup_prop(jsdisp_t *jsdisp, const WCHAR *name, unsigned return jsdisp_index_lookup(&string->dispex, name, jsstr_length(string->str), desc); }
-static HRESULT String_next_prop(jsdisp_t *jsdisp, unsigned id, struct property_info *desc) -{ - StringInstance *string = string_from_jsdisp(jsdisp); - - if(string->dispex.ctx->version < 2) - return S_FALSE; - - return jsdisp_next_index(&string->dispex, jsstr_length(string->str), id, desc); -} - static HRESULT String_prop_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r) { StringInstance *string = string_from_jsdisp(jsdisp); @@ -1542,6 +1532,16 @@ static HRESULT String_prop_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r) return S_OK; }
+static HRESULT String_fill_props(jsdisp_t *jsdisp) +{ + StringInstance *string = string_from_jsdisp(jsdisp); + + if(string->dispex.ctx->version < 2) + return S_OK; + + return jsdisp_fill_indices(&string->dispex, jsstr_length(string->str)); +} + static const builtin_prop_t String_props[] = { {L"anchor", String_anchor, PROPF_METHOD|1}, {L"big", String_big, PROPF_METHOD}, @@ -1596,8 +1596,8 @@ static const builtin_info_t StringInst_info = { .props = StringInst_props, .destructor = String_destructor, .lookup_prop = String_lookup_prop, - .next_prop = String_next_prop, .prop_get = String_prop_get, + .fill_props = String_fill_props, };
/* ECMA-262 3rd Edition 15.5.3.2 */ diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 43896729a9e..0290d61f04c 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -2670,21 +2670,6 @@ static HRESULT WINAPI JSDispatchHost_LookupProperty(IWineJSDispatchHost *iface, return get_host_property_descriptor(This, id, desc); }
-static HRESULT WINAPI JSDispatchHost_NextProperty(IWineJSDispatchHost *iface, DISPID id, struct property_info *desc) -{ - DispatchEx *This = impl_from_IWineJSDispatchHost(iface); - DISPID next; - HRESULT hres; - - TRACE("%s (%p)->(%lx)\n", This->info->name, This, id); - - hres = dispex_next_id(This, id, TRUE, &next); - if(hres != S_OK) - return hres; - - return get_host_property_descriptor(This, next, desc); -} - static HRESULT WINAPI JSDispatchHost_GetProperty(IWineJSDispatchHost *iface, DISPID id, LCID lcid, VARIANT *r, EXCEPINFO *ei, IServiceProvider *caller) { @@ -2772,6 +2757,34 @@ static HRESULT WINAPI JSDispatchHost_Construct(IWineJSDispatchHost *iface, LCID return dispex_prop_call(This, DISPID_VALUE, lcid, flags, dp, ret, ei, caller); }
+static HRESULT WINAPI JSDispatchHost_FillProperties(IWineJSDispatchHost *iface) +{ + DispatchEx *This = impl_from_IWineJSDispatchHost(iface); + DISPID id = DISPID_STARTENUM; + struct property_info desc; + HRESULT hres; + + TRACE("%s (%p)->(%lx)\n", This->info->name, This, id); + + for(;;) { + hres = dispex_next_id(This, id, TRUE, &id); + if(FAILED(hres)) + return hres; + if(hres == S_FALSE) + break; + + hres = get_host_property_descriptor(This, id, &desc); + if(FAILED(hres)) + return hres; + + hres = IWineJSDispatch_UpdateProperty(This->jsdisp, &desc); + if(FAILED(hres)) + return hres; + } + + return S_OK; +} + static HRESULT WINAPI JSDispatchHost_GetOuterDispatch(IWineJSDispatchHost *iface, IWineJSDispatchHost **ret) { DispatchEx *This = impl_from_IWineJSDispatchHost(iface); @@ -2807,13 +2820,13 @@ static IWineJSDispatchHostVtbl JSDispatchHostVtbl = { DispatchEx_GetNameSpaceParent, JSDispatchHost_GetJSDispatch, JSDispatchHost_LookupProperty, - JSDispatchHost_NextProperty, JSDispatchHost_GetProperty, JSDispatchHost_SetProperty, JSDispatchHost_DeleteProperty, JSDispatchHost_ConfigureProperty, JSDispatchHost_CallFunction, JSDispatchHost_Construct, + JSDispatchHost_FillProperties, JSDispatchHost_GetOuterDispatch, JSDispatchHost_ToString, }; diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 8913c4e511c..c964fdb9b02 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3439,12 +3439,11 @@ static HRESULT WINAPI WindowDispEx_LookupProperty(IWineJSDispatchHost *iface, co name, flags, desc); }
-static HRESULT WINAPI WindowDispEx_NextProperty(IWineJSDispatchHost *iface, DISPID id, struct property_info *desc) +static HRESULT WINAPI WindowDispEx_FillProperties(IWineJSDispatchHost *iface) { HTMLOuterWindow *This = impl_from_IWineJSDispatchHost(iface);
- return IWineJSDispatchHost_NextProperty(&This->base.inner_window->event_target.dispex.IWineJSDispatchHost_iface, - id, desc); + return IWineJSDispatchHost_FillProperties(&This->base.inner_window->event_target.dispex.IWineJSDispatchHost_iface); }
static HRESULT WINAPI WindowDispEx_GetProperty(IWineJSDispatchHost *iface, DISPID id, LCID lcid, VARIANT *r, @@ -3531,13 +3530,13 @@ static const IWineJSDispatchHostVtbl WindowDispExVtbl = { WindowDispEx_GetNameSpaceParent, WindowDispEx_GetJSDispatch, WindowDispEx_LookupProperty, - WindowDispEx_NextProperty, WindowDispEx_GetProperty, WindowDispEx_SetProperty, WindowDispEx_DeleteProperty, WindowDispEx_ConfigureProperty, WindowDispEx_CallFunction, WindowDispEx_Construct, + WindowDispEx_FillProperties, WindowDispEx_GetOuterDispatch, WindowDispEx_ToString, };