Module: wine Branch: master Commit: 2aa7e3c6147ad53ab7edd8be160bfddf95af82b3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2aa7e3c6147ad53ab7edd8be16...
Author: Piotr Caban piotr@codeweavers.com Date: Mon Oct 18 18:47:37 2010 +0200
jscript: Added VBArray.ubound() implementation.
---
dlls/jscript/tests/api.js | 2 ++ dlls/jscript/vbarray.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index a6c0c5a..72ed4ea 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -2256,5 +2256,7 @@ tmp = new VBArray(VBArray(createArray())); ok(tmp.lbound() == 0, "tmp.lbound() = " + tmp.lbound()); ok(tmp.lbound(1) == 0, "tmp.lbound(1) = " + tmp.lbound(1)); ok(tmp.lbound(2, 1) == 2, "tmp.lbound(2, 1) = " + tmp.lbound(2, 1)); +ok(tmp.ubound() == 4, "tmp.ubound() = " + tmp.ubound()); +ok(tmp.ubound("2") == 3, "tmp.ubound("2") = " + tmp.ubound("2"));
reportSuccess(); diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c index 12bb7c0..1257d56 100644 --- a/dlls/jscript/vbarray.c +++ b/dlls/jscript/vbarray.c @@ -99,8 +99,32 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DI static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { - FIXME("\n"); - return E_NOTIMPL; + VBArrayInstance *vbarray; + int dim; + HRESULT hres; + + TRACE("\n"); + + vbarray = vbarray_this(vthis); + if(!vbarray) + return throw_type_error(ctx, ei, IDS_NOT_VBARRAY, NULL); + + if(arg_cnt(dp)) { + hres = to_int32(ctx, get_arg(dp, 0), ei, &dim); + if(FAILED(hres)) + return hres; + } else + dim = 1; + + hres = SafeArrayGetUBound(vbarray->safearray, dim, &dim); + if(hres == DISP_E_BADINDEX) + return throw_range_error(ctx, ei, IDS_SUBSCRIPT_OUT_OF_RANGE, NULL); + else if(FAILED(hres)) + return hres; + + if(retv) + num_set_val(retv, dim); + return S_OK; }
static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,