From 10d5b73c7e49940faa0c47f1fd25e482bc0a090d Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Thu, 20 Aug 2015 17:42:26 +0800 Subject: [PATCH] fix opengl test error fix opengl test error, add the condition, when the data type is samewith long, it will reset data relate pr:#13449 fix open gl show error --- .../manual/js_manual_conversions.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index e3c026cc2d..20a2bf7e9f 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -187,8 +187,12 @@ bool jsval_to_int( JSContext *cx, JS::HandleValue vp, int *ret ) // Since this is called to cast uint64 to uint32, // it is needed to initialize the value to 0 first #ifdef __LP64__ - long *tmp = (long*)ret; - *tmp = 0; + // When int size is 8 Bit (same as long), the following operation is needed + if (sizeof(int) == 8) + { + long *tmp = (long*)ret; + *tmp = 0; + } #endif return jsval_to_int32(cx, vp, (int32_t*)ret); } @@ -243,8 +247,12 @@ bool jsval_to_uint( JSContext *cx, JS::HandleValue vp, unsigned int *ret ) // Since this is called to cast uint64 to uint32, // it is needed to initialize the value to 0 first #ifdef __LP64__ - long *tmp = (long*)ret; - *tmp = 0; + // When unsigned int size is 8 Bit (same as long), the following operation is needed + if (sizeof(unsigned int)==8) + { + long *tmp = (long*)ret; + *tmp = 0; + } #endif return jsval_to_int32(cx, vp, (int32_t*)ret); } @@ -2841,4 +2849,4 @@ jsval std_map_string_string_to_jsval(JSContext* cx, const std::map