jscript: Add Object.defineProperties implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9b4267b04d
commit
34d4a9c751
|
@ -409,6 +409,57 @@ static HRESULT to_property_descriptor(script_ctx_t *ctx, jsdisp_t *attr_obj, pro
|
|||
return hres;
|
||||
}
|
||||
|
||||
static HRESULT jsdisp_define_properties(script_ctx_t *ctx, jsdisp_t *obj, jsval_t list_val)
|
||||
{
|
||||
DISPID id = DISPID_STARTENUM;
|
||||
property_desc_t prop_desc;
|
||||
IDispatch *list_disp;
|
||||
jsdisp_t *list_obj, *desc_obj;
|
||||
jsval_t desc_val;
|
||||
BSTR name;
|
||||
HRESULT hres;
|
||||
|
||||
hres = to_object(ctx, list_val, &list_disp);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
if(!(list_obj = to_jsdisp(list_disp))) {
|
||||
FIXME("non-JS list obj\n");
|
||||
IDispatch_Release(list_disp);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
hres = jsdisp_next_prop(list_obj, id, TRUE, &id);
|
||||
if(hres != S_OK)
|
||||
break;
|
||||
|
||||
hres = jsdisp_propget(list_obj, id, &desc_val);
|
||||
if(FAILED(hres))
|
||||
break;
|
||||
|
||||
if(!is_object_instance(desc_val) || !get_object(desc_val) || !(desc_obj = to_jsdisp(get_object(desc_val)))) {
|
||||
jsval_release(desc_val);
|
||||
break;
|
||||
}
|
||||
|
||||
hres = to_property_descriptor(ctx, desc_obj, &prop_desc);
|
||||
jsdisp_release(desc_obj);
|
||||
if(FAILED(hres))
|
||||
break;
|
||||
|
||||
hres = IDispatchEx_GetMemberName(&list_obj->IDispatchEx_iface, id, &name);
|
||||
if(SUCCEEDED(hres))
|
||||
hres = jsdisp_define_property(obj, name, &prop_desc);
|
||||
release_property_descriptor(&prop_desc);
|
||||
if(FAILED(hres))
|
||||
break;
|
||||
}
|
||||
|
||||
jsdisp_release(list_obj);
|
||||
return FAILED(hres) ? hres : S_OK;
|
||||
}
|
||||
|
||||
static HRESULT Object_defineProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
||||
unsigned argc, jsval_t *argv, jsval_t *r)
|
||||
{
|
||||
|
@ -455,10 +506,22 @@ static HRESULT Object_defineProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
|
|||
static HRESULT Object_defineProperties(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
||||
unsigned argc, jsval_t *argv, jsval_t *r)
|
||||
{
|
||||
FIXME("\n");
|
||||
jsdisp_t *obj;
|
||||
HRESULT hres;
|
||||
|
||||
if(argc < 1 || !is_object_instance(argv[0]) || !get_object(argv[0]) || !(obj = to_jsdisp(get_object(argv[0])))) {
|
||||
FIXME("not an object\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
TRACE("%p\n", obj);
|
||||
|
||||
hres = jsdisp_define_properties(ctx, obj, argc >= 2 ? argv[1] : jsval_undefined());
|
||||
if(SUCCEEDED(hres) && r)
|
||||
*r = jsval_obj(jsdisp_addref(obj));
|
||||
return hres;
|
||||
}
|
||||
|
||||
static HRESULT Object_getOwnPropertyDescriptor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
||||
unsigned argc, jsval_t *argv, jsval_t *r)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue