Module: wine Branch: master Commit: 96cbc45a528966bff136d3f5214edfb69cafbb58 URL: http://source.winehq.org/git/wine.git/?a=commit;h=96cbc45a528966bff136d3f521...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Oct 19 20:40:39 2009 +0200
jscript: Return array length in Array.unshift for invoke version >= 2.
---
dlls/jscript/array.c | 55 +++++++++++++++++++++++++++---------------------- 1 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index e4ee4db..8ce35cf 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -967,29 +967,25 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres;
argc = arg_cnt(dp); - if(!argc) { - if(retv) - V_VT(retv) = VT_EMPTY; - return S_OK; - } - - buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; - *buf_end-- = 0; - i = length; + if(argc) { + buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; + *buf_end-- = 0; + i = length;
- while(i--) { - str = idx_to_str(i, buf_end); + while(i--) { + str = idx_to_str(i, buf_end);
- hres = jsdisp_get_id(jsthis, str, 0, &id); - if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis, id, &var, ei, caller); - if(FAILED(hres)) - return hres; + hres = jsdisp_get_id(jsthis, str, 0, &id); + if(SUCCEEDED(hres)) { + hres = jsdisp_propget(jsthis, id, &var, ei, caller); + if(FAILED(hres)) + 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); + 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)) @@ -1002,12 +998,21 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres; }
- hres = set_length(jsthis, ei, length+argc); - if(FAILED(hres)) - return hres; + if(argc) { + length += argc; + hres = set_length(jsthis, ei, length); + if(FAILED(hres)) + return hres; + }
- if(retv) - V_VT(retv) = VT_EMPTY; + if(retv) { + if(ctx->version < 2) { + V_VT(retv) = VT_EMPTY; + }else { + V_VT(retv) = VT_I4; + V_I4(retv) = length; + } + } return S_OK; }