From bc915ddc441ffb757ab7f4dcbf0c29e6e6300c59 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 16 Jan 2017 13:57:10 +0800 Subject: [PATCH] Add Downloader bindings --- native/cocos/network/CCDownloader.h | 12 ++++ .../js-bindings/manual/ScriptingCore.cpp | 15 ++++- .../js-bindings/manual/ScriptingCore.h | 5 ++ .../js-bindings/manual/js_module_register.cpp | 3 + .../manual/network/js_network_manual.cpp | 64 +++++++++++++++++++ .../manual/network/js_network_manual.h | 36 +++++++++++ .../js-bindings/proj.android/Android.mk | 2 + .../project.pbxproj | 24 +++++++ native/tools/bindings-generator | 2 +- native/tools/tojs/cocos2dx_network.ini | 60 +++++++++++++++++ 10 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 native/cocos/scripting/js-bindings/manual/network/js_network_manual.cpp create mode 100644 native/cocos/scripting/js-bindings/manual/network/js_network_manual.h create mode 100644 native/tools/tojs/cocos2dx_network.ini diff --git a/native/cocos/network/CCDownloader.h b/native/cocos/network/CCDownloader.h index 41730421b8..60c5508db1 100644 --- a/native/cocos/network/CCDownloader.h +++ b/native/cocos/network/CCDownloader.h @@ -86,6 +86,18 @@ namespace cocos2d { namespace network { int errorCode, int errorCodeInternal, const std::string& errorStr)> onTaskError; + + void setOnFileTaskSuccess(const std::function& callback) {onFileTaskSuccess = callback;}; + + void setOnTaskProgress(const std::function& callback) {onTaskProgress = callback;}; + + void setOnTaskError(const std::function& callback) {onTaskError = callback;}; std::shared_ptr createDownloadDataTask(const std::string& srcUrl, const std::string& identifier = ""); diff --git a/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 80a8480826..6c70d1d186 100644 --- a/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/native/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -2306,8 +2306,8 @@ JSObject* jsb_create_weak_jsobject(JSContext *cx, void *native, js_type_class_t #if ! CC_ENABLE_GC_FOR_NATIVE_OBJECTS JS::AddNamedObjectRoot(cx, &proxy->obj, debug); #else -#if COCOS2D_DEBUG > 1 CC_UNUSED_PARAM(proxy); +#if COCOS2D_DEBUG > 1 if (debug != nullptr) { CCLOG("++++++WEAK_REF++++++ Cpp(%s): %p - JS: %p", debug, native, jsObj.get()); @@ -2449,6 +2449,19 @@ void jsb_ref_rebind(JSContext* cx, JS::HandleObject jsobj, js_proxy_t *proxy, co #endif } +void jsb_non_ref_init(JSContext* cx, JS::Heap *obj, void* native, const char* debug) +{ +// CCLOG("jsb_non_ref_init: JSObject address = %p. %s", obj->get(), debug); +#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS + JS::RootedObject jsObj(cx, *obj); + js_add_FinalizeHook(cx, jsObj, false); + // don't retain it, already retained +#if COCOS2D_DEBUG > 1 + CCLOG("++++++RETAINED++++++ Cpp(%s): %p - JS: %p", debug, native, jsObj.get()); +#endif // COCOS2D_DEBUG +#endif +} + // Register finalize hook void jsb_register_finalize_hook(JSObject *hook, JSObject *owner) { diff --git a/native/cocos/scripting/js-bindings/manual/ScriptingCore.h b/native/cocos/scripting/js-bindings/manual/ScriptingCore.h index 2a6b0251d3..646ba1bc8a 100644 --- a/native/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/native/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -633,6 +633,11 @@ void jsb_ref_autoreleased_init(JSContext* cx, JS::Heap *obj, cocos2d: */ void jsb_ref_rebind(JSContext* cx, JS::HandleObject jsobj, js_proxy_t *js2native_proxy, cocos2d::Ref* oldRef, cocos2d::Ref* newRef, const char* debug); +/** + * Generic initialization function for non Ref classes + */ +void jsb_non_ref_init(JSContext* cx, JS::Heap *obj, void* native, const char* debug); + /** * Creates a new JSObject of a certain type (typeClass) and creates a proxy associated with and the Ref */ diff --git a/native/cocos/scripting/js-bindings/manual/js_module_register.cpp b/native/cocos/scripting/js-bindings/manual/js_module_register.cpp index f2a3bedf30..2ce4e3b1d0 100755 --- a/native/cocos/scripting/js-bindings/manual/js_module_register.cpp +++ b/native/cocos/scripting/js-bindings/manual/js_module_register.cpp @@ -6,6 +6,7 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.hpp" #include "scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.hpp" #include "scripting/js-bindings/auto/jsb_cocos2dx_dragonbones_auto.hpp" +#include "scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp" #include "jsb_creator_auto.hpp" #include "scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp" #include "scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.h" @@ -84,6 +85,8 @@ int js_module_register() sc->addRegisterCallback(register_jsb_websocket); // socket io can be commented out to reduce the package sc->addRegisterCallback(register_jsb_socketio); + // Downloader + sc->addRegisterCallback(register_all_cocos2dx_network); #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION // Physics 3d can be commented out to reduce the package diff --git a/native/cocos/scripting/js-bindings/manual/network/js_network_manual.cpp b/native/cocos/scripting/js-bindings/manual/network/js_network_manual.cpp new file mode 100644 index 0000000000..66a8af934f --- /dev/null +++ b/native/cocos/scripting/js-bindings/manual/network/js_network_manual.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2017 Chukong Technologies Inc. + * Created by panda on 1/13/17. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "js_network_manual.h" +#include "js_manual_conversions.h" + +bool jsval_to_DownloaderHints(JSContext *cx, JS::HandleValue v, cocos2d::network::DownloaderHints* ret) { + JS::RootedObject tmp(cx); + JS::RootedValue jsCountOfMaxProcessingTasks(cx); + JS::RootedValue jsTimeoutInSeconds(cx); + JS::RootedValue jsTempFileNameSuffix(cx); + + double countOfMaxProcessingTasks = 0, timeoutInSeconds = 0; + std::string tempFileNameSuffix; + bool ok = v.isObject() && + JS_ValueToObject(cx, v, &tmp) && + JS_GetProperty(cx, tmp, "countOfMaxProcessingTasks", &jsCountOfMaxProcessingTasks) && + JS_GetProperty(cx, tmp, "timeoutInSeconds", &jsTimeoutInSeconds) && + JS_GetProperty(cx, tmp, "tempFileNameSuffix", &jsTempFileNameSuffix) && + JS::ToNumber(cx, jsCountOfMaxProcessingTasks, &countOfMaxProcessingTasks) && + JS::ToNumber(cx, jsTimeoutInSeconds, &timeoutInSeconds) && + jsval_to_std_string(cx, jsTempFileNameSuffix, &tempFileNameSuffix); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->countOfMaxProcessingTasks = (uint32_t)countOfMaxProcessingTasks; + ret->timeoutInSeconds = (uint32_t)timeoutInSeconds; + ret->tempFileNameSuffix = tempFileNameSuffix; + return true; +} + +jsval downloadTask_to_jsval(JSContext *cx, const cocos2d::network::DownloadTask& v) +{ + JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); + if (!tmp) return JSVAL_NULL; + bool ok = JS_DefineProperty(cx, tmp, "identifier", JS::RootedValue(cx, std_string_to_jsval(cx, v.identifier)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "requestURL", JS::RootedValue(cx, std_string_to_jsval(cx, v.requestURL)), JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "storagePath", JS::RootedValue(cx, std_string_to_jsval(cx, v.storagePath)), JSPROP_ENUMERATE | JSPROP_PERMANENT); + if (ok) { + return OBJECT_TO_JSVAL(tmp); + } + return JSVAL_NULL; +} + diff --git a/native/cocos/scripting/js-bindings/manual/network/js_network_manual.h b/native/cocos/scripting/js-bindings/manual/network/js_network_manual.h new file mode 100644 index 0000000000..e61fe4b7d3 --- /dev/null +++ b/native/cocos/scripting/js-bindings/manual/network/js_network_manual.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Chukong Technologies Inc. + * Created by panda on 1/13/17. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef js_network_manual_h +#define js_network_manual_h + +#include "jsapi.h" +#include "jsfriendapi.h" + +#include "network/CCDownloader.h" + +bool jsval_to_DownloaderHints(JSContext *cx, JS::HandleValue v, cocos2d::network::DownloaderHints* ret); + +jsval downloadTask_to_jsval(JSContext *cx, const cocos2d::network::DownloadTask& v); + +#endif /* js_network_manual_hpp */ diff --git a/native/cocos/scripting/js-bindings/proj.android/Android.mk b/native/cocos/scripting/js-bindings/proj.android/Android.mk index 064ef7ea27..44d3aa96b8 100644 --- a/native/cocos/scripting/js-bindings/proj.android/Android.mk +++ b/native/cocos/scripting/js-bindings/proj.android/Android.mk @@ -17,6 +17,7 @@ LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_extension_auto.cpp \ ../auto/jsb_cocos2dx_studio_auto.cpp \ ../auto/jsb_cocos2dx_builder_auto.cpp \ ../auto/jsb_cocos2dx_ui_auto.cpp \ + ../auto/jsb_cocos2dx_network_auto.cpp \ ../auto/jsb_creator_auto.cpp \ ../auto/js_bindings_chipmunk_auto_classes.cpp \ ../auto/js_bindings_chipmunk_functions.cpp \ @@ -44,6 +45,7 @@ LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_extension_auto.cpp \ ../manual/network/jsb_socketio.cpp \ ../manual/network/jsb_websocket.cpp \ ../manual/network/XMLHTTPRequest.cpp \ + ../manual/network/js_network_manual.cpp \ ../manual/spine/jsb_cocos2dx_spine_manual.cpp \ ../manual/dragonbones/jsb_cocos2dx_dragonbones_manual.cpp \ ../manual/ui/jsb_cocos2dx_ui_manual.cpp \ diff --git a/native/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/native/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index 382c7167a1..026e7e36a5 100644 --- a/native/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/native/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -163,6 +163,14 @@ BA4095C31A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */; }; BA4095C41A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */; }; BA4095C51A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */; }; + BA4F59841E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4F59821E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp */; }; + BA4F59851E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4F59821E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp */; }; + BA4F59861E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BA4F59831E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp */; }; + BA4F59871E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BA4F59831E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp */; }; + BA4F598B1E28DE4A003F5096 /* js_network_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4F59891E28DE4A003F5096 /* js_network_manual.cpp */; }; + BA4F598C1E28DE4A003F5096 /* js_network_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4F59891E28DE4A003F5096 /* js_network_manual.cpp */; }; + BA4F598D1E28DE4A003F5096 /* js_network_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4F598A1E28DE4A003F5096 /* js_network_manual.h */; }; + BA4F598E1E28DE4A003F5096 /* js_network_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4F598A1E28DE4A003F5096 /* js_network_manual.h */; }; BA9FD5D21BAC0A7600996C85 /* CCComponentJS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA9FD5D01BAC0A7600996C85 /* CCComponentJS.cpp */; }; BA9FD5D31BAC0A7600996C85 /* CCComponentJS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA9FD5D01BAC0A7600996C85 /* CCComponentJS.cpp */; }; BA9FD5D41BAC0A7600996C85 /* CCComponentJS.h in Headers */ = {isa = PBXBuildFile; fileRef = BA9FD5D11BAC0A7600996C85 /* CCComponentJS.h */; }; @@ -281,6 +289,10 @@ BA127E661D791E21002C5B50 /* js_bindings_chipmunk_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_functions.h; sourceTree = ""; }; BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_conversions.cpp; sourceTree = ""; }; BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_studio_conversions.h; sourceTree = ""; }; + BA4F59821E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_network_auto.cpp; sourceTree = ""; }; + BA4F59831E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_network_auto.hpp; sourceTree = ""; }; + BA4F59891E28DE4A003F5096 /* js_network_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_network_manual.cpp; sourceTree = ""; }; + BA4F598A1E28DE4A003F5096 /* js_network_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_network_manual.h; sourceTree = ""; }; BA9FD5D01BAC0A7600996C85 /* CCComponentJS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCComponentJS.cpp; path = component/CCComponentJS.cpp; sourceTree = ""; }; BA9FD5D11BAC0A7600996C85 /* CCComponentJS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCComponentJS.h; path = component/CCComponentJS.h; sourceTree = ""; }; BAF638DA1B5F5DC900CDB43A /* jsb_cocos2dx_audioengine_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_audioengine_auto.cpp; sourceTree = ""; }; @@ -360,6 +372,8 @@ BAFF7DE71D6196D40051B92F /* js_bindings_chipmunk_functions.h */, 4DFA4C0E1CBCC49000E3B736 /* jsb_creator_auto.cpp */, 4DFA4C0F1CBCC49000E3B736 /* jsb_creator_auto.hpp */, + BA4F59821E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp */, + BA4F59831E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp */, B38AD56C1B1D38700057DD7F /* jsb_cocos2dx_experimental_video_auto.cpp */, B38AD56D1B1D38700057DD7F /* jsb_cocos2dx_experimental_video_auto.hpp */, 4BE089E01ADF965E00D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp */, @@ -478,6 +492,8 @@ 1A119E7918BDF19200352BAA /* jsb_websocket.h */, 1A119E7A18BDF19200352BAA /* XMLHTTPRequest.cpp */, 1A119E7B18BDF19200352BAA /* XMLHTTPRequest.h */, + BA4F59891E28DE4A003F5096 /* js_network_manual.cpp */, + BA4F598A1E28DE4A003F5096 /* js_network_manual.h */, ); path = network; sourceTree = ""; @@ -558,6 +574,7 @@ BA127E6D1D791E21002C5B50 /* js_bindings_chipmunk_functions_registration.h in Headers */, 1A119EF518BDF19200352BAA /* js_bindings_system_registration.h in Headers */, 1A119EBF18BDF19200352BAA /* cocosbuilder_specifics.hpp in Headers */, + BA4F598D1E28DE4A003F5096 /* js_network_manual.h in Headers */, 4B22F4AB1B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h in Headers */, 1A119ED118BDF19200352BAA /* js_bindings_config.h in Headers */, BA127E711D791E21002C5B50 /* js_bindings_chipmunk_functions.h in Headers */, @@ -568,6 +585,7 @@ 1A119E9D18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp in Headers */, 1A119EEB18BDF19200352BAA /* jsb_opengl_registration.h in Headers */, BAFF7DF21D6196D40051B92F /* js_bindings_chipmunk_functions.h in Headers */, + BA4F59861E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp in Headers */, 1A119F0318BDF19200352BAA /* spidermonkey_specifics.h in Headers */, 1A119EE718BDF19200352BAA /* jsb_opengl_manual.h in Headers */, 1A119ED518BDF19200352BAA /* js_bindings_core.h in Headers */, @@ -620,6 +638,7 @@ 1A119ED218BDF19200352BAA /* js_bindings_config.h in Headers */, 1A119EFA18BDF19200352BAA /* jsb_websocket.h in Headers */, BA127E6E1D791E21002C5B50 /* js_bindings_chipmunk_functions_registration.h in Headers */, + BA4F598E1E28DE4A003F5096 /* js_network_manual.h in Headers */, BA127E681D791E21002C5B50 /* js_bindings_chipmunk_auto_classes_registration.h in Headers */, 1A119E9218BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp in Headers */, 4B22F4AC1B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h in Headers */, @@ -632,6 +651,7 @@ 1A119ED618BDF19200352BAA /* js_bindings_core.h in Headers */, 1A119EC418BDF19200352BAA /* js_bindings_ccbreader.h in Headers */, 1A119EE018BDF19200352BAA /* jsb_helper.h in Headers */, + BA4F59871E28DCD3003F5096 /* jsb_cocos2dx_network_auto.hpp in Headers */, FA6F1BBD1D816265007DD223 /* jsb_cocos2dx_dragonbones_manual.h in Headers */, 1A119ECC18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h in Headers */, BAFF7DE91D6196D40051B92F /* js_bindings_chipmunk_auto_classes_registration.h in Headers */, @@ -731,6 +751,7 @@ 1A119E8918BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */, 1A119EED18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */, 0541A7501973876100E45470 /* JavaScriptObjCBridge.mm in Sources */, + BA4F598B1E28DE4A003F5096 /* js_network_manual.cpp in Sources */, 1A119EE918BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */, 1A119EF718BDF19200352BAA /* jsb_websocket.cpp in Sources */, 1A119ED318BDF19200352BAA /* js_bindings_core.cpp in Sources */, @@ -762,6 +783,7 @@ 1A119EA118BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp in Sources */, BAFF7DF01D6196D40051B92F /* js_bindings_chipmunk_functions.cpp in Sources */, 1A119EDB18BDF19200352BAA /* js_manual_conversions.cpp in Sources */, + BA4F59841E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp in Sources */, BA127E691D791E21002C5B50 /* js_bindings_chipmunk_auto_classes.cpp in Sources */, 83A5661918DA878400FC31A0 /* jsb_socketio.cpp in Sources */, 1A119EE118BDF19200352BAA /* jsb_opengl_functions.cpp in Sources */, @@ -776,6 +798,7 @@ files = ( 0541A75B19738AD200E45470 /* JavaScriptObjCBridge.mm in Sources */, 1A119E8A18BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */, + BA4F598C1E28DE4A003F5096 /* js_network_manual.cpp in Sources */, 1A119EEE18BDF19200352BAA /* js_bindings_system_functions.cpp in Sources */, 4DFA4C021CBCBC4E00E3B736 /* js_module_register.cpp in Sources */, 1A119EEA18BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */, @@ -792,6 +815,7 @@ 1A119ED818BDF19200352BAA /* js_bindings_opengl.cpp in Sources */, BA9FD5D31BAC0A7600996C85 /* CCComponentJS.cpp in Sources */, 1AB5E62C18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp in Sources */, + BA4F59851E28DCD3003F5096 /* jsb_cocos2dx_network_auto.cpp in Sources */, 1A119E9C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */, 4BE089E41ADF965E00D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp in Sources */, BAFF7DF11D6196D40051B92F /* js_bindings_chipmunk_functions.cpp in Sources */, diff --git a/native/tools/bindings-generator b/native/tools/bindings-generator index 76dbaa46a6..4eea234913 160000 --- a/native/tools/bindings-generator +++ b/native/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 76dbaa46a6753d2cf04799a5be705f6b73312f92 +Subproject commit 4eea2349134601545ede7d6bf6429cc91bd321dd diff --git a/native/tools/tojs/cocos2dx_network.ini b/native/tools/tojs/cocos2dx_network.ini new file mode 100644 index 0000000000..e118bbd714 --- /dev/null +++ b/native/tools/tojs/cocos2dx_network.ini @@ -0,0 +1,60 @@ +[cocos2dx_network] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_network + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = jsb + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.9/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/%(clang_include)s +clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ + +cocos_headers = -I%(cocosdir)s -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external + +cocos_flags = -DANDROID + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/network/CCDownloader.h + +cpp_headers = network/js_network_manual.h + +# what classes to produce code for. You can use regular expressions here. When testing the regular +# expression, it will be enclosed in "^$", like this: "^Menu*$". +classes = Downloader + +# what should we skip? in the format ClassName::[function function] +# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. +skip = Downloader::[createDownloadDataTask] + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = Downloader + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Clonable + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. +script_control_cpp = yes