From: Gabriel Ivăncescu gabrielopcode@gmail.com
So it can work on any prop in the future, not just dispex props.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/dispex.c | 68 ++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 30 deletions(-)
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index f45838f3109..ad31f37c9fb 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -108,6 +108,16 @@ static inline BOOL get_prop(jsdisp_t *This, DISPID id, struct prop_desc *ret) return TRUE; }
+static inline struct prop_desc get_prop_from_protref(jsdisp_t *prot, DWORD ref) +{ + struct prop_desc prop; + + prop.vtbl = &dispex_prop_vtbl; + prop.jsdisp = prot; + prop.id = ref + 1; + return prop; +} + static inline BOOL is_function_prop(dispex_prop_t *prop) { BOOL ret = FALSE; @@ -579,40 +589,54 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val) return S_OK; }
-static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t *prop, WORD flags, - unsigned argc, jsval_t *argv, jsval_t *r, IServiceProvider *caller) +static HRESULT dispex_prop_get(struct prop_desc *prop, IDispatch *jsthis, jsval_t *r) { + return prop_get(prop->jsdisp, jsthis, &prop->jsdisp->props[prop_id_to_idx(prop->id)], r); +} + +static HRESULT dispex_prop_put(struct prop_desc *prop, jsval_t val) +{ + return prop_put(prop->jsdisp, &prop->jsdisp->props[prop_id_to_idx(prop->id)], val); +} + +static HRESULT dispex_prop_invoke(struct prop_desc *prop, IDispatch *jsthis, WORD flags, + unsigned argc, jsval_t *argv, jsval_t *r, IServiceProvider *caller) +{ + dispex_prop_t *p = &prop->jsdisp->props[prop_id_to_idx(prop->id)]; + jsdisp_t *jsdisp = prop->jsdisp; HRESULT hres;
- switch(prop->type) { + switch(p->type) { case PROP_BUILTIN: return JS_E_FUNCTION_EXPECTED; - case PROP_PROTREF: - return invoke_prop_func(This->prototype, jsthis ? jsthis : (IDispatch *)&This->IDispatchEx_iface, - This->prototype->props+prop->u.ref, flags, argc, argv, r, caller); + case PROP_PROTREF: { + struct prop_desc prot_prop = get_prop_from_protref(jsdisp->prototype, p->u.ref); + return prot_prop.vtbl->invoke(&prot_prop, jsthis ? jsthis : (IDispatch*)&jsdisp->IDispatchEx_iface, + flags, argc, argv, r, caller); + } case PROP_JSVAL: { - if(!is_object_instance(prop->u.val)) { - FIXME("invoke %s\n", debugstr_jsval(prop->u.val)); + if(!is_object_instance(p->u.val)) { + FIXME("invoke %s\n", debugstr_jsval(p->u.val)); return E_FAIL; }
- TRACE("call %s %p\n", debugstr_w(prop->name), get_object(prop->u.val)); + TRACE("call %s %p\n", debugstr_w(p->name), get_object(p->u.val));
- return disp_call_value_with_caller(This->ctx, get_object(prop->u.val), - jsval_disp(jsthis ? jsthis : (IDispatch*)&This->IDispatchEx_iface), + return disp_call_value_with_caller(jsdisp->ctx, get_object(p->u.val), + jsval_disp(jsthis ? jsthis : (IDispatch*)&jsdisp->IDispatchEx_iface), flags, argc, argv, r, caller); } case PROP_ACCESSOR: case PROP_IDX: { jsval_t val;
- hres = prop_get(This, jsthis ? jsthis : (IDispatch *)&This->IDispatchEx_iface, prop, &val); + hres = dispex_prop_get(prop, jsthis ? jsthis : (IDispatch*)&jsdisp->IDispatchEx_iface, &val); if(FAILED(hres)) return hres;
if(is_object_instance(val)) { - hres = disp_call_value_with_caller(This->ctx, get_object(val), - jsval_disp(jsthis ? jsthis : (IDispatch*)&This->IDispatchEx_iface), + hres = disp_call_value_with_caller(jsdisp->ctx, get_object(val), + jsval_disp(jsthis ? jsthis : (IDispatch*)&jsdisp->IDispatchEx_iface), flags, argc, argv, r, caller); }else { FIXME("invoke %s\n", debugstr_jsval(val)); @@ -630,22 +654,6 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t return E_FAIL; }
-static HRESULT dispex_prop_get(struct prop_desc *prop, IDispatch *jsthis, jsval_t *r) -{ - return prop_get(prop->jsdisp, jsthis, &prop->jsdisp->props[prop_id_to_idx(prop->id)], r); -} - -static HRESULT dispex_prop_put(struct prop_desc *prop, jsval_t val) -{ - return prop_put(prop->jsdisp, &prop->jsdisp->props[prop_id_to_idx(prop->id)], val); -} - -static HRESULT dispex_prop_invoke(struct prop_desc *prop, IDispatch *jsthis, WORD flags, - unsigned argc, jsval_t *argv, jsval_t *r, IServiceProvider *caller) -{ - return invoke_prop_func(prop->jsdisp, jsthis, &prop->jsdisp->props[prop_id_to_idx(prop->id)], flags, argc, argv, r, caller); -} - static HRESULT dispex_prop_delete(struct prop_desc *prop, BOOL *ret) { dispex_prop_t *p = &prop->jsdisp->props[prop_id_to_idx(prop->id)];