diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp index 2fc54b6583..fa8c6ff9e9 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp @@ -265,6 +265,9 @@ bool js_cocos2dx_Node_onExitTransitionDidStart(JSContext *cx, uint32_t argc, jsv bool js_cocos2dx_Component_onEnter(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Component_onExit(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_retain(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_release(JSContext *cx, uint32_t argc, jsval *vp); + void get_or_create_js_obj(JSContext* cx, JS::HandleObject obj, const std::string &name, JS::MutableHandleObject jsObj); #endif diff --git a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp index 597701d0ba..4f72251f72 100644 --- a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp @@ -879,35 +879,6 @@ bool js_cocos2dx_ext_AssetsManager_getFailedAssets(JSContext *cx, uint32_t argc, } */ -bool js_cocos2dx_ext_retain(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *thisObj = JS_THIS_OBJECT(cx, vp); - if (thisObj) { - js_proxy_t *proxy = jsb_get_js_proxy(thisObj); - if (proxy) { - ((Ref *)proxy->ptr)->retain(); - return true; - } - } - JS_ReportError(cx, "Invalid Native Object."); - return false; -} - -bool js_cocos2dx_ext_release(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *thisObj = JS_THIS_OBJECT(cx, vp); - if (thisObj) { - js_proxy_t *proxy = jsb_get_js_proxy(thisObj); - if (proxy) { - ((Ref *)proxy->ptr)->release(); - return true; - } - } - JS_ReportError(cx, "Invalid Native Object."); - return false; -} - - __JSDownloaderDelegator::__JSDownloaderDelegator(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleObject callback) : _cx(cx) , _url(url) @@ -1077,11 +1048,11 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject glob get_or_create_js_obj(cx, global, "cc", &ccObj); JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype); - JS_DefineFunction(cx, am, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, am, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, am, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, am, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS::RootedObject manifest(cx, jsb_cocos2d_extension_Manifest_prototype); - JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, manifest, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, manifest, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); diff --git a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp index 8d215e1f2d..402a318874 100644 --- a/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp +++ b/cocos/scripting/js-bindings/manual/network/XMLHTTPRequest.cpp @@ -29,6 +29,7 @@ #include "XMLHTTPRequest.h" #include #include +#include "cocos2d_specifics.hpp" using namespace std; @@ -986,6 +987,8 @@ void MinXmlHttpRequest::_js_register(JSContext *cx, JS::HandleObject global) JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getAllResponseHeaders), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType), + JS_FN("retain", js_cocos2dx_retain, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("release", js_cocos2dx_release, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h b/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h index 866557a0ed..1eb7d05e35 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h +++ b/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h @@ -28,7 +28,9 @@ #include "navmesh/jsb_cocos2dx_navmesh_manual.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "experimental/jsb_cocos2dx_experimental_video_auto.hpp" #include "experimental/jsb_cocos2dx_experimental_video_manual.h" +#include "experimental/jsb_cocos2dx_experimental_webView_auto.hpp" #include "experimental/jsb_cocos2dx_experimental_webView_manual.h" #endif @@ -97,7 +99,9 @@ int js_module_register() #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + sc->addRegisterCallback(register_all_cocos2dx_experimental_video); sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual); + sc->addRegisterCallback(register_all_cocos2dx_experimental_webView); sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual); #endif