Jacek Caban : vbscript: Added interp_assign_member implementation.

Alexandre Julliard julliard at winehq.org
Tue Sep 13 12:18:09 CDT 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep 13 11:35:50 2011 +0200

vbscript: Added interp_assign_member implementation.

---

 dlls/vbscript/interp.c        |   59 +++++++++++++++++++++++++++++++++++++++-
 dlls/vbscript/vbscript.h      |    2 +
 dlls/vbscript/vbscript_main.c |   32 ++++++++++++++++++++++
 3 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 3212935..45a7504 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -144,6 +144,33 @@ static inline void release_val(variant_val_t *v)
         VariantClear(v->v);
 }
 
+static HRESULT stack_pop_disp(exec_ctx_t *ctx, IDispatch **ret)
+{
+    VARIANT *v = stack_pop(ctx);
+
+    if(V_VT(v) == VT_DISPATCH) {
+        *ret = V_DISPATCH(v);
+        return S_OK;
+    }
+
+    if(V_VT(v) != (VT_VARIANT|VT_BYREF)) {
+        FIXME("not supported type: %s\n", debugstr_variant(v));
+        VariantClear(v);
+        return E_FAIL;
+    }
+
+    v = V_BYREF(v);
+    if(V_VT(v) != VT_DISPATCH) {
+        FIXME("not disp %s\n", debugstr_variant(v));
+        return E_FAIL;
+    }
+
+    if(V_DISPATCH(v))
+        IDispatch_AddRef(V_DISPATCH(v));
+    *ret = V_DISPATCH(v);
+    return S_OK;
+}
+
 static void vbstack_to_dp(exec_ctx_t *ctx, unsigned arg_cnt, DISPPARAMS *dp)
 {
     dp->cArgs = arg_cnt;
@@ -259,8 +286,36 @@ static HRESULT interp_assign_ident(exec_ctx_t *ctx)
 
 static HRESULT interp_assign_member(exec_ctx_t *ctx)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    BSTR identifier = ctx->instr->arg1.bstr;
+    variant_val_t val;
+    IDispatch *obj;
+    DISPID id;
+    HRESULT hres;
+
+    TRACE("%s\n", debugstr_w(identifier));
+
+    hres = stack_pop_disp(ctx, &obj);
+    if(FAILED(hres))
+        return hres;
+
+    if(!obj) {
+        FIXME("NULL obj\n");
+        return E_FAIL;
+    }
+
+    hres = stack_pop_val(ctx, &val);
+    if(FAILED(hres)) {
+        IDispatch_Release(obj);
+        return hres;
+    }
+
+    hres = disp_get_id(obj, identifier, &id);
+    if(SUCCEEDED(hres))
+        hres = disp_propput(ctx->script, obj, id, val.v);
+
+    release_val(&val);
+    IDispatch_Release(obj);
+    return hres;
 }
 
 static HRESULT interp_ret(exec_ctx_t *ctx)
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index 6367c12..226f0d2 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -158,6 +158,8 @@ HRESULT exec_script(script_ctx_t*,function_t*) DECLSPEC_HIDDEN;
 
 HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**);
 
+const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
+
 static inline void *heap_alloc(size_t len)
 {
     return HeapAlloc(GetProcessHeap(), 0, len);
diff --git a/dlls/vbscript/vbscript_main.c b/dlls/vbscript/vbscript_main.c
index 1527281..43ab484 100644
--- a/dlls/vbscript/vbscript_main.c
+++ b/dlls/vbscript/vbscript_main.c
@@ -31,6 +31,38 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
 
 static HINSTANCE vbscript_hinstance;
 
+const char *debugstr_variant(const VARIANT *v)
+{
+    if(!v)
+        return "(null)";
+
+    if(V_ISBYREF(v))
+        return wine_dbg_sprintf("{V_BYREF -> %s}", debugstr_variant(V_BYREF(v)));
+
+    switch(V_VT(v)) {
+    case VT_EMPTY:
+        return "{VT_EMPTY}";
+    case VT_NULL:
+        return "{VT_NULL}";
+    case VT_I2:
+        return wine_dbg_sprintf("{VT_I2: %d}", V_I2(v));
+    case VT_I4:
+        return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
+    case VT_UI4:
+        return wine_dbg_sprintf("{VT_UI4: %u}", V_UI4(v));
+    case VT_R8:
+        return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
+    case VT_BSTR:
+        return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
+    case VT_DISPATCH:
+        return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
+    case VT_BOOL:
+        return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
+    default:
+        return wine_dbg_sprintf("{vt %d}", V_VT(v));
+    }
+}
+
 #define MIN_BLOCK_SIZE  128
 
 static inline DWORD block_size(DWORD block)




More information about the wine-cvs mailing list