Commit 29cdb212 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

jscript: Added VBArray.toArray() implementation.

parent 41d7f8fc
......@@ -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();
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment