Commit 0a15f2e0 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

vbscript: Add Array implementation.

parent cfcc0dda
......@@ -1792,8 +1792,44 @@ static HRESULT Global_TypeName(vbdisp_t *This, VARIANT *arg, unsigned args_cnt,
static HRESULT Global_Array(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
SAFEARRAYBOUND bounds;
SAFEARRAY *sa;
VARIANT *data;
HRESULT hres;
unsigned i;
TRACE("arg_cnt=%u\n", args_cnt);
bounds.lLbound = 0;
bounds.cElements = args_cnt;
sa = SafeArrayCreate(VT_VARIANT, 1, &bounds);
if(!sa)
return E_OUTOFMEMORY;
hres = SafeArrayAccessData(sa, (void**)&data);
if(FAILED(hres)) {
SafeArrayDestroy(sa);
return hres;
}
for(i=0; i<args_cnt; i++) {
hres = VariantCopyInd(data+i, arg+i);
if(FAILED(hres)) {
SafeArrayUnaccessData(sa);
SafeArrayDestroy(sa);
return hres;
}
}
SafeArrayUnaccessData(sa);
if(res) {
V_VT(res) = VT_ARRAY|VT_VARIANT;
V_ARRAY(res) = sa;
}else {
SafeArrayDestroy(sa);
}
return S_OK;
}
static HRESULT Global_Erase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
......@@ -2272,7 +2308,7 @@ static const builtin_prop_t global_props[] = {
{DISPID_GLOBAL_DATEDIFF, Global_DateDiff, 0, 3, 5},
{DISPID_GLOBAL_DATEPART, Global_DatePart, 0, 2, 4},
{DISPID_GLOBAL_TYPENAME, Global_TypeName, 0, 1},
{DISPID_GLOBAL_ARRAY, Global_Array, 0, 1},
{DISPID_GLOBAL_ARRAY, Global_Array, 0, 0, MAXDWORD},
{DISPID_GLOBAL_ERASE, Global_Erase, 0, 1},
{DISPID_GLOBAL_FILTER, Global_Filter, 0, 2, 4},
{DISPID_GLOBAL_JOIN, Global_Join, 0, 1, 2},
......
......@@ -212,6 +212,21 @@ arr(0) = 2
arr(1) = 3
Call ok(not isNumeric(arr), "isNumeric(arr) is not true?")
Call ok(getVT(Array()) = "VT_ARRAY|VT_VARIANT", "getVT(Array()) = " & getVT(Array()))
x = Array("a1", 2, "a3")
Call ok(getVT(x) = "VT_ARRAY|VT_VARIANT*", "getVT(array) = " & getVT(x))
Call ok(getVT(x(0)) = "VT_BSTR*", "getVT(array(0)) = " & getVT(x(0)))
Call ok(x(0) = "a1", "array(0) = " & x(0))
Call ok(getVT(x(1)) = "VT_I2*", "getVT(array(1)) = " & getVT(x(1)))
Call ok(x(1) = 2, "array(1) = " & x(1))
Call ok(getVT(x(2)) = "VT_BSTR*", "getVT(array(2)) = " & getVT(x(2)))
Call ok(x(2) = "a3", "array(2) = " & x(2))
Dim new_array
new_array = x
x(0) = "new value"
Call ok(new_array(0) = "a1", "new_array(0) = " & new_array(0))
Dim newObject
Set newObject = New ValClass
newObject.myval = 1
......
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