From 7af3f651888944a9d9df4636e273814bbb066ea1 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Thu, 22 Sep 2016 10:00:36 +0200 Subject: [PATCH] jscript: Add more jsdisp_t to Instance helpers. Signed-off-by: Michael Stefaniuc Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- 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 7cd0c21f640..75c98c2403d 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 f374fb096c9..23122282e72 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);