From: Gabriel Ivăncescu gabrielopcode@gmail.com
We can just use the object's prop_put now.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/array.c | 54 ++++++++++++++++++++++++++++-------------- dlls/jscript/dispex.c | 8 ++++--- dlls/jscript/jscript.h | 2 +- 3 files changed, 42 insertions(+), 22 deletions(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 64a945f9d84..6befe44b304 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -1589,25 +1589,33 @@ done: return hres; }
-static void Array_on_put(jsdisp_t *dispex, const WCHAR *name) +static HRESULT Array_prop_put(jsdisp_t *dispex, DISPID id, jsval_t val) { ArrayInstance *array = array_from_jsdisp(dispex); - const WCHAR *ptr = name; - DWORD id = 0; + const WCHAR *ptr; + DWORD idx = 0; + HRESULT hres; + + hres = dispex_prop_put(&array->dispex, id, val); + if(hres != S_OK) + return hres;
+ ptr = dispex_prop_get_static_name(&array->dispex, id); if(!is_digit(*ptr)) - return; + return hres;
while(*ptr && is_digit(*ptr)) { - id = id*10 + (*ptr-'0'); + idx = idx*10 + (*ptr-'0'); ptr++; }
if(*ptr) - return; + return hres;
- if(id >= array->length) - array->length = id+1; + if(idx >= array->length) + array->length = idx + 1; + + return hres; }
static const builtin_prop_t Array_props[] = { @@ -1635,11 +1643,16 @@ static const builtin_prop_t Array_props[] = { };
static const builtin_info_t Array_info = { - DEFAULT_DISPEX_PROP_VTBL_ENTRIES, - .class = JSCLASS_ARRAY, - .props_cnt = ARRAY_SIZE(Array_props), - .props = Array_props, - .on_put = Array_on_put, + .class = JSCLASS_ARRAY, + .props_cnt = ARRAY_SIZE(Array_props), + .props = Array_props, + .prop_get = dispex_prop_get, + .prop_put = Array_prop_put, + .prop_invoke = dispex_prop_invoke, + .prop_delete = dispex_prop_delete, + .prop_get_desc = dispex_prop_get_desc, + .prop_get_name = dispex_prop_get_name, + .prop_define = dispex_prop_define };
static const builtin_prop_t ArrayInst_props[] = { @@ -1647,11 +1660,16 @@ static const builtin_prop_t ArrayInst_props[] = { };
static const builtin_info_t ArrayInst_info = { - DEFAULT_DISPEX_PROP_VTBL_ENTRIES, - .class = JSCLASS_ARRAY, - .props_cnt = ARRAY_SIZE(ArrayInst_props), - .props = ArrayInst_props, - .on_put = Array_on_put, + .class = JSCLASS_ARRAY, + .props_cnt = ARRAY_SIZE(ArrayInst_props), + .props = ArrayInst_props, + .prop_get = dispex_prop_get, + .prop_put = Array_prop_put, + .prop_invoke = dispex_prop_invoke, + .prop_delete = dispex_prop_delete, + .prop_get_desc = dispex_prop_get_desc, + .prop_get_name = dispex_prop_get_name, + .prop_define = dispex_prop_define };
/* ECMA-262 5.1 Edition 15.4.3.2 */ diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 900407d9d23..7fa5bab0eea 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -572,9 +572,6 @@ HRESULT dispex_prop_put(jsdisp_t *jsdisp, DISPID id, jsval_t val) if(FAILED(hres)) return hres;
- if(jsdisp->builtin_info->on_put) - jsdisp->builtin_info->on_put(jsdisp, prop->name); - return S_OK; }
@@ -819,6 +816,11 @@ HRESULT dispex_prop_define(jsdisp_t *jsdisp, DISPID id, const property_desc_t *d return S_OK; }
+const WCHAR *dispex_prop_get_static_name(jsdisp_t *jsdisp, DISPID id) +{ + return jsdisp->props[prop_id_to_idx(id)].name; +} + static HRESULT fill_props(jsdisp_t *obj) { HRESULT hres; diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 93c7eb5aadd..70d71b34337 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -137,6 +137,7 @@ HRESULT dispex_prop_delete(jsdisp_t*,DISPID,BOOL*); HRESULT dispex_prop_get_desc(jsdisp_t*,DISPID,BOOL,property_desc_t*); void *dispex_prop_get_name(jsdisp_t*,DISPID,BOOL); HRESULT dispex_prop_define(jsdisp_t*,DISPID,const property_desc_t*); +const WCHAR *dispex_prop_get_static_name(jsdisp_t*,DISPID);
struct thread_data { LONG ref; @@ -191,7 +192,6 @@ typedef struct { DWORD props_cnt; const builtin_prop_t *props; void (*destructor)(jsdisp_t*); - void (*on_put)(jsdisp_t*,const WCHAR*); HRESULT (*prop_get)(jsdisp_t*,IDispatch*,DISPID,jsval_t*); HRESULT (*prop_put)(jsdisp_t*,DISPID,jsval_t); HRESULT (*prop_invoke)(jsdisp_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*,IServiceProvider*);