mirror of https://github.com/axmolengine/axmol.git
Merge pull request #12661 from pandamicro/v3.7-release
Fixed #12652 Add retain/release for XMLHTTPReqest in JSB
This commit is contained in:
commit
aeeb6eb683
|
@ -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_onEnter(JSContext *cx, uint32_t argc, jsval *vp);
|
||||||
bool js_cocos2dx_Component_onExit(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);
|
void get_or_create_js_obj(JSContext* cx, JS::HandleObject obj, const std::string &name, JS::MutableHandleObject jsObj);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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)
|
__JSDownloaderDelegator::__JSDownloaderDelegator(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleObject callback)
|
||||||
: _cx(cx)
|
: _cx(cx)
|
||||||
, _url(url)
|
, _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);
|
get_or_create_js_obj(cx, global, "cc", &ccObj);
|
||||||
|
|
||||||
JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype);
|
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, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, am, "release", js_cocos2dx_ext_release, 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::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, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
JS_DefineFunction(cx, manifest, "release", js_cocos2dx_ext_release, 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, "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);
|
//JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "XMLHTTPRequest.h"
|
#include "XMLHTTPRequest.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "cocos2d_specifics.hpp"
|
||||||
|
|
||||||
using namespace std;
|
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, getAllResponseHeaders),
|
||||||
JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader),
|
JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader),
|
||||||
JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType),
|
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
|
JS_FS_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,9 @@
|
||||||
#include "navmesh/jsb_cocos2dx_navmesh_manual.h"
|
#include "navmesh/jsb_cocos2dx_navmesh_manual.h"
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#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_video_manual.h"
|
||||||
|
#include "experimental/jsb_cocos2dx_experimental_webView_auto.hpp"
|
||||||
#include "experimental/jsb_cocos2dx_experimental_webView_manual.h"
|
#include "experimental/jsb_cocos2dx_experimental_webView_manual.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -97,7 +99,9 @@ int js_module_register()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#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_video_manual);
|
||||||
|
sc->addRegisterCallback(register_all_cocos2dx_experimental_webView);
|
||||||
sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual);
|
sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue