vbscript: Added interp_assign_member implementation.
authorJacek Caban <jacek@codeweavers.com>
Tue, 13 Sep 2011 09:35:50 +0000 (11:35 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 13 Sep 2011 15:16:59 +0000 (17:16 +0200)
dlls/vbscript/interp.c
dlls/vbscript/vbscript.h
dlls/vbscript/vbscript_main.c

index 321293556246901b6b4e7d2062f3153544500ca2..45a7504a0a3a36498a66ae0e9ebea67e9adc7230 100644 (file)
@@ -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)
index 6367c125536b74c99baae43e60d55df039a6827b..226f0d2bbddd6710b626190267ece4724b67dca2 100644 (file)
@@ -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);
index 152728107735ebc8012f82bea59f7718b9326d37..43ab484735d1b7e0c7405bd38efe1e615ae30032 100644 (file)
@@ -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)