Jacek Caban : jscript: Added support for VT_I2 in invoke_prop_func.

Alexandre Julliard julliard at winehq.org
Tue May 1 13:12:14 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May  1 15:05:07 2012 +0200

jscript: Added support for VT_I2 in invoke_prop_func.

---

 dlls/jscript/dispex.c  |   53 +++++++++++++++++++++++++++++++++++++++++++++++-
 dlls/jscript/jscript.h |    2 +-
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index 4f6ed7e..96c17c8 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -333,6 +333,49 @@ static HRESULT set_this(DISPPARAMS *dp, DISPPARAMS *olddp, IDispatch *jsthis)
     return S_OK;
 }
 
+static HRESULT convert_params(const DISPPARAMS *dp, VARIANT *buf, DISPPARAMS *ret)
+{
+    BOOL need_conversion = FALSE;
+    const VARIANT *s;
+    VARIANT *d;
+    unsigned i;
+
+    *ret = *dp;
+
+    for(i = 0; i < ret->cArgs; i++) {
+        if(V_VT(get_arg(dp, i)) == VT_I2) {
+            need_conversion = TRUE;
+            break;
+        }
+    }
+
+    if(!need_conversion)
+        return S_OK;
+
+    if(ret->cArgs > 6) {
+        ret->rgvarg = heap_alloc(ret->cArgs * sizeof(VARIANT));
+        if(!ret->rgvarg)
+            return E_OUTOFMEMORY;
+    }else {
+        ret->rgvarg = buf;
+    }
+
+    for(i = 0; i < ret->cArgs; i++) {
+        s = get_arg(dp, i);
+        d = get_arg(ret, i);
+        switch(V_VT(s)) {
+        case VT_I2:
+            V_VT(d) = VT_I4;
+            V_I4(d) = V_I2(s);
+            break;
+        default:
+            *d = *s;
+        }
+    }
+
+    return S_OK;
+}
+
 static HRESULT invoke_prop_func(jsdisp_t *This, jsdisp_t *jsthis, dispex_prop_t *prop, WORD flags,
         DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
 {
@@ -340,6 +383,8 @@ static HRESULT invoke_prop_func(jsdisp_t *This, jsdisp_t *jsthis, dispex_prop_t
 
     switch(prop->type) {
     case PROP_BUILTIN: {
+        DISPPARAMS params;
+        VARIANT buf[6];
         vdisp_t vthis;
 
         if(flags == DISPATCH_CONSTRUCT && (prop->flags & PROPF_METHOD)) {
@@ -347,9 +392,15 @@ static HRESULT invoke_prop_func(jsdisp_t *This, jsdisp_t *jsthis, dispex_prop_t
             return E_INVALIDARG;
         }
 
+        hres = convert_params(dp, buf, &params);
+        if(FAILED(hres))
+            return hres;
+
         set_jsdisp(&vthis, jsthis);
-        hres = prop->u.p->invoke(This->ctx, &vthis, flags, dp, retv, ei);
+        hres = prop->u.p->invoke(This->ctx, &vthis, flags, &params, retv, ei);
         vdisp_release(&vthis);
+        if(params.rgvarg != buf && params.rgvarg != dp->rgvarg)
+            heap_free(params.rgvarg);
         return hres;
     }
     case PROP_PROTREF:
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 65a80e9..ad39b45 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -375,7 +375,7 @@ HRESULT regexp_match(script_ctx_t*,jsdisp_t*,const WCHAR*,DWORD,BOOL,match_resul
 HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*) DECLSPEC_HIDDEN;
 HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,BSTR,VARIANT*,jsexcept_t*) DECLSPEC_HIDDEN;
 
-static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i)
+static inline VARIANT *get_arg(const DISPPARAMS *dp, DWORD i)
 {
     return dp->rgvarg + dp->cArgs-i-1;
 }




More information about the wine-cvs mailing list