[VBSCRIPT] Sync with Wine 3.0. CORE-14225

This commit is contained in:
Amine Khaldi 2018-01-20 13:39:40 +01:00
parent eb91a73902
commit e0b80a0929
11 changed files with 978 additions and 699 deletions

View file

@ -475,10 +475,8 @@ static void vbstack_to_dp(exec_ctx_t *ctx, unsigned arg_cnt, BOOL is_propput, DI
static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, VARIANT **ret)
{
unsigned cell_off = 0, dim_size = 1, i;
unsigned argc = arg_cnt(dp);
VARIANT *data;
LONG idx;
unsigned i, argc = arg_cnt(dp);
LONG *indices;
HRESULT hres;
if(!array) {
@ -486,34 +484,35 @@ static HRESULT array_access(exec_ctx_t *ctx, SAFEARRAY *array, DISPPARAMS *dp, V
return E_FAIL;
}
if(array->cDims != argc) {
FIXME("argc %d does not match cDims %d\n", dp->cArgs, array->cDims);
return E_FAIL;
}
for(i=0; i < argc; i++) {
hres = to_int(get_arg(dp, i), &idx);
if(FAILED(hres))
return hres;
idx -= array->rgsabound[i].lLbound;
if(idx >= array->rgsabound[i].cElements) {
FIXME("out of bound element %d in dim %d of size %d\n", idx, i+1, array->rgsabound[i].cElements);
return E_FAIL;
}
cell_off += idx*dim_size;
dim_size *= array->rgsabound[i].cElements;
}
hres = SafeArrayAccessData(array, (void**)&data);
hres = SafeArrayLock(array);
if(FAILED(hres))
return hres;
*ret = data+cell_off;
if(array->cDims != argc) {
FIXME("argc %d does not match cDims %d\n", dp->cArgs, array->cDims);
SafeArrayUnlock(array);
return E_FAIL;
}
SafeArrayUnaccessData(array);
return S_OK;
indices = heap_alloc(sizeof(*indices) * argc);
if(!indices) {
SafeArrayUnlock(array);
return E_OUTOFMEMORY;
}
for(i=0; i<argc; i++) {
hres = to_int(get_arg(dp, i), indices+i);
if(FAILED(hres)) {
heap_free(indices);
SafeArrayUnlock(array);
return hres;
}
}
hres = SafeArrayPtrOfIndex(array, indices, (void**)ret);
SafeArrayUnlock(array);
heap_free(indices);
return hres;
}
static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res)
@ -1143,6 +1142,18 @@ static HRESULT interp_newenum(exec_ctx_t *ctx)
V_UNKNOWN(r) = (IUnknown*)iter;
break;
}
case VT_VARIANT|VT_ARRAY:
case VT_VARIANT|VT_ARRAY|VT_BYREF: {
IEnumVARIANT *iter;
hres = create_safearray_iter(V_ISBYREF(v.v) ? *V_ARRAYREF(v.v) : V_ARRAY(v.v), &iter);
if(FAILED(hres))
return hres;
V_VT(r) = VT_UNKNOWN;
V_UNKNOWN(r) = (IUnknown*)iter;
break;
}
default:
FIXME("Unsupported for %s\n", debugstr_variant(v.v));
release_val(&v);
@ -1186,7 +1197,7 @@ static HRESULT interp_enumnext(exec_ctx_t *ctx)
if(do_continue) {
ctx->instr++;
}else {
stack_pop(ctx);
stack_popn(ctx, 1);
instr_jmp(ctx, loop_end);
}
return S_OK;