jscript: Return array length in Array.unshift for invoke version >= 2.

This commit is contained in:
Jacek Caban 2009-10-19 20:40:39 +02:00 committed by Alexandre Julliard
parent a1ac9d661f
commit 96cbc45a52
1 changed files with 30 additions and 25 deletions

View File

@ -967,29 +967,25 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP
return hres; return hres;
argc = arg_cnt(dp); argc = arg_cnt(dp);
if(!argc) { if(argc) {
if(retv) buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1;
V_VT(retv) = VT_EMPTY; *buf_end-- = 0;
return S_OK; i = length;
}
buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; while(i--) {
*buf_end-- = 0; str = idx_to_str(i, buf_end);
i = length;
while(i--) { hres = jsdisp_get_id(jsthis, str, 0, &id);
str = idx_to_str(i, buf_end); if(SUCCEEDED(hres)) {
hres = jsdisp_propget(jsthis, id, &var, ei, caller);
if(FAILED(hres))
return hres;
hres = jsdisp_get_id(jsthis, str, 0, &id); hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller);
if(SUCCEEDED(hres)) { VariantClear(&var);
hres = jsdisp_propget(jsthis, id, &var, ei, caller); }else if(hres == DISP_E_UNKNOWNNAME) {
if(FAILED(hres)) hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id);
return hres; }
hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller);
VariantClear(&var);
}else if(hres == DISP_E_UNKNOWNNAME) {
hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id);
} }
if(FAILED(hres)) if(FAILED(hres))
@ -1002,12 +998,21 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP
return hres; return hres;
} }
hres = set_length(jsthis, ei, length+argc); if(argc) {
if(FAILED(hres)) length += argc;
return hres; hres = set_length(jsthis, ei, length);
if(FAILED(hres))
return hres;
}
if(retv) if(retv) {
V_VT(retv) = VT_EMPTY; if(ctx->version < 2) {
V_VT(retv) = VT_EMPTY;
}else {
V_VT(retv) = VT_I4;
V_I4(retv) = length;
}
}
return S_OK; return S_OK;
} }