Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/vbscript/interp.c | 1 + dlls/vbscript/utils.c | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 11d95e57758..35a6165a819 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1422,6 +1422,7 @@ static HRESULT interp_newenum(exec_ctx_t *ctx) V_UNKNOWN(r) = (IUnknown*)iter; break; } + case VT_BSTR|VT_ARRAY: case VT_VARIANT|VT_ARRAY: case VT_VARIANT|VT_ARRAY|VT_BYREF: { IEnumVARIANT *iter; diff --git a/dlls/vbscript/utils.c b/dlls/vbscript/utils.c index d30842c52eb..c0b8b749038 100644 --- a/dlls/vbscript/utils.c +++ b/dlls/vbscript/utils.c @@ -106,11 +106,20 @@ static HRESULT WINAPI safearray_iter_IEnumVARIANT_Next(IEnumVARIANT *iface, if(!This->sa->cLocks) ERR("SAFEARRAY not locked\n");
- v = (VARIANT*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements); - V_VT(rgVar) = VT_EMPTY; - hres = VariantCopy(rgVar, v); - if(FAILED(hres)) - return hres; + if (This->sa->fFeatures & FADF_VARIANT) + { + v = (VARIANT*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements); + V_VT(rgVar) = VT_EMPTY; + hres = VariantCopy(rgVar, v); + if(FAILED(hres)) + return hres; + } + else if (This->sa->fFeatures & FADF_BSTR) + { + BSTR bstr = *(BSTR*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements); + V_VT(rgVar) = VT_BSTR; + V_BSTR(rgVar) = SysAllocString(bstr); + }
This->i++; if(pCeltFetched) @@ -165,11 +174,6 @@ HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) safearray_iter *iter; HRESULT hres;
- if(sa && !(sa->fFeatures & FADF_VARIANT)) { - FIXME("enumeration not supported: %x\n", sa->fFeatures); - return E_NOTIMPL; - } - iter = heap_alloc(sizeof(*iter)); if(!iter) return E_OUTOFMEMORY;
On 5/17/21 10:18 AM, Alistair Leslie-Hughes wrote:
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com
dlls/vbscript/interp.c | 1 + dlls/vbscript/utils.c | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-)
Tests, please.
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 11d95e57758..35a6165a819 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -1422,6 +1422,7 @@ static HRESULT interp_newenum(exec_ctx_t *ctx) V_UNKNOWN(r) = (IUnknown*)iter; break; }
- case VT_BSTR|VT_ARRAY: case VT_VARIANT|VT_ARRAY: case VT_VARIANT|VT_ARRAY|VT_BYREF: { IEnumVARIANT *iter;
diff --git a/dlls/vbscript/utils.c b/dlls/vbscript/utils.c index d30842c52eb..c0b8b749038 100644 --- a/dlls/vbscript/utils.c +++ b/dlls/vbscript/utils.c @@ -106,11 +106,20 @@ static HRESULT WINAPI safearray_iter_IEnumVARIANT_Next(IEnumVARIANT *iface, if(!This->sa->cLocks) ERR("SAFEARRAY not locked\n");
- v = (VARIANT*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements);
- V_VT(rgVar) = VT_EMPTY;
- hres = VariantCopy(rgVar, v);
- if(FAILED(hres))
return hres;
if (This->sa->fFeatures & FADF_VARIANT)
{
v = (VARIANT*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements);
V_VT(rgVar) = VT_EMPTY;
hres = VariantCopy(rgVar, v);
if(FAILED(hres))
return hres;
}
else if (This->sa->fFeatures & FADF_BSTR)
{
BSTR bstr = *(BSTR*)(((BYTE*)This->sa->pvData) + This->i * This->sa->cbElements);
V_VT(rgVar) = VT_BSTR;
V_BSTR(rgVar) = SysAllocString(bstr);
}
This->i++; if(pCeltFetched)
@@ -165,11 +174,6 @@ HRESULT create_safearray_iter(SAFEARRAY *sa, IEnumVARIANT **ev) safearray_iter *iter; HRESULT hres;
- if(sa && !(sa->fFeatures & FADF_VARIANT)) {
FIXME("enumeration not supported: %x\n", sa->fFeatures);
return E_NOTIMPL;
- }
iter = heap_alloc(sizeof(*iter)); if(!iter) return E_OUTOFMEMORY;
You allow any fFeatures now, but Next() handles only cases where FADF_VARIANT or FADF_BSTR is present.
Thanks,
Jacek