Piotr Caban : jscript: Added VBArray.toArray() implementation.
Alexandre Julliard
julliard at winehq.org
Mon Oct 18 13:36:57 CDT 2010
Module: wine
Branch: master
Commit: 29cdb21218df8c3e6d78ccd5a85ececfa9cb1876
URL: http://source.winehq.org/git/wine.git/?a=commit;h=29cdb21218df8c3e6d78ccd5a85ececfa9cb1876
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Oct 18 18:48:13 2010 +0200
jscript: Added VBArray.toArray() implementation.
---
dlls/jscript/tests/api.js | 1 +
dlls/jscript/vbarray.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index d891fba..85bd556 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -2264,5 +2264,6 @@ ok(tmp.ubound("2") == 3, "tmp.ubound(\"2\") = " + tmp.ubound("2"));
ok(tmp.getItem(1, 2) == 3, "tmp.getItem(1, 2) = " + tmp.getItem(1, 2));
ok(tmp.getItem(2, 3) == 33, "tmp.getItem(2, 3) = " + tmp.getItem(2, 3));
ok(tmp.getItem(3, 2) == 13, "tmp.getItem(3, 2) = " + tmp.getItem(3, 2));
+ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43", "tmp.toArray() = " + tmp.toArray());
reportSuccess();
diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c
index 887e19b..0366aa8 100644
--- a/dlls/jscript/vbarray.c
+++ b/dlls/jscript/vbarray.c
@@ -134,8 +134,49 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DIS
static HRESULT VBArray_toArray(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;
+ jsdisp_t *array;
+ VARIANT *v;
+ int i, size = 1, ubound, lbound;
+ HRESULT hres;
+
+ TRACE("\n");
+
+ vbarray = vbarray_this(vthis);
+ if(!vbarray)
+ return throw_type_error(ctx, ei, IDS_NOT_VBARRAY, NULL);
+
+ for(i=1; i<=SafeArrayGetDim(vbarray->safearray); i++) {
+ SafeArrayGetLBound(vbarray->safearray, i, &lbound);
+ SafeArrayGetUBound(vbarray->safearray, i, &ubound);
+ size *= ubound-lbound+1;
+ }
+
+ hres = SafeArrayAccessData(vbarray->safearray, (void**)&v);
+ if(FAILED(hres))
+ return hres;
+
+ hres = create_array(ctx, 0, &array);
+ if(FAILED(hres)) {
+ SafeArrayUnaccessData(vbarray->safearray);
+ return hres;
+ }
+
+ for(i=0; i<size; i++) {
+ hres = jsdisp_propput_idx(array, i, v, ei, caller);
+ if(FAILED(hres)) {
+ SafeArrayUnaccessData(vbarray->safearray);
+ jsdisp_release(array);
+ return hres;
+ }
+ v++;
+ }
+
+ SafeArrayUnaccessData(vbarray->safearray);
+
+ if(retv)
+ var_set_jsdisp(retv, array);
+ return S_OK;
}
static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp,
More information about the wine-cvs
mailing list