Michael Stefaniuc : jscript: Add more jsdisp_t to Instance helpers.

Alexandre Julliard julliard at winehq.org
Fri Sep 23 10:25:16 CDT 2016


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Thu Sep 22 10:00:36 2016 +0200

jscript: Add more jsdisp_t to Instance helpers.

Signed-off-by: Michael Stefaniuc <mstefani at redhat.de>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/bool.c    | 14 ++++++++++++--
 dlls/jscript/vbarray.c |  9 +++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dlls/jscript/bool.c b/dlls/jscript/bool.c
index 7cd0c21..75c98c2 100644
--- a/dlls/jscript/bool.c
+++ b/dlls/jscript/bool.c
@@ -34,15 +34,25 @@ typedef struct {
 static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0};
 static const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',0};
 
+static inline BoolInstance *bool_from_jsdisp(jsdisp_t *jsdisp)
+{
+    return CONTAINING_RECORD(jsdisp, BoolInstance, dispex);
+}
+
+static inline BoolInstance *bool_from_vdisp(vdisp_t *vdisp)
+{
+    return bool_from_jsdisp(vdisp->u.jsdisp);
+}
+
 static inline BoolInstance *bool_this(vdisp_t *jsthis)
 {
-    return is_vclass(jsthis, JSCLASS_BOOLEAN) ? (BoolInstance*)jsthis->u.jsdisp : NULL;
+    return is_vclass(jsthis, JSCLASS_BOOLEAN) ? bool_from_vdisp(jsthis) : NULL;
 }
 
 BOOL bool_obj_value(jsdisp_t *obj)
 {
     assert(is_class(obj, JSCLASS_BOOLEAN));
-    return ((BoolInstance*)obj)->val;
+    return bool_from_jsdisp(obj)->val;
 }
 
 /* ECMA-262 3rd Edition    15.6.4.2 */
diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c
index f374fb0..2312228 100644
--- a/dlls/jscript/vbarray.c
+++ b/dlls/jscript/vbarray.c
@@ -34,9 +34,14 @@ static const WCHAR lboundW[] = {'l','b','o','u','n','d',0};
 static const WCHAR toArrayW[] = {'t','o','A','r','r','a','y',0};
 static const WCHAR uboundW[] = {'u','b','o','u','n','d',0};
 
+static inline VBArrayInstance *vbarray_from_jsdisp(jsdisp_t *jsdisp)
+{
+    return CONTAINING_RECORD(jsdisp, VBArrayInstance, dispex);
+}
+
 static inline VBArrayInstance *vbarray_from_vdisp(vdisp_t *vdisp)
 {
-    return CONTAINING_RECORD(vdisp->u.jsdisp, VBArrayInstance, dispex);
+    return vbarray_from_jsdisp(vdisp->u.jsdisp);
 }
 
 static inline VBArrayInstance *vbarray_this(vdisp_t *jsthis)
@@ -236,7 +241,7 @@ static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
 
 static void VBArray_destructor(jsdisp_t *dispex)
 {
-    VBArrayInstance *vbarray = (VBArrayInstance*)dispex;
+    VBArrayInstance *vbarray = vbarray_from_jsdisp(dispex);
 
     SafeArrayDestroy(vbarray->safearray);
     heap_free(vbarray);




More information about the wine-cvs mailing list