Jacek Caban : vbscript: Added interp_dim implementation.

Alexandre Julliard julliard at winehq.org
Wed Nov 13 13:34:41 CST 2013


Module: wine
Branch: master
Commit: 853c6c4eea3094944fad4232302de9c2cf7a688b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=853c6c4eea3094944fad4232302de9c2cf7a688b

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Nov 13 16:29:29 2013 +0100

vbscript: Added interp_dim implementation.

---

 dlls/vbscript/interp.c |   47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 7d2cd65..07125d0 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -35,6 +35,7 @@ typedef struct {
 
     VARIANT *args;
     VARIANT *vars;
+    SAFEARRAY **arrays;
 
     dynamic_var_t *dynamic_vars;
     heap_pool_t heap;
@@ -891,9 +892,43 @@ static HRESULT interp_dim(exec_ctx_t *ctx)
 {
     const BSTR ident = ctx->instr->arg1.bstr;
     const unsigned array_id = ctx->instr->arg2.uint;
+    ref_t ref;
+    HRESULT hres;
+
+    TRACE("%s\n", debugstr_w(ident));
+
+    assert(array_id < ctx->func->array_cnt);
+    if(!ctx->arrays) {
+        ctx->arrays = heap_alloc_zero(ctx->func->array_cnt * sizeof(SAFEARRAY*));
+        if(!ctx->arrays)
+            return E_OUTOFMEMORY;
+    }
+
+    hres = lookup_identifier(ctx, ident, VBDISP_LET, &ref);
+    if(FAILED(hres)) {
+        FIXME("lookup %s failed: %08x\n", debugstr_w(ident), hres);
+        return hres;
+    }
 
-    FIXME("%s(%d)\n", debugstr_w(ident), array_id);
-    return E_NOTIMPL;
+    if(ref.type != REF_VAR) {
+        FIXME("got ref.type = %d\n", ref.type);
+        return E_FAIL;
+    }
+
+    if(!ctx->arrays[array_id]) {
+        const array_desc_t *array_desc;
+
+        array_desc = ctx->func->array_descs + array_id;
+        if(array_desc->dim_cnt) {
+            ctx->arrays[array_id] = SafeArrayCreate(VT_VARIANT, array_desc->dim_cnt, array_desc->bounds);
+            if(!ctx->arrays[array_id])
+                return E_OUTOFMEMORY;
+        }
+    }
+
+    V_VT(ref.u.v) = VT_ARRAY|VT_BYREF|VT_VARIANT;
+    V_ARRAYREF(ref.u.v) = ctx->arrays+array_id;
+    return S_OK;
 }
 
 static HRESULT interp_step(exec_ctx_t *ctx)
@@ -1842,6 +1877,14 @@ static void release_exec(exec_ctx_t *ctx)
             VariantClear(ctx->vars+i);
     }
 
+    if(ctx->arrays) {
+        for(i=0; i < ctx->func->var_cnt; i++) {
+            if(ctx->arrays[i])
+                SafeArrayDestroy(ctx->arrays[i]);
+        }
+        heap_free(ctx->arrays);
+    }
+
     heap_pool_free(&ctx->heap);
     heap_free(ctx->args);
     heap_free(ctx->vars);




More information about the wine-cvs mailing list