Jacek Caban : jscript: Addd jsdisp_addref helper function.

Alexandre Julliard julliard at winehq.org
Tue Sep 7 11:22:57 CDT 2010


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep  7 15:42:34 2010 +0200

jscript: Addd jsdisp_addref helper function.

---

 dlls/jscript/array.c    |    6 +++---
 dlls/jscript/dispex.c   |    4 ++--
 dlls/jscript/engine.c   |    4 ++--
 dlls/jscript/function.c |    2 +-
 dlls/jscript/global.c   |    2 +-
 dlls/jscript/jscript.h  |    5 +++++
 6 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c
index f267b38..99127d4 100644
--- a/dlls/jscript/array.c
+++ b/dlls/jscript/array.c
@@ -506,8 +506,8 @@ static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP
     }
 
     if(retv) {
+        jsdisp_addref(jsthis);
         var_set_jsdisp(retv, jsthis);
-        IDispatch_AddRef(V_DISPATCH(retv));
     }
 
     return S_OK;
@@ -745,8 +745,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR
         if(cmp_func)
             jsdisp_release(cmp_func);
         if(retv) {
+            jsdisp_addref(jsthis);
             var_set_jsdisp(retv, jsthis);
-	    IDispatch_AddRef(V_DISPATCH(retv));
         }
         return S_OK;
     }
@@ -850,8 +850,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR
         return hres;
 
     if(retv) {
+        jsdisp_addref(jsthis);
         var_set_jsdisp(retv, jsthis);
-        IDispatch_AddRef(V_DISPATCH(retv));
     }
 
     return S_OK;
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index be8967a..368cb6e 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -437,7 +437,7 @@ static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid,
         *ppv = _IDispatchEx_(This);
     }else if(IsEqualGUID(&IID_IDispatchJS, riid)) {
         TRACE("(%p)->(IID_IDispatchJS %p)\n", This, ppv);
-        IUnknown_AddRef(_IDispatchEx_(This));
+        jsdisp_addref(This);
         *ppv = This;
         return S_OK;
     }else {
@@ -755,7 +755,7 @@ HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *b
 
     dispex->prototype = prototype;
     if(prototype)
-        IDispatchEx_AddRef(_IDispatchEx_(prototype));
+        jsdisp_addref(prototype);
 
     dispex->prop_cnt = 1;
     dispex->props[0].name = NULL;
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index 4bd4bfd..8aed4db 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -143,7 +143,7 @@ HRESULT scope_push(scope_chain_t *scope, jsdisp_t *obj, scope_chain_t **ret)
 
     new_scope->ref = 1;
 
-    IDispatchEx_AddRef(_IDispatchEx_(obj));
+    jsdisp_addref(obj);
     new_scope->obj = obj;
 
     if(scope) {
@@ -197,7 +197,7 @@ HRESULT create_exec_ctx(script_ctx_t *script_ctx, IDispatch *this_obj, jsdisp_t
         ctx->this_obj = to_disp(script_ctx->global);
     IDispatch_AddRef(ctx->this_obj);
 
-    IDispatchEx_AddRef(_IDispatchEx_(var_disp));
+    jsdisp_addref(var_disp);
     ctx->var_disp = var_disp;
 
     if(scope) {
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 56cd2b2..2bcc918 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -547,7 +547,7 @@ static HRESULT Function_arguments(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
     switch(flags) {
     case DISPATCH_PROPERTYGET: {
         if(function->arguments) {
-            IDispatchEx_AddRef(_IDispatchEx_(function->arguments));
+            jsdisp_addref(function->arguments);
             var_set_jsdisp(retv, function->arguments);
         }else {
             V_VT(retv) = VT_NULL;
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index eef57c4..21d9201 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -112,8 +112,8 @@ static HRESULT constructor_call(jsdisp_t *constr, WORD flags, DISPPARAMS *dp,
     if(flags != DISPATCH_PROPERTYGET)
         return jsdisp_call_value(constr, flags, dp, retv, ei, sp);
 
+    jsdisp_addref(constr);
     var_set_jsdisp(retv, constr);
-    IDispatchEx_AddRef(_IDispatchEx_(constr));
     return S_OK;
 }
 
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 5ed7e8f..e9318e5 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -192,6 +192,11 @@ static inline IDispatch *to_disp(jsdisp_t *jsdisp)
     return (IDispatch*)&jsdisp->lpIDispatchExVtbl;
 }
 
+static inline void jsdisp_addref(jsdisp_t *jsdisp)
+{
+    IDispatchEx_AddRef(_IDispatchEx_(jsdisp));
+}
+
 static inline void jsdisp_release(jsdisp_t *jsdisp)
 {
     IDispatchEx_Release(_IDispatchEx_(jsdisp));




More information about the wine-cvs mailing list