diff --git a/cocos/base/ccConfig.h b/cocos/base/ccConfig.h index 56ad72fb48..3a64b433bd 100644 --- a/cocos/base/ccConfig.h +++ b/cocos/base/ccConfig.h @@ -329,6 +329,16 @@ THE SOFTWARE. #define CC_ENABLE_SCRIPT_BINDING 1 #endif +/** @def CC_NATIVE_CONTROL_SCRIPT + * Indicate whether use script GC to control native object life cycle to get ride of retain/release usage + * False by default. + */ +#if CC_ENABLE_SCRIPT_BINDING + #ifndef CC_ENABLE_GC_FOR_NATIVE_OBJECTS + #define CC_ENABLE_GC_FOR_NATIVE_OBJECTS 1 + #endif +#endif + /** @def CC_CONSTRUCTOR_ACCESS * Indicate the init functions access modifier. If value equals to protected, then these functions are protected. * If value equals to public, these functions are public, diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 0a1066bc38..dcb48247ac 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -76,10 +76,6 @@ #define BYTE_CODE_FILE_EXT ".jsc" -// EXPERIMENTAL: Enable this in order to get rid of retain/release -// when using the Garbage Collector -#define CC_ENABLE_GC_FOR_NATIVE_OBJECTS 0 - using namespace cocos2d; #if COCOS2D_DEBUG diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp index 158594130b..3bc5386147 100644 --- a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp @@ -343,11 +343,12 @@ JS_BINDED_CONSTRUCTOR_IMPL(MinXmlHttpRequest) js_proxy_t *p = jsb_new_proxy(req, obj); #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS + CC_UNUSED_PARAM(p); js_add_FinalizeHook(cx, obj); // don't retain it, already retained #if COCOS2D_DEBUG ScriptingCore::retainCount++; - CCLOG("++++++RETAINED++++++ %d Cpp(XMLHttpRequest): %p - JS: %p", ScriptingCore::retainCount, ref, obj.get()); + CCLOG("++++++RETAINED++++++ %d Cpp(XMLHttpRequest): %p - JS: %p", ScriptingCore::retainCount, req, obj.get()); #endif // COCOS2D_DEBUG #else // autorelease it