diff --git a/AUTHORS b/AUTHORS index 5de8a97e61..e4f2b9368f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -58,10 +58,17 @@ tkowalski @tkowalski Add missing affine transform functions renam Minh Quy @MQuy Fix url matching regex issue Park Hyun Chen @sincntx Fix cc.ScrollView constructor issue in JSB + Added cc.rectOverlapsRect function in JSB Vincent Chou @go3k Update README.md, add submodule update command suggestion Fix bug: Runtime.cpp protobuf object parseFromString may result in an incomplete protobuf object + Fix bug: PrebuiltRuntime ios version can't support portrait orientation. +Igor Mats @IgorMats Added outline shader sample + +G17hao @G17hao Fixed an typo issue in jsb_boot.js + +Simon de Lang @simondel Fixed use of deprecated cc, ccs and ccui create functions. Cocos2d-JS can not grow so fast without the active community. Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups! diff --git a/CHANGELOG b/CHANGELOG index 3f99266f4e..ccbc22db7c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,83 @@ ChangeLog: +Cocos2d-JS v3.2 @ Dec.29, 2014 + +* Replaced `transform` function with `setTransform` function under canvas render mode for better performance. +* Added a timer in `cc.audioEngine` to check audio element loading event, prevent the loading process being stucked when load audio file failed. +* Added some new browser types to `cc.sys`. +* Added some audio resource loading codes to ensure compatibility with Wechat browser. +* Added check for WebAudio support to ensure compatibility. +* [JSB]Upgraded Cocos2d-x to v3.3 Final. +* [JSB]Added `getSearchPaths` API to `jsb.Manifest` to support better script hot update. +* [JSB]Polished restart game feature. +* [JSB]Added a sample usage case for `jsb.AssetsManager`'s script hot update ability. +* [JSB]Skipped FlatBuffer related bindings. +* [JSB]Canceled modifications in Spine due to License restriction and removed new constructor for `sp.SkeletonAnimation`. + +* Bug fixes: + 1. Fixed an issue that `cc.InputManager` doesn't trigger touch event on chrome mobile emulator. + 2. Fixed an issue that `cc.game.setFrameRate` doesn't work. + 3. Fixed an issue that `cc.view` can't remove resize event listener. + 4. Fixed an issue that `cc.EventManager` didn't set register flag to false when a listener is removed. + 5. Fixed an issue that `cc.audioEngine` doesn't play some audios on some iOS devices. + 6. Fixed an issue of ccui controls that their `setColor` doesn't work when cascade color is enabled. + 7. Fixed an issue that `ccs.Armature`'s `setColor` doesn't work in canvas render mode. + 8. Fixed an issue that `ccs.Armature` crashes when adding a child to it. + 9. Fixed an issue that `cc.SpriteBatchNode`'s status is incorrect in WebGL render mode. + 10. Fixed an issue of `cc.Layer` that its position is incorrect under bake mode. + 11. Fixed an issue of `ccui.RichText` that its `setContentSize` doesn't work. + 12. Fixed an issue of `cc.LabelTTF` that its `setColor` doesn't work when cascade color is enabled. + 13. Fixed an issue of spine that its skeletons position is incorrect when scaleX equals to -1 and scaleY equals to 1. + 14. Fixed `sp.Skeleton`'s API inconsistence by renaming `boundingBox` to `getBoundingBox`. + 15. Removed all usages of deprecated create functions in the test cases. + 16. [JSB]Fixed an issue of `ccui.ScrollView`'s `innerWidth` and `innerHeight` properties. + 17. [JSB]Fixed an issue that setting `cc.Node`'s userData property will crash. + 18. [JSB]Fixed API inconsistence by renaming `jsb.fileUtils`'s `getByteArrayFromFile` to `getDataFromFile`. + 19. [JSB]Fixed a script file cache check issue in ScriptingCore.cpp. + 20. [JSB]Fixed an issue of `ccs.Armature`'s constructore. + +Cocos2d-JS v3.2 RC0 @ Dec.11, 2014 + +* Refactoration of web engine by separating the render logic, the arthictecture level refactoration is now completed and brounght great performance improvement. +* Refactoration of web engine's resolution adaptation and audio engine with polyfilled adaptation logics for different devices and browsers. This ensures better compatibility and better extensibility for future needs. +* Added `setRotation` method to `ccui.ImageView`. +* Added a function that fill sprite with repeated texture in Canvas mode. +* Added `setLineHeight` method to `cc.LabelTTF`. +* Added `dumpAudioInfo` to `cc.audioEngine` for debugging purpose on mobile browser. +* Removed Cocos Studio's Protobuffer support from the framework. +* Added an outline shader sample. +* [JSB] Supported modulization for JSB. +* [JSB] Added restart game feature. +* [JSB] Bound all missed chipmunk API in JSB and added test cases for new features, fix some potential memory leak issues. +* [JSB] Added `cc.sys.cleanScript` API to remove a script's cache. +* [JSB] Upgrade Cocos2d-x to v3.3 RC1. +* [JSB] Change default Android compiler to gcc. +* [JSB] Added manual bindings for `cc.Node#pause`. +* [JSB] Added missing constants and functions. + +* Bug fixes: + 1. Fixed an issue of `cc.Sprite` that its rendering is incorrect without texture. + 2. Fixed an issue of `cc.ClippingNode` that its stencil drawing is incorrect on Canvas Mode. + 3. Fixed an issue of `TextFieldReader` that it will throw an error when 'areaWidth' and 'areaHeight' equal to zero. + 4. Fixed an issue of `ccui.CheckBox` that its getSelectedState doesn't return its state. + 5. Fixed an issue of `cc.LabelTTF` that it doesn't update the string when its string become to empty string. + 6. Fixed an issue of `cc.ParticleSystem` that it can't change its texture mode and shape type in Canvas mode. + 7. Fixed an issue of `cc.Layer`'s bake function that its position is incorrect when cc.view's scale isn't 1. + 8. Fixed an issue of `ccs.ArmatureAnimation`'s `setMovementEventCallFunc` and `setFrameEventCallFunc`. + 9. Fixed an issue of `console.log` that it isn't a funtion on IE9. + 10. Fixed an issue of `CSLoader` that it will add duplicate resources to sprite frame cache. + 11. Fixed an issue of `cc.ProgressTimer` that its setColor is not taking effect. + 12. Fixed an issue of `cc.loader` that it will throw an error when loading a remote texture. + 13. Upgrade html5 version chipmunk to the latest release. + 14. [JSB] Fixed an issue that the string return value can not be accessed in JavaScript to Objective-C reflection. + 15. [JSB] Fixed potential memory leaks in JavaScriptJavaBridge. + 16. [JSB] Fixed libcurl's relocation overflow linker issue in Android release mode. + 17. [JSB] Fixed an issue of `ccui.CheckBox`'s _ctor function. + 18. [JSB] Made `cc.MenuSpriteImage`'s set functions support sprite frame name as parameter. + 19. [JSB] Made ccui's `addEventListener` functions support one argument. + 20. [JSB] Made `ccs.ArmatureAnimation`'s `setFrameEventCallFunc` and `setMovementEventCallFunc` accepts one parameter. + 21. [JSB] Made project.json's configs - `frameRate` and `debugMode` take effect in JSB. + Cocos2d-JS v3.1 @ Oct.22, 2014 * Released Facebook Integration for Cocos2d-JS v1.0, all APIs have been significantly polished and stabilized. Improved test cases for Facebook with more features demonstrated. diff --git a/CMakeLists.txt b/CMakeLists.txt index b25bc79c1d..baf38af98c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,23 +23,23 @@ # ****************************************************************************/ cmake_minimum_required(VERSION 2.8) -project (Cocos2djs) +project (Cocos2d-JS) # The version number -#set(Cocos2djsSamples_VERSION_MAJOR 3) -#set(Cocos2djsSamples_VERSION_MINOR 0) - -include(frameworks/js-bindings/cocos2d-x/cmake/BuildHelpers.CMakeLists.txt) +set(Cocos2d_JS_Samples_VERSION_MAJOR 3) +set(Cocos2d_JS_Samples_VERSION_MINOR 2) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cmake/Modules/") +include(CocosBuildHelpers) option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(DEBUG_MODE "Debug or release?" ON) -option(BUILD_LIBS_LUA "Build lua libraries" ON) option(BUILD_EXTENSIONS "Build extension library" ON) option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) +option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ON) option(BUILD_JSTests "build TestJS sample" ON) option(BUILD_JSMOONWARRIORS "build MoonWarriors sample" ON) @@ -70,7 +70,7 @@ elseif(APPLE) else()#Linux -ADD_DEFINITIONS(-DLINUX) +ADD_DEFINITIONS(-DLINUX -DCC_RESOURCE_FOLDER_LINUX="/") endif() @@ -111,82 +111,159 @@ else() # Assume Linux set(PLATFORM_FOLDER linux) endif() +set(COCOS_EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external) + + include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/platform - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/platform/desktop - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/platform/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/audio/include - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/editor-support - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/scripting/lua-bindings/auto - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/scripting/lua-bindings/manual + ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/ + ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/deprecated + ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/cocos/platform ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/extensions ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/tinyxml2 - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/unzip - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/edtaa3func - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/chipmunk/include/chipmunk - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/jpeg/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/png/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/tiff/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/webp/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/glfw3/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/freetype2/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/websockets/include/${PLATFORM_FOLDER} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/xxhash - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/external/spidermonkey/include/${PLATFORM_FOLDER} ) -if(WIN32) - include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/${PLATFORM_FOLDER}-specific/icon/include - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/${PLATFORM_FOLDER}-specific/zlib/include - external/curl/include/${PLATFORM_FOLDER} - ) -elseif(APPLE) - include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/curl/include/${PLATFORM_FOLDER} - ) -else() - include_directories( - /usr/include - /usr/include/GLFW - /usr/local/include/GLFW - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/${PLATFORM_FOLDER}-specific/fmod/include/${ARCH_DIR} - ) +if(USE_PREBUILT_LIBS) + include(CocosUsePrebuiltLibs) endif() +# GLFW3 used on Mac, Windows and Linux desktop platforms +if(LINUX OR MACOSX OR WINDOWS) + cocos_find_package(OpenGL OPENGL REQUIRED) + if(LINUX OR WINDOWS) + cocos_find_package(GLEW GLEW REQUIRED) + endif() + cocos_find_package(GLFW3 GLFW3 REQUIRED) + include_directories(${GLFW3_INCLUDE_DIRS}) -link_directories( - /usr/local/lib - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/chipmunk/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/jpeg/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/tiff/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/webp/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/png/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/freetype2/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/websockets/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/${PLATFORM_FOLDER}-specific/fmod/prebuilt/${ARCH_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/external/spidermonkey/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} -) + if(LINUX) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + find_package(Threads REQUIRED) + set(THREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + + #cocos_find_package(FMODEX FMODEX REQUIRED) + cocos_find_package(Fontconfig FONTCONFIG REQUIRED) + endif() + + if(WINDOWS) + cocos_find_package(Vorbis VORBIS REQUIRED) + cocos_find_package(MPG123 MPG123 REQUIRED) + cocos_find_package(OpenAL OPENAL REQUIRED) + # because FindOpenAL.cmake set include dir for '#include ' for portability (not for '#include ' + set(OPENAL_DEFINITIONS "-DOPENAL_PLAIN_INCLUDES") + endif() +endif(LINUX OR MACOSX OR WINDOWS) +# Freetype required on all platforms +cocos_find_package(Freetype FREETYPE REQUIRED) + +# WebP required if used +if(USE_WEBP) + cocos_find_package(WebP WEBP REQUIRED) +endif(USE_WEBP) + +# Chipmunk +if(USE_CHIPMUNK) + cocos_find_package(Chipmunk CHIPMUNK REQUIRED) + add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1) + if(IOS OR MACOSX) + # without this chipmunk will try to use apple defined geometry types, that conflicts with cocos + add_definitions(-DCP_USE_CGPOINTS=0) + endif() +else(USE_CHIPMUNK) + add_definitions(-DCC_USE_PHYSICS=0) +endif(USE_CHIPMUNK) + +# Box2d (not prebuilded, exists as source) +if(USE_BOX2D) + if(USE_PREBUILT_LIBS) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/Box2D) + set(Box2D_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/box2d/include) + set(Box2D_LIBRARIES box2d) + else() + find_package(Box2D REQUIRED CONFIG) + # actually Box2D in next line is not a library, it is target exported from Box2DConfig.cmake + set(Box2D_LIBRARIES Box2D) + endif() + message(STATUS "Box2D include dirs: ${Box2D_INCLUDE_DIRS}") + add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1) +else() + add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=0) +endif(USE_BOX2D) + +# Tinyxml2 (not prebuilded, exists as source) +if(USE_PREBUILT_LIBS) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/tinyxml2) + set(TinyXML2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/tinyxml2) + set(TinyXML2_LIBRARIES tinyxml2) +else() + cocos_find_package(TinyXML2 TinyXML2 REQUIRED) +endif() +message(STATUS "TinyXML2 include dirs: ${TinyXML2_INCLUDE_DIRS}") + +# libjpeg +cocos_find_package(JPEG JPEG REQUIRED) +cocos_find_package(ZLIB ZLIB REQUIRED) + +# minizip (we try to migrate to minizip from https://github.com/nmoinvaz/minizip) +# only msys2 currently provides package for this variant, all other +# dists have packages from zlib, thats very old for us. +# moreover our embedded version modified to quick provide +# functionality needed by cocos. +if(USE_PREBUILT_LIBS OR NOT MINGW) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/unzip) + set(MINIZIP_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/unzip) + set(MINIZIP_LIBRARIES unzip) + message(STATUS "MINIZIP include dirs: ${MINIZIP_INCLUDE_DIRS}") +else() + cocos_find_package(MINIZIP MINIZIP REQUIRED) + # double check that we have needed functions + include(CheckLibraryExists) + check_library_exists(${MINIZIP_LIBRARIES} "unzGoToFirstFile2" "" MINIZIP_HAS_GOTOFIRSTFILE2) + if(NOT MINIZIP_HAS_GOTOFIRSTFILE2) + message(FATAL_ERROR "Minizip library on you system very old. Please use recent version from https://github.com/nmoinvaz/minizip or enable USE_PREBUILT_LIBS") + endif() + add_definitions(-DMINIZIP_FROM_SYSTEM) +endif() + +cocos_find_package(PNG PNG REQUIRED) +cocos_find_package(TIFF TIFF REQUIRED) +cocos_find_package(WEBSOCKETS WEBSOCKETS REQUIRED) +cocos_find_package(CURL CURL REQUIRED) + +# protobuf-lite (not prebuilded, exists as source) +# TODO: for now we can't use upstream protobuf because these files: +# cocos/editor-support/cocostudio/CSParseBinary.pb.h +# cocos/editor-support/cocostudio/CSParseBinary.pb.cc +# was generated by concrete version of protobuf compiler +# and source file not provided. So these files can be +# compiled only with our in-source version of protobuf-lite +## if(USE_PREBUILT_LIBS) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/protobuf-lite) + set(PROTOBUF_LITE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/protobuf-lite/src) + set(PROTOBUF_LITE_LIBRARIES protobuf) +## else() +## cocos_find_package(Protobuf REQUIRED PROTOBUF_LITE_LIBRARIES) +## set(PROTOBUF_LITE_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS}) +## endif() +message(STATUS "Protobuf lite libs: ${PROTOBUF_LITE_LIBRARIES}") +message(STATUS "Protobuf include dirs: ${PROTOBUF_LITE_INCLUDE_DIRS}") # build for 3rd party libraries if(LINUX OR APPLE) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/Box2D) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/unzip) add_subdirectory(frameworks/js-bindings/cocos2d-x/external/xxhash) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/tinyxml2) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/protobuf-lite) endif() # cocos2d library add_subdirectory(frameworks/js-bindings/cocos2d-x/cocos) +link_directories( + /usr/local/lib + ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/external/spidermonkey/prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} +) + # jsbindings library add_subdirectory(frameworks/js-bindings/bindings) diff --git a/README.md b/README.md index c4f7e840c6..e486c5321d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - + Cocos2d-JS =========== @@ -39,7 +39,7 @@ Furthermore, JavaScript friendly APIs make your game development experience a br - Cocos2d-JS v3.0 uses Cocos2d-x 3.2 final as base of JSB solution - Cocos2d-JS v3.0 is compatible with Cocos Code IDE v1.0.0 RC2+ -- Cocos2d-JS v3.0 is compatible with Cocos Studio v1.2 - v1.5.0.1 +- Cocos2d-JS v3.0 is compatible with Cocos Studio v1.2 - v2.0 With any problems you might have, our communities are happy to help: diff --git a/build/android-build.py b/build/android-build.py index 3323f55285..e69c9eadbc 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -82,9 +82,9 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,an num_of_cpu = get_num_of_cpu() if ndk_build_param == None: - command = '%s -j%d -C %s NDK_DEBUG=%d %s' % (ndk_path, num_of_cpu, app_android_root, build_mode=='debug', ndk_module_path) + command = '%s -j%d -C %s NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=%d %s' % (ndk_path, num_of_cpu, app_android_root, build_mode=='debug', ndk_module_path) else: - command = '%s -j%d -C %s NDK_DEBUG=%d %s %s' % (ndk_path, num_of_cpu, app_android_root, build_mode=='debug', ndk_build_param, ndk_module_path) + command = '%s -j%d -C %s NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=%d %s %s' % (ndk_path, num_of_cpu, app_android_root, build_mode=='debug', ndk_build_param, ndk_module_path) print command if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") diff --git a/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj b/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj index c5e25e5f3d..67750e8852 100644 --- a/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj +++ b/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj @@ -1476,6 +1476,7 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../frameworks/js-bindings/cocos2d-x/plugin/plugins/facebook/proj.ios/sdk", + "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks", ); GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -1509,6 +1510,7 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../frameworks/js-bindings/cocos2d-x/plugin/plugins/facebook/proj.ios/sdk", + "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks", ); GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; diff --git a/build/install-deps-linux.sh b/build/install-deps-linux.sh index 183288af5d..2732ff78f4 100755 --- a/build/install-deps-linux.sh +++ b/build/install-deps-linux.sh @@ -21,6 +21,7 @@ DEPENDS+=' libfontconfig1-dev' DEPENDS+=' libsqlite3-dev' DEPENDS+=' libglew*-dev' DEPENDS+=' libssl-dev' +DEPENDS+=' gnutls-dev' MISSING= echo "Checking for missing packages ..." diff --git a/docs/release-note-v3.2.md b/docs/release-note-v3.2.md new file mode 100644 index 0000000000..f7347c28b8 --- /dev/null +++ b/docs/release-note-v3.2.md @@ -0,0 +1,71 @@ +# Cocos2d-JS v3.2 release note + + + +Cocos2d-JS is Cocos2d-x engine's JavaScript version that includes Cocos2d-html5 and Cocos2d-x JavaScript Bindings. It equips your game with cross-browser and cross-platform abilities, accompanied by full Cocos2d-x features and simplified JavaScript friendly APIs. + +Cocos2d-JS reinvented workflows for all platforms in v3.x, it provides a consistent development experience for whichever platform you want to distribute to, no matter web and native. "Code once, run everywhere" is incredibly easy and natural in Cocos2d-JS. With one single JavaScript code base, you can run your game on all web browsers and native platforms including Mac OS, Windows, iOS and Android. This will bring your game great opportunities in almost all channels of distribution. On the other hand, if you are only interested in casual games on the web, you can embed directly in your web page the Cocos2d-JS Lite Version which is extremely easy to use and light as a feather. + +In addition, Cocos2d-JS v3.x is super powerful along with all these cool new features: Editors Support, Assets Manager, Object Pool, JS to Objective-C/JAVA reflection, etc. + +One more thing, Facebook Integration for Cocos2d-JS have brought a huge opportunity for game developers who want to integrate Facebook functionality into their games. With a single code base, they can release fully cross-platform games across Facebook Canvas, iOS and Android. + +## Highlights + +* Refactoration of web engine by separating the render logic, the arthictecture level refactoration is now completed and brounght great performance improvement, especially on mobile browsers. +* Refactoration of web engine's resolution adaptation and audio engine with polyfilled adaptation logics for different devices and browsers. This ensures better compatibility and better extensibility for future needs. +* Supported modulization for JSB, developers can comment out the bindings registration code then the corresponded module will be excluded in the final package. Minimum package size for android is now 4.4mb. The usage is described in the upgrade guide. +* Added restart game feature and fixed crutial bugs in AssetsManager, developers can now easily update assets and scripts, new scripts can take effect directly with a restart. +* Bound all missed chipmunk API in JSB, this greatly improved physics game support in Cocos2d-JS. + +## Notice + +For JSB build, there are some restrictions : + +- [Android build] Suggested NDK version is r10c, if you don't need Android 5.0 compatibility, you can also use r9d, other NDKs are not supported. +- [iOS build] Xcode version must be 5.1.1 + +- [Web code obfuscation] JRE or JDK version must be 1.6 or 1.7 + +## Download + +- [Cocos2d-JS v3.2](http://www.cocos2d-x.org/filedown/cocos2d-js-v3.2.zip) +- [Online API reference](http://www.cocos2d-x.org/reference/html5-js/V3.0/index.html) +- [Downloadable API Reference](http://www.cocos2d-x.org/filedown/Cocos2d-JS-v3.2-API.zip) +- [Online test cases](http://cocos2d-x.org/js-tests/) + +## Workflows + +- Cross platforms developers can use Cocos Console to create projects, boost their development with web version engine and deploy games onto all native platforms and all browsers with Cocos Console. + +- Casual web game developers can download the Lite Version and start to develop just like using other web frameworks (e.g. jQuery). + +![](../../v3.0/release-note/workflows.jpg) + +## More information + +Read more about all the features and bug fixes + +- [Cocos2d-JS v3.2 changelog](http://www.cocos2d-x.org/docs/manual/framework/html5/release-notes/v3.2/changelog/en) +- [Cocos2d-JS v3.2 upgrade guide](http://www.cocos2d-x.org/docs/manual/framework/html5/release-notes/v3.2rc0/upgrade-guide/en) + +## Upgrade your project from previous versions + +If you want to upgrade your game based on v3.x previous version to the v3.2 version, you should follow these steps: + +1. Download the Cocos2d-JS v3.2 package. +2. Upgrade cocos command with `setup.py`. +3. Create a new project with `cocos new` command. +4. Replace the "src", "res", "index.html", "project.json", "main.js" etc with your old project. +5. Then you may need to refer to the upgrade guide to solve some API change issues. + +## About Cocos2d family + +- Cocos2d-JS v3.2 uses Cocos2d-x v3.3 as base of JSB solution +- Cocos2d-JS v3.2 is compatible with Cocos Code IDE v1.1.0 +- Cocos2d-JS v3.2 is compatible with Cocos Studio v1.2 - v1.6, Cocos Studio 2 support have been removed because flat buffer binary file can't be parsed in JS, we will support Cocos Studio 2 in v3.3 with a JSON format parser. + +With any problems you might have, our communities are happy to help: + +- [Online forum](http://discuss.cocos2d-x.org/category/cocos2d-x/javascript) +- [Document root](http://cocos2d-x.org/wiki/Cocos2d-JS) +- [Github repository](https://github.com/cocos2d/cocos2d-js) \ No newline at end of file diff --git a/docs/upgrade-guide-from-3.1-to-3.2.md b/docs/upgrade-guide-from-3.1-to-3.2.md new file mode 100644 index 0000000000..9320d2014b --- /dev/null +++ b/docs/upgrade-guide-from-3.1-to-3.2.md @@ -0,0 +1,127 @@ +#Upgrade guide from Cocos2d-JS v3.1 to Cocos2d-JS v3.2 + +## 0. Upgrade to Cocos2d-JS v3.1 + +If you are still using Cocos2d-html5 or previous version of Cocos2d-JS, you need to read the previous upgrade guide first : [Upgrade guide to Cocos2d-JS v3.1](../../v3.0rc0/upgrade-guide/en.md) + +## 1. Reduce package size with modulirization in JSB + +In Cocos2d-JS v3.2, during compilation, Cocos2d-x modules and related JavaScript Bindings code can be automatically excluded from the final package if they are not used. As you may already know, our web engine support modularization with `modules` section in project.json file. However, this configuration doesn't take effect in JSB, you should do the following to exclude any module you don't need in JSB. + +In AppDelegate.cpp, you will find `applicationDidFinishLaunching` function in which all JSB bindings are registered. If the registration code for a module is commented out, then the base Cocos2d-x module won't be used, during linking the linker will exclude it. This is a common optimization in linker, so it will take effect for both Android and iOS apps. Of course, all modules that you don't register their bindings won't be available in your JavaScript code. + +At last, you only need to compile your project. The minimum size of Android package in Cocos2d-JS v3.2 is 4.4mb. + +``` +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + auto director = Director::getInstance(); + auto glview = director->getOpenGLView(); + if(!glview) { + glview = cocos2d::GLViewImpl::createWithRect("Release3_2", Rect(0,0,900,640)); + director->setOpenGLView(glview); + } + + // set FPS. the default value is 1.0/60 if you don't call this + director->setAnimationInterval(1.0 / 60); + + ScriptingCore* sc = ScriptingCore::getInstance(); + sc->addRegisterCallback(register_all_cocos2dx); + sc->addRegisterCallback(register_cocos2dx_js_core); + sc->addRegisterCallback(register_cocos2dx_js_extensions); + sc->addRegisterCallback(jsb_register_system); + + // extension can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + + // chipmunk can be commented out to reduce the package + sc->addRegisterCallback(jsb_register_chipmunk); + // opengl can be commented out to reduce the package + sc->addRegisterCallback(JSB_register_opengl); + + // builder can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_builder); + sc->addRegisterCallback(register_CCBuilderReader); + + // ui can be commented out to reduce the package, attension studio need ui module + sc->addRegisterCallback(register_all_cocos2dx_ui); + sc->addRegisterCallback(register_all_cocos2dx_ui_manual); + + // studio can be commented out to reduce the package, + sc->addRegisterCallback(register_all_cocos2dx_studio); + sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + + // spine can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_spine); + sc->addRegisterCallback(register_all_cocos2dx_spine_manual); + + // XmlHttpRequest can be commented out to reduce the package + sc->addRegisterCallback(MinXmlHttpRequest::_js_register); + // websocket can be commented out to reduce the package + sc->addRegisterCallback(register_jsb_websocket); + // sokcet io can be commented out to reduce the package + sc->addRegisterCallback(register_jsb_socketio); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + sc->addRegisterCallback(JavascriptJavaBridge::_js_register); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + sc->addRegisterCallback(JavaScriptObjCBridge::_js_register); +#endif + sc->start(); + sc->runScript("script/jsb_boot.js"); + ScriptEngineProtocol *engine = ScriptingCore::getInstance(); + ScriptEngineManager::getInstance()->setScriptEngine(engine); + ScriptingCore::getInstance()->runScript("main.js"); + + return true; +} +``` + +## 2. Restart game and hot update related APIs + +Since Cocos2d-JS v3.0 Beta, we have provided AssetsManager for assets and scripts hot update ability. Ever since, its stability is greatly improved and become reliable. Thank to our developers, we have also collected many great suggestions and feature requests. In v3.2, we decided to add two importants ones: + +1. Clean a script's cache + + A script will be cached in JSB, so even if you updated it with AssetsManager, it won't take effect even if you require it again. In this case, we provided `cleanScript` API to clean its cache. + + ``` + cc.sys.cleanScript(scriptPath); + ``` + +2. Restart game + + Very often, when the hot update is done, the game need to be restarted entirely. So we provided restart game API, it will do the following steps: + + 1. Clean up Cocos2d-x's environment + 2. Restart the JavaScript VM + 3. Register all script bindings + 4. Re-execute the main.js + + The API is + + ``` + cc.game.restart() + ``` + +3. Manifest's new API: getSearchPaths + + If you want the new JavaScript files updated via AssetsManager to take effect, there are two requirements to be satisfied: + + 1. JavaScript files must be updated correctly. + 2. Everytime before the game start up, the search paths for the new scripts must be prepended before the execution of `cc.game.run()`. Then in `cc.game.run`, the engine will load the updated scripts. + + This means the search paths of the updated assets must be stored locally, so we have provided a new API of Manifest to retrieve the search pahts. Then the local storage can be used to save the search paths, it's our recommended way, but developers can also use whatever they want to save the paths persistantly. Here is an recommended process after the scripts hot update via AssetsManager: + + ``` + // After update succeeded, updated manifest will become the new local manifest. + var searchPaths = assetsManager.getLocalManifest().getSearchPaths(); + // The search paths can be coded to JSON string then stored in cc.sys.localStorage, so that it can be retrieved and preppended to jsb.fileUtils during the game restart. + cc.sys.localStorage.setItem("AssetsSearchPaths", JSON.stringify(searchPaths)); + // Restart the game to let new scripts take effect. + cc.game.restart(); + ``` + +Hope these new APIs will make hot update in your game much eaiser. \ No newline at end of file diff --git a/frameworks/cocos2d-html5 b/frameworks/cocos2d-html5 index fcd8b87528..a0cee92a3f 160000 --- a/frameworks/cocos2d-html5 +++ b/frameworks/cocos2d-html5 @@ -1 +1 @@ -Subproject commit fcd8b87528204d204cb53f6ed05eceb51958c9ce +Subproject commit a0cee92a3f345aefb5f973074a9222eabc941ea4 diff --git a/frameworks/js-bindings/bindings/CMakeLists.txt b/frameworks/js-bindings/bindings/CMakeLists.txt index e7ab97a8a2..a0f55deab4 100644 --- a/frameworks/js-bindings/bindings/CMakeLists.txt +++ b/frameworks/js-bindings/bindings/CMakeLists.txt @@ -77,10 +77,11 @@ include_directories( ../cocos2d-x/cocos/platform ../cocos2d-x/extensions ../cocos2d-x/external + ../cocos2d-x/cocos/editor-support ../cocos2d-x/cocos/editor-support/spine ../cocos2d-x/cocos/editor-support/cocosbuilder ../cocos2d-x/cocos/editor-support/cocostudio - ../cocos2d-x/external/chipmunk/include + ../cocos2d-x/external/chipmunk/include/chipmunk ) add_library(jsbindings STATIC @@ -89,6 +90,7 @@ add_library(jsbindings STATIC target_link_libraries(jsbindings sqlite3 + js_static ) set_target_properties(jsbindings diff --git a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_auto_api.js b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_auto_api.js index ee003ab46f..4a7777384b 100644 --- a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -883,14 +883,6 @@ func { }, -/** - * @method pause - */ -pause : function ( -) -{ -}, - /** * @method convertToWorldSpaceAR * @param {vec2_object} arg0 @@ -1279,14 +1271,6 @@ getName : function ( return ; }, -/** - * @method resume - */ -resume : function ( -) -{ -}, - /** * @method getRotation3D * @return {vec3_object} @@ -2714,23 +2698,13 @@ eventdispatcher }, /** - * @method pushScene - * @param {cc.Scene} arg0 - */ -pushScene : function ( -scene -) -{ -}, - -/** - * @method getDeltaTime - * @return {float} + * @method setContentScaleFactor + * @param {float} arg0 */ -getDeltaTime : function ( +setContentScaleFactor : function ( +float ) { - return 0; }, /** @@ -2754,13 +2728,13 @@ getWinSizeInPixels : function ( }, /** - * @method pushMatrix - * @param {cc.MATRIX_STACK_TYPE} arg0 + * @method getDeltaTime + * @return {float} */ -pushMatrix : function ( -matrix_stack_type +getDeltaTime : function ( ) { + return 0; }, /** @@ -2907,6 +2881,14 @@ getSecondsPerFrame : function ( return 0; }, +/** + * @method resetMatrixStack + */ +resetMatrixStack : function ( +) +{ +}, + /** * @method convertToUI * @param {vec2_object} arg0 @@ -2919,6 +2901,16 @@ vec2 return cc.Vec2; }, +/** + * @method pushMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + */ +pushMatrix : function ( +matrix_stack_type +) +{ +}, + /** * @method setDefaultValues */ @@ -2947,6 +2939,18 @@ scheduler { }, +/** + * @method getMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 + * @return {mat4_object} + */ +getMatrix : function ( +matrix_stack_type +) +{ + return cc.Mat4; +}, + /** * @method startAnimation */ @@ -2991,16 +2995,6 @@ stopAnimation : function ( { }, -/** - * @method setContentScaleFactor - * @param {float} arg0 - */ -setContentScaleFactor : function ( -float -) -{ -}, - /** * @method popToSceneStackLevel * @param {int} arg0 @@ -3098,31 +3092,27 @@ drawScene : function ( }, /** - * @method getZEye - * @return {float} + * @method restart */ -getZEye : function ( +restart : function ( ) { - return 0; }, /** - * @method getMatrix - * @param {cc.MATRIX_STACK_TYPE} arg0 - * @return {mat4_object} + * @method popScene */ -getMatrix : function ( -matrix_stack_type +popScene : function ( ) { - return cc.Mat4; }, /** - * @method popScene + * @method loadIdentityMatrix + * @param {cc.MATRIX_STACK_TYPE} arg0 */ -popScene : function ( +loadIdentityMatrix : function ( +matrix_stack_type ) { }, @@ -3148,29 +3138,33 @@ projection }, /** - * @method loadIdentityMatrix + * @method multiplyMatrix * @param {cc.MATRIX_STACK_TYPE} arg0 + * @param {mat4_object} arg1 */ -loadIdentityMatrix : function ( -matrix_stack_type +multiplyMatrix : function ( +matrix_stack_type, +mat4 ) { }, /** - * @method setNextDeltaTimeZero - * @param {bool} arg0 + * @method getZEye + * @return {float} */ -setNextDeltaTimeZero : function ( -bool +getZEye : function ( ) { + return 0; }, /** - * @method resetMatrixStack + * @method setNextDeltaTimeZero + * @param {bool} arg0 */ -resetMatrixStack : function ( +setNextDeltaTimeZero : function ( +bool ) { }, @@ -3206,11 +3200,11 @@ getScheduler : function ( }, /** - * @method setAnimationInterval - * @param {double} arg0 + * @method pushScene + * @param {cc.Scene} arg0 */ -setAnimationInterval : function ( -double +pushScene : function ( +scene ) { }, @@ -3266,13 +3260,11 @@ scene }, /** - * @method multiplyMatrix - * @param {cc.MATRIX_STACK_TYPE} arg0 - * @param {mat4_object} arg1 + * @method setAnimationInterval + * @param {double} arg0 */ -multiplyMatrix : function ( -matrix_stack_type, -mat4 +setAnimationInterval : function ( +double ) { }, @@ -4590,6 +4582,16 @@ Speed : function ( */ cc.Follow = { +/** + * @method setBoundarySet + * @param {bool} arg0 + */ +setBoundarySet : function ( +bool +) +{ +}, + /** * @method initWithTarget * @param {cc.Node} arg0 @@ -4604,16 +4606,6 @@ rect return false; }, -/** - * @method setBoudarySet - * @param {bool} arg0 - */ -setBoudarySet : function ( -bool -) -{ -}, - /** * @method isBoundarySet * @return {bool} @@ -10106,6 +10098,251 @@ ProtectedNode : function ( }; +/** + * @class GLProgramState + */ +cc.GLProgramState = { + +/** + * @method setUniformTexture +* @param {String|String|int|int} str +* @param {unsigned int|cc.Texture2D|cc.Texture2D|unsigned int} int +*/ +setUniformTexture : function( +int, +int +) +{ +}, + +/** + * @method setUniformMat4 +* @param {int|String} int +* @param {mat4_object|mat4_object} mat4 +*/ +setUniformMat4 : function( +str, +mat4 +) +{ +}, + +/** + * @method applyUniforms + */ +applyUniforms : function ( +) +{ +}, + +/** + * @method setUniformCallback +* @param {int|String} int +* @param {function|function} func +*/ +setUniformCallback : function( +str, +func +) +{ +}, + +/** + * @method applyGLProgram + * @param {mat4_object} arg0 + */ +applyGLProgram : function ( +mat4 +) +{ +}, + +/** + * @method getUniformCount + * @return {long} + */ +getUniformCount : function ( +) +{ + return 0; +}, + +/** + * @method applyAttributes + */ +applyAttributes : function ( +) +{ +}, + +/** + * @method setUniformFloat +* @param {int|String} int +* @param {float|float} float +*/ +setUniformFloat : function( +str, +float +) +{ +}, + +/** + * @method setUniformVec3 +* @param {int|String} int +* @param {vec3_object|vec3_object} vec3 +*/ +setUniformVec3 : function( +str, +vec3 +) +{ +}, + +/** + * @method setUniformInt +* @param {int|String} int +* @param {int|int} int +*/ +setUniformInt : function( +str, +int +) +{ +}, + +/** + * @method getVertexAttribCount + * @return {long} + */ +getVertexAttribCount : function ( +) +{ + return 0; +}, + +/** + * @method setGLProgram + * @param {cc.GLProgram} arg0 + */ +setGLProgram : function ( +glprogram +) +{ +}, + +/** + * @method setUniformVec2 +* @param {int|String} int +* @param {vec2_object|vec2_object} vec2 +*/ +setUniformVec2 : function( +str, +vec2 +) +{ +}, + +/** + * @method getVertexAttribsFlags + * @return {unsigned int} + */ +getVertexAttribsFlags : function ( +) +{ + return 0; +}, + +/** + * @method setVertexAttribCallback + * @param {String} arg0 + * @param {function} arg1 + */ +setVertexAttribCallback : function ( +str, +func +) +{ +}, + +/** + * @method apply + * @param {mat4_object} arg0 + */ +apply : function ( +mat4 +) +{ +}, + +/** + * @method setVertexAttribPointer + * @param {String} arg0 + * @param {int} arg1 + * @param {unsigned int} arg2 + * @param {unsigned char} arg3 + * @param {int} arg4 + * @param {void} arg5 + */ +setVertexAttribPointer : function ( +str, +int, +int, +char, +int, +void +) +{ +}, + +/** + * @method getGLProgram + * @return {cc.GLProgram} + */ +getGLProgram : function ( +) +{ + return cc.GLProgram; +}, + +/** + * @method create + * @param {cc.GLProgram} arg0 + * @return {cc.GLProgramState} + */ +create : function ( +glprogram +) +{ + return cc.GLProgramState; +}, + +/** + * @method getOrCreateWithGLProgramName + * @param {String} arg0 + * @return {cc.GLProgramState} + */ +getOrCreateWithGLProgramName : function ( +str +) +{ + return cc.GLProgramState; +}, + +/** + * @method getOrCreateWithGLProgram + * @param {cc.GLProgram} arg0 + * @return {cc.GLProgramState} + */ +getOrCreateWithGLProgram : function ( +glprogram +) +{ + return cc.GLProgramState; +}, + +}; + /** * @class AtlasNode */ @@ -14449,10 +14686,10 @@ Menu : function ( cc.ClippingNode = { /** - * @method isInverted + * @method hasContent * @return {bool} */ -isInverted : function ( +hasContent : function ( ) { return false; @@ -14520,6 +14757,16 @@ float { }, +/** + * @method isInverted + * @return {bool} + */ +isInverted : function ( +) +{ + return false; +}, + /** * @method create * @param {cc.Node} node @@ -18131,20 +18378,6 @@ getFragmentShaderLog : function ( return ; }, -/** - * @method setUniformLocationWithMatrix2fv - * @param {int} arg0 - * @param {float} arg1 - * @param {unsigned int} arg2 - */ -setUniformLocationWithMatrix2fv : function ( -int, -float, -int -) -{ -}, - /** * @method bindAttribLocation * @param {String} arg0 @@ -18157,20 +18390,6 @@ int { }, -/** - * @method setUniformLocationWithMatrix4fv - * @param {int} arg0 - * @param {float} arg1 - * @param {unsigned int} arg2 - */ -setUniformLocationWithMatrix4fv : function ( -int, -float, -int -) -{ -}, - /** * @method getUniformLocationForName * @param {char} arg0 @@ -18227,6 +18446,18 @@ char return false; }, +/** + * @method setUniformLocationWith1f + * @param {int} arg0 + * @param {float} arg1 + */ +setUniformLocationWith1f : function ( +int, +float +) +{ +}, + /** * @method initWithFilenames * @param {String} arg0 @@ -18241,6 +18472,22 @@ str return false; }, +/** + * @method setUniformLocationWith3f + * @param {int} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + */ +setUniformLocationWith3f : function ( +int, +float, +float, +float +) +{ +}, + /** * @method setUniformsForBuiltins * @param {mat4_object} mat4 @@ -18268,15 +18515,19 @@ int }, /** - * @method setUniformLocationWith3iv + * @method setUniformLocationWith4f * @param {int} arg0 - * @param {int} arg1 - * @param {unsigned int} arg2 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @param {float} arg4 */ -setUniformLocationWith3iv : function ( -int, +setUniformLocationWith4f : function ( int, -int +float, +float, +float, +float ) { }, @@ -18289,20 +18540,6 @@ updateUniforms : function ( { }, -/** - * @method setUniformLocationWith4iv - * @param {int} arg0 - * @param {int} arg1 - * @param {unsigned int} arg2 - */ -setUniformLocationWith4iv : function ( -int, -int, -int -) -{ -}, - /** * @method getUniformLocation * @param {String} arg0 @@ -18325,34 +18562,6 @@ link : function ( return false; }, -/** - * @method setUniformLocationWith2iv - * @param {int} arg0 - * @param {int} arg1 - * @param {unsigned int} arg2 - */ -setUniformLocationWith2iv : function ( -int, -int, -int -) -{ -}, - -/** - * @method setUniformLocationWithMatrix3fv - * @param {int} arg0 - * @param {float} arg1 - * @param {unsigned int} arg2 - */ -setUniformLocationWithMatrix3fv : function ( -int, -float, -int -) -{ -}, - /** * @method reset */ @@ -18385,6 +18594,20 @@ str return cc.VertexAttrib; }, +/** + * @method setUniformLocationWith2f + * @param {int} arg0 + * @param {float} arg1 + * @param {float} arg2 + */ +setUniformLocationWith2f : function ( +int, +float, +float +) +{ +}, + /** * @method setUniformLocationWith4i * @param {int} arg0 diff --git a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_extension_auto_api.js b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_extension_auto_api.js index 3f602602a4..c0cdf69eb5 100644 --- a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_extension_auto_api.js +++ b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_extension_auto_api.js @@ -151,394 +151,6 @@ Control : function ( }; -/** - * @class Scale9Sprite - */ -cc.Scale9Sprite = { - -/** - * @method disableCascadeColor - */ -disableCascadeColor : function ( -) -{ -}, - -/** - * @method updateWithSprite -* @param {cc.Sprite|cc.Sprite} sprite -* @param {rect_object|rect_object} rect -* @param {bool|bool} bool -* @param {vec2_object|rect_object} vec2 -* @param {size_object} size -* @param {rect_object} rect -* @return {bool|bool} -*/ -updateWithSprite : function( -sprite, -rect, -bool, -vec2, -size, -rect -) -{ - return false; -}, - -/** - * @method isFlippedX - * @return {bool} - */ -isFlippedX : function ( -) -{ - return false; -}, - -/** - * @method setFlippedY - * @param {bool} arg0 - */ -setFlippedY : function ( -bool -) -{ -}, - -/** - * @method setFlippedX - * @param {bool} arg0 - */ -setFlippedX : function ( -bool -) -{ -}, - -/** - * @method setScale9Enabled - * @param {bool} arg0 - */ -setScale9Enabled : function ( -bool -) -{ -}, - -/** - * @method disableCascadeOpacity - */ -disableCascadeOpacity : function ( -) -{ -}, - -/** - * @method setInsetBottom - * @param {float} arg0 - */ -setInsetBottom : function ( -float -) -{ -}, - -/** - * @method initWithSpriteFrameName -* @param {String|String} str -* @param {rect_object} rect -* @return {bool|bool} -*/ -initWithSpriteFrameName : function( -str, -rect -) -{ - return false; -}, - -/** - * @method getSprite - * @return {cc.Sprite} - */ -getSprite : function ( -) -{ - return cc.Sprite; -}, - -/** - * @method setInsetTop - * @param {float} arg0 - */ -setInsetTop : function ( -float -) -{ -}, - -/** - * @method init -* @param {cc.Sprite|cc.Sprite|cc.Sprite} sprite -* @param {rect_object|rect_object|rect_object} rect -* @param {bool|rect_object|bool} bool -* @param {rect_object|vec2_object} rect -* @param {size_object} size -* @param {rect_object} rect -* @return {bool|bool|bool|bool} -*/ -init : function( -sprite, -rect, -bool, -vec2, -size, -rect -) -{ - return false; -}, - -/** - * @method setPreferredSize - * @param {size_object} arg0 - */ -setPreferredSize : function ( -size -) -{ -}, - -/** - * @method getInsetRight - * @return {float} - */ -getInsetRight : function ( -) -{ - return 0; -}, - -/** - * @method setSpriteFrame - * @param {cc.SpriteFrame} arg0 - * @param {rect_object} arg1 - */ -setSpriteFrame : function ( -spriteframe, -rect -) -{ -}, - -/** - * @method getInsetBottom - * @return {float} - */ -getInsetBottom : function ( -) -{ - return 0; -}, - -/** - * @method resizableSpriteWithCapInsets - * @param {rect_object} arg0 - * @return {ccui.Scale9Sprite} - */ -resizableSpriteWithCapInsets : function ( -rect -) -{ - return ccui.Scale9Sprite; -}, - -/** - * @method isScale9Enabled - * @return {bool} - */ -isScale9Enabled : function ( -) -{ - return false; -}, - -/** - * @method getCapInsets - * @return {rect_object} - */ -getCapInsets : function ( -) -{ - return cc.Rect; -}, - -/** - * @method getOriginalSize - * @return {size_object} - */ -getOriginalSize : function ( -) -{ - return cc.Size; -}, - -/** - * @method initWithFile -* @param {String|String|rect_object|String} str -* @param {rect_object|rect_object|String} rect -* @param {rect_object} rect -* @return {bool|bool|bool|bool} -*/ -initWithFile : function( -str, -rect, -rect -) -{ - return false; -}, - -/** - * @method getInsetTop - * @return {float} - */ -getInsetTop : function ( -) -{ - return 0; -}, - -/** - * @method setInsetLeft - * @param {float} arg0 - */ -setInsetLeft : function ( -float -) -{ -}, - -/** - * @method initWithSpriteFrame -* @param {cc.SpriteFrame|cc.SpriteFrame} spriteframe -* @param {rect_object} rect -* @return {bool|bool} -*/ -initWithSpriteFrame : function( -spriteframe, -rect -) -{ - return false; -}, - -/** - * @method getPreferredSize - * @return {size_object} - */ -getPreferredSize : function ( -) -{ - return cc.Size; -}, - -/** - * @method setCapInsets - * @param {rect_object} arg0 - */ -setCapInsets : function ( -rect -) -{ -}, - -/** - * @method isFlippedY - * @return {bool} - */ -isFlippedY : function ( -) -{ - return false; -}, - -/** - * @method getInsetLeft - * @return {float} - */ -getInsetLeft : function ( -) -{ - return 0; -}, - -/** - * @method setInsetRight - * @param {float} arg0 - */ -setInsetRight : function ( -float -) -{ -}, - -/** - * @method create -* @param {String|rect_object|String|String} str -* @param {rect_object|String|rect_object} rect -* @param {rect_object} rect -* @return {ccui.Scale9Sprite|ccui.Scale9Sprite|ccui.Scale9Sprite|ccui.Scale9Sprite|ccui.Scale9Sprite} -*/ -create : function( -str, -rect, -rect -) -{ - return ccui.Scale9Sprite; -}, - -/** - * @method createWithSpriteFrameName -* @param {String|String} str -* @param {rect_object} rect -* @return {ccui.Scale9Sprite|ccui.Scale9Sprite} -*/ -createWithSpriteFrameName : function( -str, -rect -) -{ - return ccui.Scale9Sprite; -}, - -/** - * @method createWithSpriteFrame -* @param {cc.SpriteFrame|cc.SpriteFrame} spriteframe -* @param {rect_object} rect -* @return {ccui.Scale9Sprite|ccui.Scale9Sprite} -*/ -createWithSpriteFrame : function( -spriteframe, -rect -) -{ - return ccui.Scale9Sprite; -}, - -/** - * @method Scale9Sprite - * @constructor - */ -Scale9Sprite : function ( -) -{ -}, - -}; - /** * @class ControlButton */ @@ -3026,6 +2638,16 @@ getVersionFileUrl : function ( return ; }, +/** + * @method getSearchPaths + * @return {Array} + */ +getSearchPaths : function ( +) +{ + return new Array(); +}, + }; /** diff --git a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_spine_auto_api.js b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_spine_auto_api.js index 9776cfeb96..664f1adfe5 100644 --- a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_spine_auto_api.js +++ b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_spine_auto_api.js @@ -19,53 +19,51 @@ float }, /** - * @method getDebugSlotsEnabled + * @method isOpacityModifyRGB * @return {bool} */ -getDebugSlotsEnabled : function ( +isOpacityModifyRGB : function ( ) { return false; }, /** - * @method setAttachment - * @param {String} arg0 - * @param {String} arg1 - * @return {bool} + * @method drawSkeleton + * @param {mat4_object} arg0 + * @param {unsigned int} arg1 */ -setAttachment : function ( -str, -str +drawSkeleton : function ( +mat4, +int ) { - return false; }, /** - * @method setBonesToSetupPose + * @method setDebugSlotsEnabled + * @param {bool} arg0 */ -setBonesToSetupPose : function ( +setDebugSlotsEnabled : function ( +bool ) { }, /** - * @method isOpacityModifyRGB + * @method getDebugSlotsEnabled * @return {bool} */ -isOpacityModifyRGB : function ( +getDebugSlotsEnabled : function ( ) { return false; }, /** - * @method setDebugSlotsEnabled - * @param {bool} arg0 + * @method setBonesToSetupPose */ -setDebugSlotsEnabled : function ( -bool +setBonesToSetupPose : function ( ) { }, @@ -79,41 +77,45 @@ setSlotsToSetupPose : function ( }, /** - * @method setOpacityModifyRGB - * @param {bool} arg0 + * @method setAttachment + * @param {String} arg0 + * @param {String} arg1 + * @return {bool} */ -setOpacityModifyRGB : function ( -bool +setAttachment : function ( +str, +str ) { + return false; }, /** - * @method setToSetupPose + * @method getBlendFunc + * @return {cc.BlendFunc} */ -setToSetupPose : function ( +getBlendFunc : function ( ) { + return cc.BlendFunc; }, /** - * @method getBlendFunc - * @return {cc.BlendFunc} + * @method setSkin + * @param {String} arg0 + * @return {bool} */ -getBlendFunc : function ( +setSkin : function ( +str ) { - return cc.BlendFunc; + return false; }, /** - * @method drawSkeleton - * @param {mat4_object} arg0 - * @param {unsigned int} arg1 + * @method setToSetupPose */ -drawSkeleton : function ( -mat4, -int +setToSetupPose : function ( ) { }, @@ -127,9 +129,11 @@ updateWorldTransform : function ( }, /** - * @method initialize + * @method setOpacityModifyRGB + * @param {bool} arg0 */ -initialize : function ( +setOpacityModifyRGB : function ( +bool ) { }, @@ -145,23 +149,23 @@ bool }, /** - * @method getDebugBonesEnabled - * @return {bool} + * @method getSkeleton + * @return {spSkeleton} */ -getDebugBonesEnabled : function ( +getSkeleton : function ( ) { - return false; + return spSkeleton; }, /** - * @method getTimeScale - * @return {float} + * @method getDebugBonesEnabled + * @return {bool} */ -getTimeScale : function ( +getDebugBonesEnabled : function ( ) { - return 0; + return false; }, /** @@ -175,25 +179,13 @@ blendfunc }, /** - * @method setSkin - * @param {String} arg0 - * @return {bool} - */ -setSkin : function ( -str -) -{ - return false; -}, - -/** - * @method getSkeleton - * @return {spSkeleton} + * @method getTimeScale + * @return {float} */ -getSkeleton : function ( +getTimeScale : function ( ) { - return spSkeleton; + return 0; }, /** @@ -212,21 +204,6 @@ float return sp.SkeletonRenderer; }, -/** - * @method SkeletonRenderer - * @constructor -* @param {spSkeletonData|String|String} spskeletondata -* @param {bool|spAtlas|String} bool -* @param {float|float} float -*/ -SkeletonRenderer : function( -str, -str, -float -) -{ -}, - }; /** @@ -372,14 +349,6 @@ func { }, -/** - * @method initialize - */ -initialize : function ( -) -{ -}, - /** * @method clearTracks */ @@ -428,19 +397,4 @@ float return sp.SkeletonAnimation; }, -/** - * @method SkeletonAnimation - * @constructor -* @param {String|spSkeletonData|String} str -* @param {spAtlas|String} spatlas -* @param {float|float} float -*/ -SkeletonAnimation : function( -str, -str, -float -) -{ -}, - }; diff --git a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_studio_auto_api.js b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_studio_auto_api.js index 88ab9e3edf..eb7d72428b 100644 --- a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_studio_auto_api.js +++ b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_studio_auto_api.js @@ -205,16 +205,14 @@ ActionObject : function ( ccs.ActionManager = { /** - * @method playActionByName -* @param {char|char} char -* @param {char|char} char -* @param {cc.CallFunc} callfunc -* @return {ccs.ActionObject|ccs.ActionObject} -*/ -playActionByName : function( -char, -char, -callfunc + * @method stopActionByName + * @param {char} arg0 + * @param {char} arg1 + * @return {ccs.ActionObject} + */ +stopActionByName : function ( +char, +char ) { return ccs.ActionObject; @@ -250,6 +248,22 @@ stexpcoconode { }, +/** + * @method playActionByName +* @param {char|char} char +* @param {char|char} char +* @param {cc.CallFunc} callfunc +* @return {ccs.ActionObject|ccs.ActionObject} +*/ +playActionByName : function( +char, +char, +callfunc +) +{ + return ccs.ActionObject; +}, + /** * @method releaseActions */ @@ -3065,54 +3079,6 @@ str return ccs.timeline::ActionTimeline; }, -/** - * @method createActionFromProtocolBuffers - * @param {String} arg0 - * @return {ccs.timeline::ActionTimeline} - */ -createActionFromProtocolBuffers : function ( -str -) -{ - return ccs.timeline::ActionTimeline; -}, - -/** - * @method createActionFromXML - * @param {String} arg0 - * @return {ccs.timeline::ActionTimeline} - */ -createActionFromXML : function ( -str -) -{ - return ccs.timeline::ActionTimeline; -}, - -/** - * @method loadAnimationActionWithFileFromProtocolBuffers - * @param {String} arg0 - * @return {ccs.timeline::ActionTimeline} - */ -loadAnimationActionWithFileFromProtocolBuffers : function ( -str -) -{ - return ccs.timeline::ActionTimeline; -}, - -/** - * @method loadAnimationActionWithFileFromXML - * @param {String} arg0 - * @return {ccs.timeline::ActionTimeline} - */ -loadAnimationActionWithFileFromXML : function ( -str -) -{ - return ccs.timeline::ActionTimeline; -}, - /** * @method purge */ @@ -3165,18 +3131,6 @@ str { }, -/** - * @method loadActionTimelineFromXML - * @param {tinyxml2::XMLElement} arg0 - * @return {ccs.timeline::ActionTimeline} - */ -loadActionTimelineFromXML : function ( -xmlelement -) -{ - return ccs.timeline::ActionTimeline; -}, - /** * @method destroyInstance */ @@ -4209,13 +4163,23 @@ int ccs.ActionTimeline = { /** - * @method getTimelines - * @return {Array} + * @method setFrameEventCallFunc + * @param {function} arg0 */ -getTimelines : function ( +setFrameEventCallFunc : function ( +func +) +{ +}, + +/** + * @method addTimeline + * @param {ccs.timeline::Timeline} arg0 + */ +addTimeline : function ( +timeline ) { - return new Array(); }, /** @@ -4247,98 +4211,68 @@ pause : function ( }, /** - * @method setFrameEventCallFunc - * @param {function} arg0 - */ -setFrameEventCallFunc : function ( -func -) -{ -}, - -/** - * @method resume - */ -resume : function ( -) -{ -}, - -/** - * @method getDuration - * @return {int} + * @method init + * @return {bool} */ -getDuration : function ( +init : function ( ) { - return 0; + return false; }, /** - * @method addTimeline + * @method removeTimeline * @param {ccs.timeline::Timeline} arg0 */ -addTimeline : function ( +removeTimeline : function ( timeline ) { }, /** - * @method getEndFrame - * @return {int} - */ -getEndFrame : function ( -) -{ - return 0; -}, - -/** - * @method setCurrentFrame - * @param {int} arg0 + * @method setLastFrameCallFunc + * @param {function} arg0 */ -setCurrentFrame : function ( -int +setLastFrameCallFunc : function ( +func ) { }, /** - * @method setTimeSpeed - * @param {float} arg0 + * @method getTimelines + * @return {Array} */ -setTimeSpeed : function ( -float +getTimelines : function ( ) { + return new Array(); }, /** - * @method init - * @return {bool} + * @method resume */ -init : function ( +resume : function ( ) { - return false; }, /** - * @method setDuration - * @param {int} arg0 + * @method getTimeSpeed + * @return {float} */ -setDuration : function ( -int +getTimeSpeed : function ( ) { + return 0; }, /** - * @method getTimeSpeed - * @return {float} + * @method getDuration + * @return {int} */ -getTimeSpeed : function ( +getDuration : function ( ) { return 0; @@ -4381,104 +4315,86 @@ bool }, /** - * @method removeTimeline - * @param {ccs.timeline::Timeline} arg0 + * @method clearFrameEventCallFunc */ -removeTimeline : function ( -timeline +clearFrameEventCallFunc : function ( ) { }, /** - * @method clearFrameEventCallFunc + * @method getEndFrame + * @return {int} */ -clearFrameEventCallFunc : function ( +getEndFrame : function ( ) { + return 0; }, /** - * @method create - * @return {ccs.timeline::ActionTimeline} + * @method setTimeSpeed + * @param {float} arg0 */ -create : function ( +setTimeSpeed : function ( +float ) { - return ccs.timeline::ActionTimeline; }, /** - * @method ActionTimeline - * @constructor + * @method clearLastFrameCallFunc */ -ActionTimeline : function ( +clearLastFrameCallFunc : function ( ) { }, -}; - /** - * @class CSLoader - */ -ccs.CSLoader = { - -/** - * @method createNodeFromJson - * @param {String} arg0 - * @return {cc.Node} + * @method setDuration + * @param {int} arg0 */ -createNodeFromJson : function ( -str +setDuration : function ( +int ) { - return cc.Node; }, /** - * @method nodeFromXML - * @param {tinyxml2::XMLElement} arg0 - * @param {String} arg1 - * @return {cc.Node} + * @method setCurrentFrame + * @param {int} arg0 */ -nodeFromXML : function ( -xmlelement, -str +setCurrentFrame : function ( +int ) { - return cc.Node; }, /** - * @method createNodeFromProtocolBuffers - * @param {String} arg0 - * @return {cc.Node} + * @method create + * @return {ccs.timeline::ActionTimeline} */ -createNodeFromProtocolBuffers : function ( -str +create : function ( ) { - return cc.Node; + return ccs.timeline::ActionTimeline; }, /** - * @method init + * @method ActionTimeline + * @constructor */ -init : function ( +ActionTimeline : function ( ) { }, +}; + /** - * @method setRecordXMLPath - * @param {bool} arg0 + * @class CSLoader */ -setRecordXMLPath : function ( -bool -) -{ -}, +ccs.CSLoader = { /** * @method setJsonPath @@ -4491,11 +4407,11 @@ str }, /** - * @method loadNodeWithFile + * @method createNodeFromJson * @param {String} arg0 * @return {cc.Node} */ -loadNodeWithFile : function ( +createNodeFromJson : function ( str ) { @@ -4503,11 +4419,11 @@ str }, /** - * @method loadNodeWithContent + * @method loadNodeWithFile * @param {String} arg0 * @return {cc.Node} */ -loadNodeWithContent : function ( +loadNodeWithFile : function ( str ) { @@ -4515,51 +4431,45 @@ str }, /** - * @method isRecordProtocolBuffersPath - * @return {bool} - */ -isRecordProtocolBuffersPath : function ( -) -{ - return false; -}, - -/** - * @method isRecordXMLPath + * @method bindCallback + * @param {String} arg0 + * @param {String} arg1 + * @param {ccui.Widget} arg2 + * @param {cc.Node} arg3 * @return {bool} */ -isRecordXMLPath : function ( +bindCallback : function ( +str, +str, +widget, +node ) { return false; }, /** - * @method getProtocolBuffersPath - * @return {String} + * @method purge */ -getProtocolBuffersPath : function ( +purge : function ( ) { - return ; }, /** - * @method getXMLPath - * @return {String} + * @method init */ -getXMLPath : function ( +init : function ( ) { - return ; }, /** - * @method createNodeFromXML + * @method loadNodeWithContent * @param {String} arg0 * @return {cc.Node} */ -createNodeFromXML : function ( +loadNodeWithContent : function ( str ) { @@ -4576,16 +4486,6 @@ isRecordJsonPath : function ( return false; }, -/** - * @method setRecordProtocolBuffersPath - * @param {bool} arg0 - */ -setRecordProtocolBuffersPath : function ( -bool -) -{ -}, - /** * @method getJsonPath * @return {String} @@ -4606,46 +4506,6 @@ bool { }, -/** - * @method setProtocolBuffersPath - * @param {String} arg0 - */ -setProtocolBuffersPath : function ( -str -) -{ -}, - -/** - * @method purge - */ -purge : function ( -) -{ -}, - -/** - * @method setXMLPath - * @param {String} arg0 - */ -setXMLPath : function ( -str -) -{ -}, - -/** - * @method nodeFromXMLFile - * @param {String} arg0 - * @return {cc.Node} - */ -nodeFromXMLFile : function ( -str -) -{ - return cc.Node; -}, - /** * @method destroyInstance */ diff --git a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index cc7e2de82d..cf4a7f39d5 100644 --- a/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/frameworks/js-bindings/bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -247,13 +247,13 @@ bool }, /** - * @method init - * @return {bool} + * @method setCallbackName + * @param {String} arg0 */ -init : function ( +setCallbackName : function ( +str ) { - return false; }, /** @@ -387,15 +387,13 @@ getLayoutParameter : function ( }, /** - * @method hitTest - * @param {vec2_object} arg0 - * @return {bool} + * @method addCCSEventListener + * @param {function} arg0 */ -hitTest : function ( -vec2 +addCCSEventListener : function ( +func ) { - return false; }, /** @@ -482,6 +480,16 @@ isTouchEnabled : function ( return false; }, +/** + * @method getCallbackName + * @return {String} + */ +getCallbackName : function ( +) +{ + return ; +}, + /** * @method getActionTag * @return {int} @@ -552,6 +560,16 @@ bool { }, +/** + * @method init + * @return {bool} + */ +init : function ( +) +{ + return false; +}, + /** * @method setEnabled * @param {bool} arg0 @@ -632,6 +650,18 @@ isBright : function ( return false; }, +/** + * @method dispatchFocusEvent + * @param {ccui.Widget} arg0 + * @param {ccui.Widget} arg1 + */ +dispatchFocusEvent : function ( +widget, +widget +) +{ +}, + /** * @method setUnifySizeEnabled * @param {bool} arg0 @@ -662,6 +692,18 @@ getCurrentFocusedWidget : function ( return ccui.Widget; }, +/** + * @method hitTest + * @param {vec2_object} arg0 + * @return {bool} + */ +hitTest : function ( +vec2 +) +{ + return false; +}, + /** * @method requestFocus */ @@ -713,17 +755,13 @@ getSizeType : function ( }, /** - * @method interceptTouchEvent - * @param {ccui.Widget::TouchEventType} arg0 - * @param {ccui.Widget} arg1 - * @param {cc.Touch} arg2 + * @method getCallbackType + * @return {String} */ -interceptTouchEvent : function ( -toucheventtype, -widget, -touch +getCallbackType : function ( ) { + return ; }, /** @@ -813,13 +851,15 @@ sizetype }, /** - * @method dispatchFocusEvent - * @param {ccui.Widget} arg0 + * @method interceptTouchEvent + * @param {ccui.Widget::TouchEventType} arg0 * @param {ccui.Widget} arg1 + * @param {cc.Touch} arg2 */ -dispatchFocusEvent : function ( +interceptTouchEvent : function ( +toucheventtype, widget, -widget +touch ) { }, @@ -834,6 +874,16 @@ bool { }, +/** + * @method setCallbackType + * @param {String} arg0 + */ +setCallbackType : function ( +str +) +{ +}, + /** * @method isSwallowTouches * @return {bool} @@ -4298,6 +4348,394 @@ RelativeBox : function ( }; +/** + * @class Scale9Sprite + */ +ccui.Scale9Sprite = { + +/** + * @method disableCascadeColor + */ +disableCascadeColor : function ( +) +{ +}, + +/** + * @method updateWithSprite +* @param {cc.Sprite|cc.Sprite} sprite +* @param {rect_object|rect_object} rect +* @param {bool|bool} bool +* @param {vec2_object|rect_object} vec2 +* @param {size_object} size +* @param {rect_object} rect +* @return {bool|bool} +*/ +updateWithSprite : function( +sprite, +rect, +bool, +vec2, +size, +rect +) +{ + return false; +}, + +/** + * @method isFlippedX + * @return {bool} + */ +isFlippedX : function ( +) +{ + return false; +}, + +/** + * @method setFlippedY + * @param {bool} arg0 + */ +setFlippedY : function ( +bool +) +{ +}, + +/** + * @method setFlippedX + * @param {bool} arg0 + */ +setFlippedX : function ( +bool +) +{ +}, + +/** + * @method setScale9Enabled + * @param {bool} arg0 + */ +setScale9Enabled : function ( +bool +) +{ +}, + +/** + * @method disableCascadeOpacity + */ +disableCascadeOpacity : function ( +) +{ +}, + +/** + * @method setInsetBottom + * @param {float} arg0 + */ +setInsetBottom : function ( +float +) +{ +}, + +/** + * @method initWithSpriteFrameName +* @param {String|String} str +* @param {rect_object} rect +* @return {bool|bool} +*/ +initWithSpriteFrameName : function( +str, +rect +) +{ + return false; +}, + +/** + * @method getSprite + * @return {cc.Sprite} + */ +getSprite : function ( +) +{ + return cc.Sprite; +}, + +/** + * @method setInsetTop + * @param {float} arg0 + */ +setInsetTop : function ( +float +) +{ +}, + +/** + * @method init +* @param {cc.Sprite|cc.Sprite|cc.Sprite} sprite +* @param {rect_object|rect_object|rect_object} rect +* @param {bool|rect_object|bool} bool +* @param {rect_object|vec2_object} rect +* @param {size_object} size +* @param {rect_object} rect +* @return {bool|bool|bool|bool} +*/ +init : function( +sprite, +rect, +bool, +vec2, +size, +rect +) +{ + return false; +}, + +/** + * @method setPreferredSize + * @param {size_object} arg0 + */ +setPreferredSize : function ( +size +) +{ +}, + +/** + * @method getInsetRight + * @return {float} + */ +getInsetRight : function ( +) +{ + return 0; +}, + +/** + * @method setSpriteFrame + * @param {cc.SpriteFrame} arg0 + * @param {rect_object} arg1 + */ +setSpriteFrame : function ( +spriteframe, +rect +) +{ +}, + +/** + * @method getInsetBottom + * @return {float} + */ +getInsetBottom : function ( +) +{ + return 0; +}, + +/** + * @method resizableSpriteWithCapInsets + * @param {rect_object} arg0 + * @return {ccui.Scale9Sprite} + */ +resizableSpriteWithCapInsets : function ( +rect +) +{ + return ccui.Scale9Sprite; +}, + +/** + * @method isScale9Enabled + * @return {bool} + */ +isScale9Enabled : function ( +) +{ + return false; +}, + +/** + * @method getCapInsets + * @return {rect_object} + */ +getCapInsets : function ( +) +{ + return cc.Rect; +}, + +/** + * @method getOriginalSize + * @return {size_object} + */ +getOriginalSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method initWithFile +* @param {String|String|rect_object|String} str +* @param {rect_object|rect_object|String} rect +* @param {rect_object} rect +* @return {bool|bool|bool|bool} +*/ +initWithFile : function( +str, +rect, +rect +) +{ + return false; +}, + +/** + * @method getInsetTop + * @return {float} + */ +getInsetTop : function ( +) +{ + return 0; +}, + +/** + * @method setInsetLeft + * @param {float} arg0 + */ +setInsetLeft : function ( +float +) +{ +}, + +/** + * @method initWithSpriteFrame +* @param {cc.SpriteFrame|cc.SpriteFrame} spriteframe +* @param {rect_object} rect +* @return {bool|bool} +*/ +initWithSpriteFrame : function( +spriteframe, +rect +) +{ + return false; +}, + +/** + * @method getPreferredSize + * @return {size_object} + */ +getPreferredSize : function ( +) +{ + return cc.Size; +}, + +/** + * @method setCapInsets + * @param {rect_object} arg0 + */ +setCapInsets : function ( +rect +) +{ +}, + +/** + * @method isFlippedY + * @return {bool} + */ +isFlippedY : function ( +) +{ + return false; +}, + +/** + * @method getInsetLeft + * @return {float} + */ +getInsetLeft : function ( +) +{ + return 0; +}, + +/** + * @method setInsetRight + * @param {float} arg0 + */ +setInsetRight : function ( +float +) +{ +}, + +/** + * @method create +* @param {String|rect_object|String|String} str +* @param {rect_object|String|rect_object} rect +* @param {rect_object} rect +* @return {ccui.Scale9Sprite|ccui.Scale9Sprite|ccui.Scale9Sprite|ccui.Scale9Sprite|ccui.Scale9Sprite} +*/ +create : function( +str, +rect, +rect +) +{ + return ccui.Scale9Sprite; +}, + +/** + * @method createWithSpriteFrameName +* @param {String|String} str +* @param {rect_object} rect +* @return {ccui.Scale9Sprite|ccui.Scale9Sprite} +*/ +createWithSpriteFrameName : function( +str, +rect +) +{ + return ccui.Scale9Sprite; +}, + +/** + * @method createWithSpriteFrame +* @param {cc.SpriteFrame|cc.SpriteFrame} spriteframe +* @param {rect_object} rect +* @return {ccui.Scale9Sprite|ccui.Scale9Sprite} +*/ +createWithSpriteFrame : function( +spriteframe, +rect +) +{ + return ccui.Scale9Sprite; +}, + +/** + * @method Scale9Sprite + * @constructor + */ +Scale9Sprite : function ( +) +{ +}, + +}; + /** * @class EditBox */ diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.cpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.cpp index 071119b872..b77e207551 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.cpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.cpp @@ -2277,15 +2277,22 @@ bool js_cocos2dx_Node_setOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp) if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=]() -> void { - jsval rval; - bool ok = func->invoke(0, nullptr, rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=]() -> void { + jsval rval; + bool ok = func->invoke(0, nullptr, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setOnExitCallback : Error processing arguments"); @@ -2297,21 +2304,6 @@ bool js_cocos2dx_Node_setOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Node_setOnExitCallback : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Node_pause(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_pause : Invalid Native Object"); - if (argc == 0) { - cobj->pause(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Node_pause : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_Node_convertToWorldSpaceAR(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -2542,15 +2534,22 @@ bool js_cocos2dx_Node_setonEnterTransitionDidFinishCallback(JSContext *cx, uint3 if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=]() -> void { - jsval rval; - bool ok = func->invoke(0, nullptr, rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=]() -> void { + jsval rval; + bool ok = func->invoke(0, nullptr, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setonEnterTransitionDidFinishCallback : Error processing arguments"); @@ -2896,15 +2895,22 @@ bool js_cocos2dx_Node_setOnEnterCallback(JSContext *cx, uint32_t argc, jsval *vp if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=]() -> void { - jsval rval; - bool ok = func->invoke(0, nullptr, rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=]() -> void { + jsval rval; + bool ok = func->invoke(0, nullptr, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setOnEnterCallback : Error processing arguments"); @@ -2947,15 +2953,22 @@ bool js_cocos2dx_Node_setonExitTransitionDidStartCallback(JSContext *cx, uint32_ if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=]() -> void { - jsval rval; - bool ok = func->invoke(0, nullptr, rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=]() -> void { + jsval rval; + bool ok = func->invoke(0, nullptr, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_setonExitTransitionDidStartCallback : Error processing arguments"); @@ -3140,21 +3153,6 @@ bool js_cocos2dx_Node_getName(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Node_getName : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Node_resume(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_resume : Invalid Native Object"); - if (argc == 0) { - cobj->resume(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Node_resume : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_Node_getRotation3D(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -4893,10 +4891,12 @@ bool js_cocos2dx_Node_enumerateChildren(JSContext *cx, uint32_t argc, jsval *vp) std::function arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::Node* larg0) -> bool { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::Node* larg0) -> bool { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Node*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -4904,16 +4904,21 @@ bool js_cocos2dx_Node_enumerateChildren(JSContext *cx, uint32_t argc, jsval *vp) largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - bool ret; - ret = JS::ToBoolean(JS::RootedValue(cx, rval)); - return ret; - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + bool ret; + ret = JS::ToBoolean(JS::RootedValue(cx, rval)); + return ret; + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Node_enumerateChildren : Error processing arguments"); @@ -5327,7 +5332,6 @@ void js_register_cocos2dx_Node(JSContext *cx, JSObject *global) { JS_FN("setCascadeOpacityEnabled", js_cocos2dx_Node_setCascadeOpacityEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getChildren", js_cocos2dx_Node_getChildren, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setOnExitCallback", js_cocos2dx_Node_setOnExitCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("pause", js_cocos2dx_Node_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToWorldSpaceAR", js_cocos2dx_Node_convertToWorldSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isIgnoreAnchorPointForPosition", js_cocos2dx_Node_isIgnoreAnchorPointForPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getChildByName", js_cocos2dx_Node_getChildByName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -5366,7 +5370,6 @@ void js_register_cocos2dx_Node(JSContext *cx, JSObject *global) { JS_FN("isCascadeOpacityEnabled", js_cocos2dx_Node_isCascadeOpacityEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setParent", js_cocos2dx_Node_setParent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_Node_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("resume", js_cocos2dx_Node_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRotation3D", js_cocos2dx_Node_getRotation3D, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getNodeToParentTransform", js_cocos2dx_Node_getNodeToParentTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertTouchToNodeSpaceAR", js_cocos2dx_Node_convertTouchToNodeSpaceAR, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -6583,48 +6586,24 @@ bool js_cocos2dx_Director_setEventDispatcher(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_Director_setEventDispatcher : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_pushScene : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_setContentScaleFactor : Invalid Native Object"); if (argc == 1) { - cocos2d::Scene* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_pushScene : Error processing arguments"); - cobj->pushScene(arg0); + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setContentScaleFactor : Error processing arguments"); + cobj->setContentScaleFactor(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_pushScene : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_Director_getDeltaTime(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_getDeltaTime : Invalid Native Object"); - if (argc == 0) { - double ret = cobj->getDeltaTime(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Director_getDeltaTime : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_Director_setContentScaleFactor : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_Director_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) @@ -6661,24 +6640,21 @@ bool js_cocos2dx_Director_getWinSizeInPixels(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_Director_getWinSizeInPixels : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Director_pushMatrix(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_getDeltaTime(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_pushMatrix : Invalid Native Object"); - if (argc == 1) { - cocos2d::MATRIX_STACK_TYPE arg0; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_pushMatrix : Error processing arguments"); - cobj->pushMatrix(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_getDeltaTime : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getDeltaTime(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_pushMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_Director_getDeltaTime : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Director_setGLDefaultValues(JSContext *cx, uint32_t argc, jsval *vp) @@ -6963,6 +6939,21 @@ bool js_cocos2dx_Director_getSecondsPerFrame(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_Director_getSecondsPerFrame : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Director_resetMatrixStack(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_resetMatrixStack : Invalid Native Object"); + if (argc == 0) { + cobj->resetMatrixStack(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_resetMatrixStack : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Director_convertToUI(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -6985,6 +6976,26 @@ bool js_cocos2dx_Director_convertToUI(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Director_convertToUI : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Director_pushMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_pushMatrix : Invalid Native Object"); + if (argc == 1) { + cocos2d::MATRIX_STACK_TYPE arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_pushMatrix : Error processing arguments"); + cobj->pushMatrix(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_pushMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Director_setDefaultValues(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -7044,6 +7055,28 @@ bool js_cocos2dx_Director_setScheduler(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Director_setScheduler : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Director_getMatrix(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_getMatrix : Invalid Native Object"); + if (argc == 1) { + cocos2d::MATRIX_STACK_TYPE arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_getMatrix : Error processing arguments"); + const cocos2d::Mat4& ret = cobj->getMatrix(arg0); + jsval jsret = JSVAL_NULL; + jsret = matrix_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Director_startAnimation(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -7137,26 +7170,6 @@ bool js_cocos2dx_Director_stopAnimation(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Director_stopAnimation : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Director_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_setContentScaleFactor : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setContentScaleFactor : Error processing arguments"); - cobj->setContentScaleFactor(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Director_setContentScaleFactor : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_Director_popToSceneStackLevel(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -7359,58 +7372,54 @@ bool js_cocos2dx_Director_drawScene(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Director_drawScene : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Director_getZEye(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_restart(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_getZEye : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_restart : Invalid Native Object"); if (argc == 0) { - double ret = cobj->getZEye(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); + cobj->restart(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_getZEye : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_Director_restart : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Director_getMatrix(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_popScene(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_getMatrix : Invalid Native Object"); - if (argc == 1) { - cocos2d::MATRIX_STACK_TYPE arg0; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_getMatrix : Error processing arguments"); - cocos2d::Mat4 ret = cobj->getMatrix(arg0); - jsval jsret = JSVAL_NULL; - jsret = matrix_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_popScene : Invalid Native Object"); + if (argc == 0) { + cobj->popScene(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_getMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_Director_popScene : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Director_popScene(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_loadIdentityMatrix(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_popScene : Invalid Native Object"); - if (argc == 0) { - cobj->popScene(); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_loadIdentityMatrix : Invalid Native Object"); + if (argc == 1) { + cocos2d::MATRIX_STACK_TYPE arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_loadIdentityMatrix : Error processing arguments"); + cobj->loadIdentityMatrix(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_popScene : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_Director_loadIdentityMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_Director_isDisplayStats(JSContext *cx, uint32_t argc, jsval *vp) @@ -7450,24 +7459,43 @@ bool js_cocos2dx_Director_setProjection(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Director_setProjection : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Director_loadIdentityMatrix(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_multiplyMatrix(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_loadIdentityMatrix : Invalid Native Object"); - if (argc == 1) { + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_multiplyMatrix : Invalid Native Object"); + if (argc == 2) { cocos2d::MATRIX_STACK_TYPE arg0; + cocos2d::Mat4 arg1; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_loadIdentityMatrix : Error processing arguments"); - cobj->loadIdentityMatrix(arg0); + ok &= jsval_to_matrix(cx, argv[1], &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_multiplyMatrix : Error processing arguments"); + cobj->multiplyMatrix(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_loadIdentityMatrix : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_Director_multiplyMatrix : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_Director_getZEye(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_getZEye : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getZEye(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Director_getZEye : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Director_setNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp) @@ -7490,21 +7518,6 @@ bool js_cocos2dx_Director_setNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsv JS_ReportError(cx, "js_cocos2dx_Director_setNextDeltaTimeZero : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Director_resetMatrixStack(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_resetMatrixStack : Invalid Native Object"); - if (argc == 0) { - cobj->resetMatrixStack(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Director_resetMatrixStack : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_Director_popMatrix(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -7566,24 +7579,31 @@ bool js_cocos2dx_Director_getScheduler(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Director_getScheduler : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Director_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_setAnimationInterval : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_pushScene : Invalid Native Object"); if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setAnimationInterval : Error processing arguments"); - cobj->setAnimationInterval(arg0); + cocos2d::Scene* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Scene*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_pushScene : Error processing arguments"); + cobj->pushScene(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_setAnimationInterval : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_Director_pushScene : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_Director_getAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) @@ -7691,26 +7711,24 @@ bool js_cocos2dx_Director_replaceScene(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Director_replaceScene : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Director_multiplyMatrix(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Director_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Director* cobj = (cocos2d::Director *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_multiplyMatrix : Invalid Native Object"); - if (argc == 2) { - cocos2d::MATRIX_STACK_TYPE arg0; - cocos2d::Mat4 arg1; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - ok &= jsval_to_matrix(cx, argv[1], &arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_multiplyMatrix : Error processing arguments"); - cobj->multiplyMatrix(arg0, arg1); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Director_setAnimationInterval : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Director_setAnimationInterval : Error processing arguments"); + cobj->setAnimationInterval(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_Director_multiplyMatrix : wrong number of arguments: %d, was expecting %d", argc, 2); + JS_ReportError(cx, "js_cocos2dx_Director_setAnimationInterval : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_Director_getActionManager(JSContext *cx, uint32_t argc, jsval *vp) @@ -7784,11 +7802,10 @@ void js_register_cocos2dx_Director(JSContext *cx, JSObject *global) { static JSFunctionSpec funcs[] = { JS_FN("pause", js_cocos2dx_Director_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEventDispatcher", js_cocos2dx_Director_setEventDispatcher, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("pushScene", js_cocos2dx_Director_pushScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getDeltaTime", js_cocos2dx_Director_getDeltaTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setContentScaleFactor", js_cocos2dx_Director_setContentScaleFactor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentScaleFactor", js_cocos2dx_Director_getContentScaleFactor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWinSizeInPixels", js_cocos2dx_Director_getWinSizeInPixels, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("pushMatrix", js_cocos2dx_Director_pushMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDeltaTime", js_cocos2dx_Director_getDeltaTime, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGLDefaultValues", js_cocos2dx_Director_setGLDefaultValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setActionManager", js_cocos2dx_Director_setActionManager, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlphaBlending", js_cocos2dx_Director_setAlphaBlending, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -7804,16 +7821,18 @@ void js_register_cocos2dx_Director(JSContext *cx, JSObject *global) { JS_FN("setDepthTest", js_cocos2dx_Director_setDepthTest, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFrameRate", js_cocos2dx_Director_getFrameRate, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSecondsPerFrame", js_cocos2dx_Director_getSecondsPerFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resetMatrixStack", js_cocos2dx_Director_resetMatrixStack, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("convertToUI", js_cocos2dx_Director_convertToUI, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pushMatrix", js_cocos2dx_Director_pushMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDefaultValues", js_cocos2dx_Director_setDefaultValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_Director_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScheduler", js_cocos2dx_Director_setScheduler, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMatrix", js_cocos2dx_Director_getMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("startAnimation", js_cocos2dx_Director_startAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOpenGLView", js_cocos2dx_Director_getOpenGLView, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRunningScene", js_cocos2dx_Director_getRunningScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setViewport", js_cocos2dx_Director_setViewport, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("stopAnimation", js_cocos2dx_Director_stopAnimation, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setContentScaleFactor", js_cocos2dx_Director_setContentScaleFactor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("popToSceneStackLevel", js_cocos2dx_Director_popToSceneStackLevel, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("resume", js_cocos2dx_Director_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isNextDeltaTimeZero", js_cocos2dx_Director_isNextDeltaTimeZero, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -7824,24 +7843,24 @@ void js_register_cocos2dx_Director(JSContext *cx, JSObject *global) { JS_FN("runWithScene", js_cocos2dx_Director_runWithScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNotificationNode", js_cocos2dx_Director_setNotificationNode, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawScene", js_cocos2dx_Director_drawScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getZEye", js_cocos2dx_Director_getZEye, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getMatrix", js_cocos2dx_Director_getMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("restart", js_cocos2dx_Director_restart, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("popScene", js_cocos2dx_Director_popScene, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("loadIdentityMatrix", js_cocos2dx_Director_loadIdentityMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isDisplayStats", js_cocos2dx_Director_isDisplayStats, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setProjection", js_cocos2dx_Director_setProjection, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadIdentityMatrix", js_cocos2dx_Director_loadIdentityMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("multiplyMatrix", js_cocos2dx_Director_multiplyMatrix, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getZEye", js_cocos2dx_Director_getZEye, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setNextDeltaTimeZero", js_cocos2dx_Director_setNextDeltaTimeZero, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("resetMatrixStack", js_cocos2dx_Director_resetMatrixStack, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("popMatrix", js_cocos2dx_Director_popMatrix, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVisibleSize", js_cocos2dx_Director_getVisibleSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getScheduler", js_cocos2dx_Director_getScheduler, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setAnimationInterval", js_cocos2dx_Director_setAnimationInterval, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pushScene", js_cocos2dx_Director_pushScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAnimationInterval", js_cocos2dx_Director_getAnimationInterval, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPaused", js_cocos2dx_Director_isPaused, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDisplayStats", js_cocos2dx_Director_setDisplayStats, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getEventDispatcher", js_cocos2dx_Director_getEventDispatcher, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("replaceScene", js_cocos2dx_Director_replaceScene, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("multiplyMatrix", js_cocos2dx_Director_multiplyMatrix, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAnimationInterval", js_cocos2dx_Director_setAnimationInterval, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionManager", js_cocos2dx_Director_getActionManager, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -7913,15 +7932,22 @@ bool js_cocos2dx_Scheduler_performFunctionInCocosThread(JSContext *cx, uint32_t if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=]() -> void { - jsval rval; - bool ok = func->invoke(0, nullptr, rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=]() -> void { + jsval rval; + bool ok = func->invoke(0, nullptr, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Scheduler_performFunctionInCocosThread : Error processing arguments"); @@ -8940,10 +8966,12 @@ bool js_cocos2dx_EventDispatcher_addCustomEventListener(JSContext *cx, uint32_t std::function arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::EventCustom* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::EventCustom* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventCustom*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -8951,13 +8979,18 @@ bool js_cocos2dx_EventDispatcher_addCustomEventListener(JSContext *cx, uint32_t largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventDispatcher_addCustomEventListener : Error processing arguments"); @@ -10317,11 +10350,13 @@ bool js_cocos2dx_EventListenerAcceleration_init(JSContext *cx, uint32_t argc, js if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { - jsval largv[2]; - largv[0] = ccacceleration_to_jsval(cx, *larg0); - do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { + jsval largv[2]; + largv[0] = ccacceleration_to_jsval(cx, *larg0); + do { if (larg1) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Event*)larg1); largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -10329,13 +10364,18 @@ bool js_cocos2dx_EventListenerAcceleration_init(JSContext *cx, uint32_t argc, js largv[1] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(2, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventListenerAcceleration_init : Error processing arguments"); @@ -10356,11 +10396,13 @@ bool js_cocos2dx_EventListenerAcceleration_create(JSContext *cx, uint32_t argc, if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { - jsval largv[2]; - largv[0] = ccacceleration_to_jsval(cx, *larg0); - do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](cocos2d::Acceleration* larg0, cocos2d::Event* larg1) -> void { + jsval largv[2]; + largv[0] = ccacceleration_to_jsval(cx, *larg0); + do { if (larg1) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Event*)larg1); largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -10368,13 +10410,18 @@ bool js_cocos2dx_EventListenerAcceleration_create(JSContext *cx, uint32_t argc, largv[1] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(2, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventListenerAcceleration_create : Error processing arguments"); @@ -10605,10 +10652,12 @@ bool js_cocos2dx_EventListenerCustom_create(JSContext *cx, uint32_t argc, jsval std::function arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::EventCustom* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::EventCustom* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::EventCustom*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -10616,13 +10665,18 @@ bool js_cocos2dx_EventListenerCustom_create(JSContext *cx, uint32_t argc, jsval largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventListenerCustom_create : Error processing arguments"); @@ -11680,6 +11734,26 @@ void js_register_cocos2dx_Speed(JSContext *cx, JSObject *global) { JSClass *jsb_cocos2d_Follow_class; JSObject *jsb_cocos2d_Follow_prototype; +bool js_cocos2dx_Follow_setBoundarySet(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Follow* cobj = (cocos2d::Follow *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Follow_setBoundarySet : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Follow_setBoundarySet : Error processing arguments"); + cobj->setBoundarySet(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Follow_setBoundarySet : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Follow_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -11728,26 +11802,6 @@ bool js_cocos2dx_Follow_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Follow_initWithTarget : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Follow_setBoudarySet(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Follow* cobj = (cocos2d::Follow *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Follow_setBoudarySet : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Follow_setBoudarySet : Error processing arguments"); - cobj->setBoudarySet(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Follow_setBoudarySet : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_Follow_isBoundarySet(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -11875,8 +11929,8 @@ void js_register_cocos2dx_Follow(JSContext *cx, JSObject *global) { }; static JSFunctionSpec funcs[] = { + JS_FN("setBoundarySet", js_cocos2dx_Follow_setBoundarySet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTarget", js_cocos2dx_Follow_initWithTarget, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setBoudarySet", js_cocos2dx_Follow_setBoudarySet, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBoundarySet", js_cocos2dx_Follow_isBoundarySet, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -30898,6 +30952,847 @@ void js_register_cocos2dx_ProtectedNode(JSContext *cx, JSObject *global) { } } +JSClass *jsb_cocos2d_GLProgramState_class; +JSObject *jsb_cocos2d_GLProgramState_prototype; + +bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::GLProgramState* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformTexture : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + unsigned int arg1; + ok &= jsval_to_uint32(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformTexture(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!argv[1].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->setUniformTexture(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Texture2D* arg1; + do { + if (!argv[1].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cobj->setUniformTexture(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + unsigned int arg1; + ok &= jsval_to_uint32(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformTexture(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformTexture : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformMat4(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::GLProgramState* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformMat4 : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Mat4 arg1; + ok &= jsval_to_matrix(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformMat4(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Mat4 arg1; + ok &= jsval_to_matrix(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformMat4(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformMat4 : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_applyUniforms(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_applyUniforms : Invalid Native Object"); + if (argc == 0) { + cobj->applyUniforms(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_applyUniforms : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::GLProgramState* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformCallback : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + std::function arg1; + do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLProgram*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + do { + if (larg1) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Uniform*)larg1); + largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[1] = JSVAL_NULL; + } + } while (0); + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } + } while(0) + ; + if (!ok) { ok = true; break; } + cobj->setUniformCallback(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + std::function arg1; + do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::GLProgram* larg0, cocos2d::Uniform* larg1) -> void { + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLProgram*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + do { + if (larg1) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Uniform*)larg1); + largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[1] = JSVAL_NULL; + } + } while (0); + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } + } while(0) + ; + if (!ok) { ok = true; break; } + cobj->setUniformCallback(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformCallback : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_applyGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_applyGLProgram : Invalid Native Object"); + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_applyGLProgram : Error processing arguments"); + cobj->applyGLProgram(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_applyGLProgram : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgramState_getUniformCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_getUniformCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getUniformCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getUniformCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramState_applyAttributes(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_applyAttributes : Invalid Native Object"); + if (argc == 0) { + cobj->applyAttributes(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_applyAttributes : Error processing arguments"); + cobj->applyAttributes(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_applyAttributes : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformFloat(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::GLProgramState* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformFloat : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformFloat(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + double arg1; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformFloat(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformFloat : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformVec3(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::GLProgramState* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec3 : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec3(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec3 arg1; + ok &= jsval_to_vector3(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec3(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformVec3 : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformInt(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::GLProgramState* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformInt : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->setUniformInt(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + int arg1; + ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); + if (!ok) { ok = true; break; } + cobj->setUniformInt(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformInt : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_getVertexAttribCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_getVertexAttribCount : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getVertexAttribCount(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getVertexAttribCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramState_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setGLProgram : Invalid Native Object"); + if (argc == 1) { + cocos2d::GLProgram* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_setGLProgram : Error processing arguments"); + cobj->setGLProgram(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setGLProgram : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgramState_setUniformVec2(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::GLProgramState* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setUniformVec2 : Invalid Native Object"); + do { + if (argc == 2) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec2(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Vec2 arg1; + ok &= jsval_to_vector2(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cobj->setUniformVec2(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setUniformVec2 : wrong number of arguments"); + return false; +} +bool js_cocos2dx_GLProgramState_getVertexAttribsFlags(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_getVertexAttribsFlags : Invalid Native Object"); + if (argc == 0) { + unsigned int ret = cobj->getVertexAttribsFlags(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getVertexAttribsFlags : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramState_setVertexAttribCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setVertexAttribCallback : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::function arg1; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::VertexAttrib* larg0) -> void { + jsval largv[1]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::VertexAttrib*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_setVertexAttribCallback : Error processing arguments"); + cobj->setVertexAttribCallback(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setVertexAttribCallback : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} +bool js_cocos2dx_GLProgramState_apply(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_apply : Invalid Native Object"); + if (argc == 1) { + cocos2d::Mat4 arg0; + ok &= jsval_to_matrix(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_apply : Error processing arguments"); + cobj->apply(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_apply : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_GLProgramState_setVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_setVertexAttribPointer : Invalid Native Object"); + if (argc == 6) { + std::string arg0; + int arg1; + unsigned int arg2; + uint16_t arg3; + int arg4; + void* arg5; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); + ok &= jsval_to_uint32(cx, argv[2], &arg2); + ok &= jsval_to_uint16(cx, argv[3], &arg3); + ok &= jsval_to_int32(cx, argv[4], (int32_t *)&arg4); + #pragma warning NO CONVERSION TO NATIVE FOR void* + ok = false; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_setVertexAttribPointer : Error processing arguments"); + cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, arg5); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_setVertexAttribPointer : wrong number of arguments: %d, was expecting %d", argc, 6); + return false; +} +bool js_cocos2dx_GLProgramState_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgramState* cobj = (cocos2d::GLProgramState *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgramState_getGLProgram : Invalid Native Object"); + if (argc == 0) { + cocos2d::GLProgram* ret = cobj->getGLProgram(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLProgram*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getGLProgram : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_GLProgramState_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + if (argc == 1) { + cocos2d::GLProgram* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_create : Error processing arguments"); + cocos2d::GLProgramState* ret = cocos2d::GLProgramState::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLProgramState*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLProgramState_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_GLProgramState_getOrCreateWithGLProgramName(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_getOrCreateWithGLProgramName : Error processing arguments"); + cocos2d::GLProgramState* ret = cocos2d::GLProgramState::getOrCreateWithGLProgramName(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLProgramState*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getOrCreateWithGLProgramName : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_GLProgramState_getOrCreateWithGLProgram(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + if (argc == 1) { + cocos2d::GLProgram* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::GLProgram*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgramState_getOrCreateWithGLProgram : Error processing arguments"); + cocos2d::GLProgramState* ret = cocos2d::GLProgramState::getOrCreateWithGLProgram(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::GLProgramState*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_GLProgramState_getOrCreateWithGLProgram : wrong number of arguments"); + return false; +} + + + +void js_cocos2d_GLProgramState_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (GLProgramState)", obj); +} + +void js_register_cocos2dx_GLProgramState(JSContext *cx, JSObject *global) { + jsb_cocos2d_GLProgramState_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_GLProgramState_class->name = "GLProgramState"; + jsb_cocos2d_GLProgramState_class->addProperty = JS_PropertyStub; + jsb_cocos2d_GLProgramState_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_GLProgramState_class->getProperty = JS_PropertyStub; + jsb_cocos2d_GLProgramState_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_GLProgramState_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_GLProgramState_class->resolve = JS_ResolveStub; + jsb_cocos2d_GLProgramState_class->convert = JS_ConvertStub; + jsb_cocos2d_GLProgramState_class->finalize = js_cocos2d_GLProgramState_finalize; + jsb_cocos2d_GLProgramState_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, + {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} + }; + + static JSFunctionSpec funcs[] = { + JS_FN("setUniformTexture", js_cocos2dx_GLProgramState_setUniformTexture, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformMat4", js_cocos2dx_GLProgramState_setUniformMat4, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("applyUniforms", js_cocos2dx_GLProgramState_applyUniforms, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformCallback", js_cocos2dx_GLProgramState_setUniformCallback, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("applyGLProgram", js_cocos2dx_GLProgramState_applyGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getUniformCount", js_cocos2dx_GLProgramState_getUniformCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("applyAttributes", js_cocos2dx_GLProgramState_applyAttributes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformFloat", js_cocos2dx_GLProgramState_setUniformFloat, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformVec3", js_cocos2dx_GLProgramState_setUniformVec3, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformInt", js_cocos2dx_GLProgramState_setUniformInt, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertexAttribCount", js_cocos2dx_GLProgramState_getVertexAttribCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGLProgram", js_cocos2dx_GLProgramState_setGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformVec2", js_cocos2dx_GLProgramState_setUniformVec2, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertexAttribsFlags", js_cocos2dx_GLProgramState_getVertexAttribsFlags, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVertexAttribCallback", js_cocos2dx_GLProgramState_setVertexAttribCallback, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("apply", js_cocos2dx_GLProgramState_apply, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setVertexAttribPointer", js_cocos2dx_GLProgramState_setVertexAttribPointer, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGLProgram", js_cocos2dx_GLProgramState_getGLProgram, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_GLProgramState_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOrCreateWithGLProgramName", js_cocos2dx_GLProgramState_getOrCreateWithGLProgramName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOrCreateWithGLProgram", js_cocos2dx_GLProgramState_getOrCreateWithGLProgram, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_GLProgramState_prototype = JS_InitClass( + cx, global, + NULL, // parent proto + jsb_cocos2d_GLProgramState_class, + dummy_constructor, 0, // no constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "GLProgramState", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_GLProgramState_class; + p->proto = jsb_cocos2d_GLProgramState_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + JSClass *jsb_cocos2d_AtlasNode_class; JSObject *jsb_cocos2d_AtlasNode_prototype; @@ -32380,6 +33275,22 @@ void js_cocos2d_LabelAtlas_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LabelAtlas)", obj); } +static bool js_cocos2d_LabelAtlas_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + cocos2d::LabelAtlas *nobj = new (std::nothrow) cocos2d::LabelAtlas(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelAtlas"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; +} void js_register_cocos2dx_LabelAtlas(JSContext *cx, JSObject *global) { jsb_cocos2d_LabelAtlas_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LabelAtlas_class->name = "LabelAtlas"; @@ -32403,6 +33314,7 @@ void js_register_cocos2dx_LabelAtlas(JSContext *cx, JSObject *global) { JS_FN("initWithString", js_cocos2dx_LabelAtlas_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateAtlasValues", js_cocos2dx_LabelAtlas_updateAtlasValues, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_LabelAtlas_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_LabelAtlas_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -33237,6 +34149,22 @@ void js_cocos2d_LabelTTF_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LabelTTF)", obj); } +static bool js_cocos2d_LabelTTF_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + cocos2d::LabelTTF *nobj = new (std::nothrow) cocos2d::LabelTTF(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelTTF"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; +} void js_register_cocos2dx_LabelTTF(JSContext *cx, JSObject *global) { jsb_cocos2d_LabelTTF_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LabelTTF_class->name = "LabelTTF"; @@ -33281,6 +34209,7 @@ void js_register_cocos2dx_LabelTTF(JSContext *cx, JSObject *global) { JS_FN("setHorizontalAlignment", js_cocos2dx_LabelTTF_setHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("disableShadow", js_cocos2dx_LabelTTF_disableShadow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("disableStroke", js_cocos2dx_LabelTTF_disableStroke, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_LabelTTF_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -35318,6 +36247,22 @@ void js_cocos2d_Label_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (Label)", obj); } +static bool js_cocos2d_Label_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + cocos2d::Label *nobj = new (std::nothrow) cocos2d::Label(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::Label"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; +} void js_register_cocos2dx_Label(JSContext *cx, JSObject *global) { jsb_cocos2d_Label_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_Label_class->name = "Label"; @@ -35379,6 +36324,7 @@ void js_register_cocos2dx_Label(JSContext *cx, JSObject *global) { JS_FN("setHorizontalAlignment", js_cocos2dx_Label_setHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlignment", js_cocos2dx_Label_setAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestSystemFontRefresh", js_cocos2dx_Label_requestSystemFontRefresh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_Label_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -35904,6 +36850,22 @@ void js_cocos2d_LabelBMFont_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (LabelBMFont)", obj); } +static bool js_cocos2d_LabelBMFont_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + cocos2d::LabelBMFont *nobj = new (std::nothrow) cocos2d::LabelBMFont(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::LabelBMFont"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; +} void js_register_cocos2dx_LabelBMFont(JSContext *cx, JSObject *global) { jsb_cocos2d_LabelBMFont_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_LabelBMFont_class->name = "LabelBMFont"; @@ -35936,6 +36898,7 @@ void js_register_cocos2dx_LabelBMFont(JSContext *cx, JSObject *global) { JS_FN("setFntFile", js_cocos2dx_LabelBMFont_setFntFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlignment", js_cocos2dx_LabelBMFont_setAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setWidth", js_cocos2dx_LabelBMFont_setWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_LabelBMFont_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -42797,10 +43760,12 @@ bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval * if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -42808,13 +43773,18 @@ bool js_cocos2dx_MenuItem_initWithCallback(JSContext *cx, uint32_t argc, jsval * largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItem_initWithCallback : Error processing arguments"); @@ -43106,10 +44076,12 @@ bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); } while (0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -43117,13 +44089,18 @@ bool js_cocos2dx_MenuItemLabel_initWithLabel(JSContext *cx, uint32_t argc, jsval largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemLabel_initWithLabel : Error processing arguments"); @@ -43313,10 +44290,12 @@ bool js_cocos2dx_MenuItemAtlasFont_initWithString(JSContext *cx, uint32_t argc, ok &= jsval_to_int32(cx, argv[3], (int32_t *)&arg3); ok &= jsval_to_int32(cx, argv[4], &arg4); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[5])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[5]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[5])); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -43324,13 +44303,18 @@ bool js_cocos2dx_MenuItemAtlasFont_initWithString(JSContext *cx, uint32_t argc, largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg5 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg5 = lambda; + } + else + { + arg5 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemAtlasFont_initWithString : Error processing arguments"); @@ -43520,10 +44504,12 @@ bool js_cocos2dx_MenuItemFont_initWithString(JSContext *cx, uint32_t argc, jsval std::function arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -43531,13 +44517,18 @@ bool js_cocos2dx_MenuItemFont_initWithString(JSContext *cx, uint32_t argc, jsval largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemFont_initWithString : Error processing arguments"); @@ -43869,10 +44860,12 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); } while (0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[3])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[3]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[3])); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -43880,13 +44873,18 @@ bool js_cocos2dx_MenuItemSprite_initWithNormalSprite(JSContext *cx, uint32_t arg largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg3 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg3 = lambda; + } + else + { + arg3 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemSprite_initWithNormalSprite : Error processing arguments"); @@ -44244,10 +45242,12 @@ bool js_cocos2dx_MenuItemImage_initWithNormalImage(JSContext *cx, uint32_t argc, ok &= jsval_to_std_string(cx, argv[1], &arg1); ok &= jsval_to_std_string(cx, argv[2], &arg2); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[3])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[3]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[3])); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -44255,13 +45255,18 @@ bool js_cocos2dx_MenuItemImage_initWithNormalImage(JSContext *cx, uint32_t argc, largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg3 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg3 = lambda; + } + else + { + arg3 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_MenuItemImage_initWithNormalImage : Error processing arguments"); @@ -44892,21 +45897,21 @@ void js_register_cocos2dx_Menu(JSContext *cx, JSObject *global) { JSClass *jsb_cocos2d_ClippingNode_class; JSObject *jsb_cocos2d_ClippingNode_prototype; -bool js_cocos2dx_ClippingNode_isInverted(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ClippingNode_hasContent(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ClippingNode_isInverted : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ClippingNode_hasContent : Invalid Native Object"); if (argc == 0) { - bool ret = cobj->isInverted(); + bool ret = cobj->hasContent(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_ClippingNode_isInverted : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_ClippingNode_hasContent : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_ClippingNode_setInverted(JSContext *cx, uint32_t argc, jsval *vp) @@ -45061,6 +46066,23 @@ bool js_cocos2dx_ClippingNode_setAlphaThreshold(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_ClippingNode_setAlphaThreshold : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ClippingNode_isInverted(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ClippingNode* cobj = (cocos2d::ClippingNode *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ClippingNode_isInverted : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isInverted(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ClippingNode_isInverted : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ClippingNode_create(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -45164,13 +46186,14 @@ void js_register_cocos2dx_ClippingNode(JSContext *cx, JSObject *global) { }; static JSFunctionSpec funcs[] = { - JS_FN("isInverted", js_cocos2dx_ClippingNode_isInverted, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasContent", js_cocos2dx_ClippingNode_hasContent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setInverted", js_cocos2dx_ClippingNode_setInverted, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setStencil", js_cocos2dx_ClippingNode_setStencil, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAlphaThreshold", js_cocos2dx_ClippingNode_getAlphaThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_ClippingNode_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStencil", js_cocos2dx_ClippingNode_getStencil, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlphaThreshold", js_cocos2dx_ClippingNode_setAlphaThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isInverted", js_cocos2dx_ClippingNode_isInverted, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -54663,31 +55686,6 @@ bool js_cocos2dx_GLProgram_getFragmentShaderLog(JSContext *cx, uint32_t argc, js JS_ReportError(cx, "js_cocos2dx_GLProgram_getFragmentShaderLog : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv : Invalid Native Object"); - if (argc == 3) { - int arg0; - const float* arg1; - unsigned int arg2; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - #pragma warning NO CONVERSION TO NATIVE FOR float* - ok = false; - ok &= jsval_to_uint32(cx, argv[2], &arg2); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv : Error processing arguments"); - cobj->setUniformLocationWithMatrix2fv(arg0, arg1, arg2); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv : wrong number of arguments: %d, was expecting %d", argc, 3); - return false; -} bool js_cocos2dx_GLProgram_bindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -54710,31 +55708,6 @@ bool js_cocos2dx_GLProgram_bindAttribLocation(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_GLProgram_bindAttribLocation : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } -bool js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv : Invalid Native Object"); - if (argc == 3) { - int arg0; - const float* arg1; - unsigned int arg2; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - #pragma warning NO CONVERSION TO NATIVE FOR float* - ok = false; - ok &= jsval_to_uint32(cx, argv[2], &arg2); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv : Error processing arguments"); - cobj->setUniformLocationWithMatrix4fv(arg0, arg1, arg2); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv : wrong number of arguments: %d, was expecting %d", argc, 3); - return false; -} bool js_cocos2dx_GLProgram_getUniformLocationForName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -54835,6 +55808,28 @@ bool js_cocos2dx_GLProgram_initWithByteArrays(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_GLProgram_initWithByteArrays : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } +bool js_cocos2dx_GLProgram_setUniformLocationWith1f(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith1f : Invalid Native Object"); + if (argc == 2) { + int arg0; + double arg1; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith1f : Error processing arguments"); + cobj->setUniformLocationWith1f(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith1f : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} bool js_cocos2dx_GLProgram_initWithFilenames(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -54859,6 +55854,32 @@ bool js_cocos2dx_GLProgram_initWithFilenames(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_GLProgram_initWithFilenames : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } +bool js_cocos2dx_GLProgram_setUniformLocationWith3f(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith3f : Invalid Native Object"); + if (argc == 4) { + int arg0; + double arg1; + double arg2; + double arg3; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &arg1); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &arg2); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[3]), &arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith3f : Error processing arguments"); + cobj->setUniformLocationWith3f(arg0, arg1, arg2, arg3); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith3f : wrong number of arguments: %d, was expecting %d", argc, 4); + return false; +} bool js_cocos2dx_GLProgram_setUniformsForBuiltins(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -54918,29 +55939,32 @@ bool js_cocos2dx_GLProgram_setUniformLocationWith3i(JSContext *cx, uint32_t argc JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith3i : wrong number of arguments: %d, was expecting %d", argc, 4); return false; } -bool js_cocos2dx_GLProgram_setUniformLocationWith3iv(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_GLProgram_setUniformLocationWith4f(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith3iv : Invalid Native Object"); - if (argc == 3) { + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith4f : Invalid Native Object"); + if (argc == 5) { int arg0; - int* arg1; - unsigned int arg2; + double arg1; + double arg2; + double arg3; + double arg4; ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - #pragma warning NO CONVERSION TO NATIVE FOR int* - ok = false; - ok &= jsval_to_uint32(cx, argv[2], &arg2); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith3iv : Error processing arguments"); - cobj->setUniformLocationWith3iv(arg0, arg1, arg2); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &arg1); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &arg2); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[3]), &arg3); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[4]), &arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith4f : Error processing arguments"); + cobj->setUniformLocationWith4f(arg0, arg1, arg2, arg3, arg4); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith3iv : wrong number of arguments: %d, was expecting %d", argc, 3); + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith4f : wrong number of arguments: %d, was expecting %d", argc, 5); return false; } bool js_cocos2dx_GLProgram_updateUniforms(JSContext *cx, uint32_t argc, jsval *vp) @@ -54958,31 +55982,6 @@ bool js_cocos2dx_GLProgram_updateUniforms(JSContext *cx, uint32_t argc, jsval *v JS_ReportError(cx, "js_cocos2dx_GLProgram_updateUniforms : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_GLProgram_setUniformLocationWith4iv(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith4iv : Invalid Native Object"); - if (argc == 3) { - int arg0; - int* arg1; - unsigned int arg2; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - #pragma warning NO CONVERSION TO NATIVE FOR int* - ok = false; - ok &= jsval_to_uint32(cx, argv[2], &arg2); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith4iv : Error processing arguments"); - cobj->setUniformLocationWith4iv(arg0, arg1, arg2); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith4iv : wrong number of arguments: %d, was expecting %d", argc, 3); - return false; -} bool js_cocos2dx_GLProgram_getUniformLocation(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -55022,56 +56021,6 @@ bool js_cocos2dx_GLProgram_link(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_GLProgram_link : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_GLProgram_setUniformLocationWith2iv(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith2iv : Invalid Native Object"); - if (argc == 3) { - int arg0; - int* arg1; - unsigned int arg2; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - #pragma warning NO CONVERSION TO NATIVE FOR int* - ok = false; - ok &= jsval_to_uint32(cx, argv[2], &arg2); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith2iv : Error processing arguments"); - cobj->setUniformLocationWith2iv(arg0, arg1, arg2); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith2iv : wrong number of arguments: %d, was expecting %d", argc, 3); - return false; -} -bool js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv : Invalid Native Object"); - if (argc == 3) { - int arg0; - const float* arg1; - unsigned int arg2; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - #pragma warning NO CONVERSION TO NATIVE FOR float* - ok = false; - ok &= jsval_to_uint32(cx, argv[2], &arg2); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv : Error processing arguments"); - cobj->setUniformLocationWithMatrix3fv(arg0, arg1, arg2); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv : wrong number of arguments: %d, was expecting %d", argc, 3); - return false; -} bool js_cocos2dx_GLProgram_reset(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -55131,6 +56080,30 @@ bool js_cocos2dx_GLProgram_getVertexAttrib(JSContext *cx, uint32_t argc, jsval * JS_ReportError(cx, "js_cocos2dx_GLProgram_getVertexAttrib : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_GLProgram_setUniformLocationWith2f(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::GLProgram* cobj = (cocos2d::GLProgram *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith2f : Invalid Native Object"); + if (argc == 3) { + int arg0; + double arg1; + double arg2; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[1]), &arg1); + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_GLProgram_setUniformLocationWith2f : Error processing arguments"); + cobj->setUniformLocationWith2f(arg0, arg1, arg2); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_GLProgram_setUniformLocationWith2f : wrong number of arguments: %d, was expecting %d", argc, 3); + return false; +} bool js_cocos2dx_GLProgram_setUniformLocationWith4i(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -55311,27 +56284,25 @@ void js_register_cocos2dx_GLProgram(JSContext *cx, JSObject *global) { static JSFunctionSpec funcs[] = { JS_FN("getFragmentShaderLog", js_cocos2dx_GLProgram_getFragmentShaderLog, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setUniformLocationWithMatrix2fv", js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addAttribute", js_cocos2dx_GLProgram_bindAttribLocation, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setUniformLocationWithMatrix4fv", js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUniformLocationForName", js_cocos2dx_GLProgram_getUniformLocationForName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("use", js_cocos2dx_GLProgram_use, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVertexShaderLog", js_cocos2dx_GLProgram_getVertexShaderLog, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUniform", js_cocos2dx_GLProgram_getUniform, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithString", js_cocos2dx_GLProgram_initWithByteArrays, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformLocationWith1f", js_cocos2dx_GLProgram_setUniformLocationWith1f, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_GLProgram_initWithFilenames, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformLocationWith3f", js_cocos2dx_GLProgram_setUniformLocationWith3f, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformsForBuiltins", js_cocos2dx_GLProgram_setUniformsForBuiltins, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith3i", js_cocos2dx_GLProgram_setUniformLocationWith3i, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setUniformLocationWith3iv", js_cocos2dx_GLProgram_setUniformLocationWith3iv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformLocationWith4f", js_cocos2dx_GLProgram_setUniformLocationWith4f, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateUniforms", js_cocos2dx_GLProgram_updateUniforms, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setUniformLocationWith4iv", js_cocos2dx_GLProgram_setUniformLocationWith4iv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUniformLocation", js_cocos2dx_GLProgram_getUniformLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("link", js_cocos2dx_GLProgram_link, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setUniformLocationWith2iv", js_cocos2dx_GLProgram_setUniformLocationWith2iv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setUniformLocationWithMatrix3fv", js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("reset", js_cocos2dx_GLProgram_reset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAttribLocation", js_cocos2dx_GLProgram_getAttribLocation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVertexAttrib", js_cocos2dx_GLProgram_getVertexAttrib, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setUniformLocationWith2f", js_cocos2dx_GLProgram_setUniformLocationWith2f, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith4i", js_cocos2dx_GLProgram_setUniformLocationWith4i, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationI32", js_cocos2dx_GLProgram_setUniformLocationWith1i, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUniformLocationWith2i", js_cocos2dx_GLProgram_setUniformLocationWith2i, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -55674,10 +56645,12 @@ bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval std::function arg1; ok &= jsval_to_std_string(cx, argv[0], &arg0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::Texture2D* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::Texture2D* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -55685,13 +56658,18 @@ bool js_cocos2dx_TextureCache_addImageAsync(JSContext *cx, uint32_t argc, jsval largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextureCache_addImageAsync : Error processing arguments"); @@ -61793,6 +62771,7 @@ void register_all_cocos2dx(JSContext* cx, JSObject* obj) { js_register_cocos2dx_Grid3DAction(cx, obj); js_register_cocos2dx_FadeTo(cx, obj); js_register_cocos2dx_FadeIn(cx, obj); + js_register_cocos2dx_GLProgramState(cx, obj); js_register_cocos2dx_EventListenerCustom(cx, obj); js_register_cocos2dx_FlipX3D(cx, obj); js_register_cocos2dx_FlipY3D(cx, obj); diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.hpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.hpp index eee8f8795f..cff62c093f 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.hpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_auto.hpp @@ -140,7 +140,6 @@ bool js_cocos2dx_Node_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *v bool js_cocos2dx_Node_setCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getChildren(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setOnExitCallback(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_pause(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_convertToWorldSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_isIgnoreAnchorPointForPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getChildByName(JSContext *cx, uint32_t argc, jsval *vp); @@ -179,7 +178,6 @@ bool js_cocos2dx_Node_getNodeToParentAffineTransform(JSContext *cx, uint32_t arg bool js_cocos2dx_Node_isCascadeOpacityEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_setParent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Node_resume(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getRotation3D(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_getNodeToParentTransform(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Node_convertTouchToNodeSpaceAR(JSContext *cx, uint32_t argc, jsval *vp); @@ -347,11 +345,10 @@ void js_register_cocos2dx_Director(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); bool js_cocos2dx_Director_pause(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_getDeltaTime(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getWinSizeInPixels(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_pushMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_getDeltaTime(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setGLDefaultValues(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setActionManager(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setAlphaBlending(JSContext *cx, uint32_t argc, jsval *vp); @@ -367,16 +364,18 @@ bool js_cocos2dx_Director_mainLoop(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setDepthTest(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getFrameRate(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getSecondsPerFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_resetMatrixStack(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_convertToUI(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_pushMatrix(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setDefaultValues(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setScheduler(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_getMatrix(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_startAnimation(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getOpenGLView(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getRunningScene(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setViewport(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_stopAnimation(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_setContentScaleFactor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_popToSceneStackLevel(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_resume(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_isNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp); @@ -387,24 +386,24 @@ bool js_cocos2dx_Director_getTotalFrames(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_Director_runWithScene(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setNotificationNode(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_drawScene(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_getZEye(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_getMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_restart(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_popScene(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_loadIdentityMatrix(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_isDisplayStats(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setProjection(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_loadIdentityMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_multiplyMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_getZEye(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setNextDeltaTimeZero(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_resetMatrixStack(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_popMatrix(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getVisibleSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getScheduler(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_pushScene(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_isPaused(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_setDisplayStats(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getEventDispatcher(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_replaceScene(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Director_multiplyMatrix(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Director_setAnimationInterval(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getActionManager(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Director_getInstance(JSContext *cx, uint32_t argc, jsval *vp); @@ -668,8 +667,8 @@ bool js_cocos2dx_Follow_constructor(JSContext *cx, uint32_t argc, jsval *vp); void js_cocos2dx_Follow_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_Follow(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); +bool js_cocos2dx_Follow_setBoundarySet(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Follow_initWithTarget(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Follow_setBoudarySet(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Follow_isBoundarySet(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Follow_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Follow_Follow(JSContext *cx, uint32_t argc, jsval *vp); @@ -2000,6 +1999,35 @@ bool js_cocos2dx_ProtectedNode_removeAllProtectedChildren(JSContext *cx, uint32_ bool js_cocos2dx_ProtectedNode_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ProtectedNode_ProtectedNode(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocos2d_GLProgramState_class; +extern JSObject *jsb_cocos2d_GLProgramState_prototype; + +bool js_cocos2dx_GLProgramState_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_GLProgramState_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_GLProgramState(JSContext *cx, JSObject *global); +void register_all_cocos2dx(JSContext* cx, JSObject* obj); +bool js_cocos2dx_GLProgramState_setUniformTexture(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformMat4(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_applyUniforms(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_applyGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getUniformCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_applyAttributes(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformFloat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformVec3(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformInt(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getVertexAttribCount(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setUniformVec2(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getVertexAttribsFlags(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setVertexAttribCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_apply(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_setVertexAttribPointer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getGLProgram(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getOrCreateWithGLProgramName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgramState_getOrCreateWithGLProgram(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocos2d_AtlasNode_class; extern JSObject *jsb_cocos2d_AtlasNode_prototype; @@ -2808,13 +2836,14 @@ bool js_cocos2dx_ClippingNode_constructor(JSContext *cx, uint32_t argc, jsval *v void js_cocos2dx_ClippingNode_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ClippingNode(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); -bool js_cocos2dx_ClippingNode_isInverted(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ClippingNode_hasContent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_setInverted(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_setStencil(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_getAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_getStencil(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_setAlphaThreshold(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ClippingNode_isInverted(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ClippingNode_ClippingNode(JSContext *cx, uint32_t argc, jsval *vp); @@ -3333,27 +3362,25 @@ void js_cocos2dx_GLProgram_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_GLProgram(JSContext *cx, JSObject *global); void register_all_cocos2dx(JSContext* cx, JSObject* obj); bool js_cocos2dx_GLProgram_getFragmentShaderLog(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_GLProgram_setUniformLocationWithMatrix2fv(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_bindAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_GLProgram_setUniformLocationWithMatrix4fv(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_getUniformLocationForName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_use(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_getVertexShaderLog(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_getUniform(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_initWithByteArrays(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_setUniformLocationWith1f(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_initWithFilenames(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_setUniformLocationWith3f(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_setUniformsForBuiltins(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_setUniformLocationWith3i(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_GLProgram_setUniformLocationWith3iv(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_setUniformLocationWith4f(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_updateUniforms(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_GLProgram_setUniformLocationWith4iv(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_getUniformLocation(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_link(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_GLProgram_setUniformLocationWith2iv(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_GLProgram_setUniformLocationWithMatrix3fv(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_reset(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_getAttribLocation(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_getVertexAttrib(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_GLProgram_setUniformLocationWith2f(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_setUniformLocationWith4i(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_setUniformLocationWith1i(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_GLProgram_setUniformLocationWith2i(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.cpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.cpp index 33a3fc9922..53ad900ccb 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.cpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.cpp @@ -397,1218 +397,6 @@ void js_register_cocos2dx_extension_Control(JSContext *cx, JSObject *global) { } } -JSClass *jsb_cocos2d_ui_Scale9Sprite_class; -JSObject *jsb_cocos2d_ui_Scale9Sprite_prototype; - -bool js_cocos2dx_extension_Scale9Sprite_disableCascadeColor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_disableCascadeColor : Invalid Native Object"); - if (argc == 0) { - cobj->disableCascadeColor(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_disableCascadeColor : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - JSObject *obj = NULL; - cocos2d::ui::Scale9Sprite* cobj = NULL; - obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_updateWithSprite : Invalid Native Object"); - do { - if (argc == 6) { - cocos2d::Sprite* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool arg2; - arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); - cocos2d::Vec2 arg3; - ok &= jsval_to_vector2(cx, argv[3], &arg3); - if (!ok) { ok = true; break; } - cocos2d::Size arg4; - ok &= jsval_to_ccsize(cx, argv[4], &arg4); - if (!ok) { ok = true; break; } - cocos2d::Rect arg5; - ok &= jsval_to_ccrect(cx, argv[5], &arg5); - if (!ok) { ok = true; break; } - bool ret = cobj->updateWithSprite(arg0, arg1, arg2, arg3, arg4, arg5); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 4) { - cocos2d::Sprite* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool arg2; - arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); - cocos2d::Rect arg3; - ok &= jsval_to_ccrect(cx, argv[3], &arg3); - if (!ok) { ok = true; break; } - bool ret = cobj->updateWithSprite(arg0, arg1, arg2, arg3); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_updateWithSprite : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_isFlippedX : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isFlippedX(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_isFlippedX : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setFlippedY : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setFlippedY : Error processing arguments"); - cobj->setFlippedY(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setFlippedY : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setFlippedX : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setFlippedX : Error processing arguments"); - cobj->setFlippedX(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setFlippedX : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setScale9Enabled : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setScale9Enabled : Error processing arguments"); - cobj->setScale9Enabled(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_disableCascadeOpacity(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_disableCascadeOpacity : Invalid Native Object"); - if (argc == 0) { - cobj->disableCascadeOpacity(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_disableCascadeOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetBottom : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetBottom : Error processing arguments"); - cobj->setInsetBottom(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetBottom : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - JSObject *obj = NULL; - cocos2d::ui::Scale9Sprite* cobj = NULL; - obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName : Invalid Native Object"); - do { - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithSpriteFrameName(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithSpriteFrameName(arg0, arg1); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getSprite(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getSprite : Invalid Native Object"); - if (argc == 0) { - cocos2d::Sprite* ret = cobj->getSprite(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getSprite : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetTop : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetTop : Error processing arguments"); - cobj->setInsetTop(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetTop : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - JSObject *obj = NULL; - cocos2d::ui::Scale9Sprite* cobj = NULL; - obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_init : Invalid Native Object"); - do { - if (argc == 4) { - cocos2d::Sprite* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool arg2; - arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); - cocos2d::Rect arg3; - ok &= jsval_to_ccrect(cx, argv[3], &arg3); - if (!ok) { ok = true; break; } - bool ret = cobj->init(arg0, arg1, arg2, arg3); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 0) { - bool ret = cobj->init(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 3) { - cocos2d::Sprite* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cocos2d::Rect arg2; - ok &= jsval_to_ccrect(cx, argv[2], &arg2); - if (!ok) { ok = true; break; } - bool ret = cobj->init(arg0, arg1, arg2); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 6) { - cocos2d::Sprite* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool arg2; - arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); - cocos2d::Vec2 arg3; - ok &= jsval_to_vector2(cx, argv[3], &arg3); - if (!ok) { ok = true; break; } - cocos2d::Size arg4; - ok &= jsval_to_ccsize(cx, argv[4], &arg4); - if (!ok) { ok = true; break; } - cocos2d::Rect arg5; - ok &= jsval_to_ccrect(cx, argv[5], &arg5); - if (!ok) { ok = true; break; } - bool ret = cobj->init(arg0, arg1, arg2, arg3, arg4, arg5); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_init : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setPreferredSize : Invalid Native Object"); - if (argc == 1) { - cocos2d::Size arg0; - ok &= jsval_to_ccsize(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setPreferredSize : Error processing arguments"); - cobj->setPreferredSize(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getInsetRight : Invalid Native Object"); - if (argc == 0) { - double ret = cobj->getInsetRight(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetRight : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setSpriteFrame : Invalid Native Object"); - if (argc == 1) { - cocos2d::SpriteFrame* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setSpriteFrame : Error processing arguments"); - cobj->setSpriteFrame(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - if (argc == 2) { - cocos2d::SpriteFrame* arg0; - cocos2d::Rect arg1; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setSpriteFrame : Error processing arguments"); - cobj->setSpriteFrame(arg0, arg1); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getInsetBottom : Invalid Native Object"); - if (argc == 0) { - double ret = cobj->getInsetBottom(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetBottom : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets : Invalid Native Object"); - if (argc == 1) { - cocos2d::Rect arg0; - ok &= jsval_to_ccrect(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets : Error processing arguments"); - cocos2d::ui::Scale9Sprite* ret = cobj->resizableSpriteWithCapInsets(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_isScale9Enabled : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isScale9Enabled(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getCapInsets : Invalid Native Object"); - if (argc == 0) { - cocos2d::Rect ret = cobj->getCapInsets(); - jsval jsret = JSVAL_NULL; - jsret = ccrect_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getCapInsets : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getOriginalSize : Invalid Native Object"); - if (argc == 0) { - cocos2d::Size ret = cobj->getOriginalSize(); - jsval jsret = JSVAL_NULL; - jsret = ccsize_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getOriginalSize : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - JSObject *obj = NULL; - cocos2d::ui::Scale9Sprite* cobj = NULL; - obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_initWithFile : Invalid Native Object"); - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithFile(arg0, arg1); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 3) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cocos2d::Rect arg2; - ok &= jsval_to_ccrect(cx, argv[2], &arg2); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithFile(arg0, arg1, arg2); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 2) { - cocos2d::Rect arg0; - ok &= jsval_to_ccrect(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - std::string arg1; - ok &= jsval_to_std_string(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithFile(arg0, arg1); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithFile(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_initWithFile : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getInsetTop(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getInsetTop : Invalid Native Object"); - if (argc == 0) { - double ret = cobj->getInsetTop(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetTop : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setInsetLeft(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetLeft : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetLeft : Error processing arguments"); - cobj->setInsetLeft(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetLeft : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - JSObject *obj = NULL; - cocos2d::ui::Scale9Sprite* cobj = NULL; - obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame : Invalid Native Object"); - do { - if (argc == 1) { - cocos2d::SpriteFrame* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithSpriteFrame(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 2) { - cocos2d::SpriteFrame* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - bool ret = cobj->initWithSpriteFrame(arg0, arg1); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getPreferredSize : Invalid Native Object"); - if (argc == 0) { - cocos2d::Size ret = cobj->getPreferredSize(); - jsval jsret = JSVAL_NULL; - jsret = ccsize_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setCapInsets : Invalid Native Object"); - if (argc == 1) { - cocos2d::Rect arg0; - ok &= jsval_to_ccrect(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setCapInsets : Error processing arguments"); - cobj->setCapInsets(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_isFlippedY : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isFlippedY(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_isFlippedY : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_getInsetLeft(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_getInsetLeft : Invalid Native Object"); - if (argc == 0) { - double ret = cobj->getInsetLeft(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_getInsetLeft : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_setInsetRight(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetRight : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_Scale9Sprite_setInsetRight : Error processing arguments"); - cobj->setInsetRight(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_setInsetRight : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - do { - if (argc == 3) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cocos2d::Rect arg2; - ok &= jsval_to_ccrect(cx, argv[2], &arg2); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0, arg1, arg2); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - - do { - if (argc == 0) { - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - - do { - if (argc == 2) { - cocos2d::Rect arg0; - ok &= jsval_to_ccrect(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - std::string arg1; - ok &= jsval_to_std_string(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - - do { - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_create : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrameName(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - - do { - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrameName(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - do { - if (argc == 2) { - cocos2d::SpriteFrame* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrame(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - - do { - if (argc == 1) { - cocos2d::SpriteFrame* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrame(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while (0); - JS_ReportError(cx, "js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame : wrong number of arguments"); - return false; -} -bool js_cocos2dx_extension_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - cocos2d::ui::Scale9Sprite* cobj = new (std::nothrow) cocos2d::ui::Scale9Sprite(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); - // link the native object with the javascript object - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Scale9Sprite"); - if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); - return true; -} - - -extern JSObject *jsb_cocos2d_Node_prototype; - -void js_cocos2d_ui_Scale9Sprite_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (Scale9Sprite)", obj); -} - -static bool js_cocos2d_ui_Scale9Sprite_ctor(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSObject *obj = JS_THIS_OBJECT(cx, vp); - cocos2d::ui::Scale9Sprite *nobj = new (std::nothrow) cocos2d::ui::Scale9Sprite(); - if (nobj) { - nobj->autorelease(); - } - js_proxy_t* p = jsb_new_proxy(nobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Scale9Sprite"); - bool isFound = false; - if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; -} -void js_register_cocos2dx_extension_Scale9Sprite(JSContext *cx, JSObject *global) { - jsb_cocos2d_ui_Scale9Sprite_class = (JSClass *)calloc(1, sizeof(JSClass)); - jsb_cocos2d_ui_Scale9Sprite_class->name = "Scale9Sprite"; - jsb_cocos2d_ui_Scale9Sprite_class->addProperty = JS_PropertyStub; - jsb_cocos2d_ui_Scale9Sprite_class->delProperty = JS_DeletePropertyStub; - jsb_cocos2d_ui_Scale9Sprite_class->getProperty = JS_PropertyStub; - jsb_cocos2d_ui_Scale9Sprite_class->setProperty = JS_StrictPropertyStub; - jsb_cocos2d_ui_Scale9Sprite_class->enumerate = JS_EnumerateStub; - jsb_cocos2d_ui_Scale9Sprite_class->resolve = JS_ResolveStub; - jsb_cocos2d_ui_Scale9Sprite_class->convert = JS_ConvertStub; - jsb_cocos2d_ui_Scale9Sprite_class->finalize = js_cocos2d_ui_Scale9Sprite_finalize; - jsb_cocos2d_ui_Scale9Sprite_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, - {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} - }; - - static JSFunctionSpec funcs[] = { - JS_FN("disableCascadeColor", js_cocos2dx_extension_Scale9Sprite_disableCascadeColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("updateWithSprite", js_cocos2dx_extension_Scale9Sprite_updateWithSprite, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isFlippedX", js_cocos2dx_extension_Scale9Sprite_isFlippedX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setFlippedY", js_cocos2dx_extension_Scale9Sprite_setFlippedY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setFlippedX", js_cocos2dx_extension_Scale9Sprite_setFlippedX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setScale9Enabled", js_cocos2dx_extension_Scale9Sprite_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("disableCascadeOpacity", js_cocos2dx_extension_Scale9Sprite_disableCascadeOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setInsetBottom", js_cocos2dx_extension_Scale9Sprite_setInsetBottom, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithSpriteFrameName", js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getSprite", js_cocos2dx_extension_Scale9Sprite_getSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setInsetTop", js_cocos2dx_extension_Scale9Sprite_setInsetTop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("init", js_cocos2dx_extension_Scale9Sprite_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setPreferredSize", js_cocos2dx_extension_Scale9Sprite_setPreferredSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getInsetRight", js_cocos2dx_extension_Scale9Sprite_getInsetRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setSpriteFrame", js_cocos2dx_extension_Scale9Sprite_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getInsetBottom", js_cocos2dx_extension_Scale9Sprite_getInsetBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("resizableSpriteWithCapInsets", js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isScale9Enabled", js_cocos2dx_extension_Scale9Sprite_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCapInsets", js_cocos2dx_extension_Scale9Sprite_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getOriginalSize", js_cocos2dx_extension_Scale9Sprite_getOriginalSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithFile", js_cocos2dx_extension_Scale9Sprite_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getInsetTop", js_cocos2dx_extension_Scale9Sprite_getInsetTop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setInsetLeft", js_cocos2dx_extension_Scale9Sprite_setInsetLeft, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithSpriteFrame", js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getPreferredSize", js_cocos2dx_extension_Scale9Sprite_getPreferredSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCapInsets", js_cocos2dx_extension_Scale9Sprite_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isFlippedY", js_cocos2dx_extension_Scale9Sprite_isFlippedY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getInsetLeft", js_cocos2dx_extension_Scale9Sprite_getInsetLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setInsetRight", js_cocos2dx_extension_Scale9Sprite_setInsetRight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("ctor", js_cocos2d_ui_Scale9Sprite_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - static JSFunctionSpec st_funcs[] = { - JS_FN("create", js_cocos2dx_extension_Scale9Sprite_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createWithSpriteFrameName", js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createWithSpriteFrame", js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - jsb_cocos2d_ui_Scale9Sprite_prototype = JS_InitClass( - cx, global, - jsb_cocos2d_Node_prototype, - jsb_cocos2d_ui_Scale9Sprite_class, - js_cocos2dx_extension_Scale9Sprite_constructor, 0, // constructor - properties, - funcs, - NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Scale9Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_ui_Scale9Sprite_class; - p->proto = jsb_cocos2d_ui_Scale9Sprite_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } -} - JSClass *jsb_cocos2d_extension_ControlButton_class; JSObject *jsb_cocos2d_extension_ControlButton_prototype; @@ -8342,6 +7130,23 @@ bool js_cocos2dx_extension_Manifest_getVersionFileUrl(JSContext *cx, uint32_t ar JS_ReportError(cx, "js_cocos2dx_extension_Manifest_getVersionFileUrl : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_extension_Manifest_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::extension::Manifest* cobj = (cocos2d::extension::Manifest *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_Manifest_getSearchPaths : Invalid Native Object"); + if (argc == 0) { + std::vector ret = cobj->getSearchPaths(); + jsval jsret = JSVAL_NULL; + jsret = std_vector_string_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_extension_Manifest_getSearchPaths : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} void js_cocos2d_extension_Manifest_finalize(JSFreeOp *fop, JSObject *obj) { @@ -8373,6 +7178,7 @@ void js_register_cocos2dx_extension_Manifest(JSContext *cx, JSObject *global) { JS_FN("getPackageUrl", js_cocos2dx_extension_Manifest_getPackageUrl, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVersion", js_cocos2dx_extension_Manifest_getVersion, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVersionFileUrl", js_cocos2dx_extension_Manifest_getVersionFileUrl, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSearchPaths", js_cocos2dx_extension_Manifest_getSearchPaths, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -8685,10 +7491,12 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); } while (0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::EventAssetsManagerEx*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -8696,13 +7504,18 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_EventListenerAssetsManagerEx_init : Error processing arguments"); @@ -8732,10 +7545,12 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, ui JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); } while (0); do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](cocos2d::extension::EventAssetsManagerEx* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::extension::EventAssetsManagerEx*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -8743,13 +7558,18 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, ui largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_EventListenerAssetsManagerEx_create : Error processing arguments"); @@ -8877,7 +7697,7 @@ void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj) { js_register_cocos2dx_extension_Control(cx, obj); js_register_cocos2dx_extension_ControlHuePicker(cx, obj); js_register_cocos2dx_extension_TableViewCell(cx, obj); - js_register_cocos2dx_extension_Scale9Sprite(cx, obj); + js_register_cocos2dx_extension_ControlStepper(cx, obj); js_register_cocos2dx_extension_ControlColourPicker(cx, obj); js_register_cocos2dx_extension_ControlButton(cx, obj); js_register_cocos2dx_extension_ControlSlider(cx, obj); @@ -8886,7 +7706,6 @@ void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj) { js_register_cocos2dx_extension_Manifest(cx, obj); js_register_cocos2dx_extension_ControlPotentiometer(cx, obj); js_register_cocos2dx_extension_EventAssetsManagerEx(cx, obj); - js_register_cocos2dx_extension_ControlStepper(cx, obj); js_register_cocos2dx_extension_TableView(cx, obj); js_register_cocos2dx_extension_EventListenerAssetsManagerEx(cx, obj); js_register_cocos2dx_extension_ControlSwitch(cx, obj); diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.hpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.hpp index 528eee65cd..9296ca4ba9 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.hpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_extension_auto.hpp @@ -27,47 +27,6 @@ bool js_cocos2dx_extension_Control_isHighlighted(JSContext *cx, uint32_t argc, j bool js_cocos2dx_extension_Control_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_extension_Control_Control(JSContext *cx, uint32_t argc, jsval *vp); -extern JSClass *jsb_cocos2d_ui_Scale9Sprite_class; -extern JSObject *jsb_cocos2d_ui_Scale9Sprite_prototype; - -bool js_cocos2dx_extension_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void js_cocos2dx_extension_Scale9Sprite_finalize(JSContext *cx, JSObject *obj); -void js_register_cocos2dx_extension_Scale9Sprite(JSContext *cx, JSObject *global); -void register_all_cocos2dx_extension(JSContext* cx, JSObject* obj); -bool js_cocos2dx_extension_Scale9Sprite_disableCascadeColor(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_disableCascadeOpacity(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getSprite(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_resizableSpriteWithCapInsets(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getInsetTop(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setInsetLeft(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_getInsetLeft(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_setInsetRight(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_create(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_extension_Scale9Sprite_Scale9Sprite(JSContext *cx, uint32_t argc, jsval *vp); - extern JSClass *jsb_cocos2d_extension_ControlButton_class; extern JSObject *jsb_cocos2d_extension_ControlButton_prototype; @@ -394,6 +353,7 @@ bool js_cocos2dx_extension_Manifest_isLoaded(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_extension_Manifest_getPackageUrl(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_extension_Manifest_getVersion(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_extension_Manifest_getVersionFileUrl(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_extension_Manifest_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_cocos2d_extension_AssetsManagerEx_class; extern JSObject *jsb_cocos2d_extension_AssetsManagerEx_prototype; diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.cpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.cpp index 512f4a4be2..3a9c260765 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.cpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.cpp @@ -59,97 +59,95 @@ bool js_cocos2dx_spine_SkeletonRenderer_setTimeScale(JSContext *cx, uint32_t arg JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setTimeScale : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB : Invalid Native Object"); if (argc == 0) { - bool ret = cobj->getDebugSlotsEnabled(); + bool ret = cobj->isOpacityModifyRGB(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_drawSkeleton(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_drawSkeleton : Invalid Native Object"); if (argc == 2) { - std::string arg0; - std::string arg1; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - ok &= jsval_to_std_string(cx, argv[1], &arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Error processing arguments"); - bool ret = cobj->setAttachment(arg0, arg1); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); + cocos2d::Mat4 arg0; + unsigned int arg1; + ok &= jsval_to_matrix(cx, argv[0], &arg0); + ok &= jsval_to_uint32(cx, argv[1], &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_drawSkeleton : Error processing arguments"); + cobj->drawSkeleton(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : wrong number of arguments: %d, was expecting %d", argc, 2); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_drawSkeleton : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose : Invalid Native Object"); - if (argc == 0) { - cobj->setBonesToSetupPose(); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled : Error processing arguments"); + cobj->setDebugSlotsEnabled(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled : Invalid Native Object"); if (argc == 0) { - bool ret = cobj->isOpacityModifyRGB(); + bool ret = cobj->getDebugSlotsEnabled(); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled : Error processing arguments"); - cobj->setDebugSlotsEnabled(arg0); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose : Invalid Native Object"); + if (argc == 0) { + cobj->setBonesToSetupPose(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_spine_SkeletonRenderer_setSlotsToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) @@ -167,78 +165,82 @@ bool js_cocos2dx_spine_SkeletonRenderer_setSlotsToSetupPose(JSContext *cx, uint3 JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setSlotsToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB : Error processing arguments"); - cobj->setOpacityModifyRGB(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Invalid Native Object"); + if (argc == 2) { + std::string arg0; + std::string arg1; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + ok &= jsval_to_std_string(cx, argv[1], &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : Error processing arguments"); + bool ret = cobj->setAttachment(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setAttachment : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setToSetupPose : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getBlendFunc : Invalid Native Object"); if (argc == 0) { - cobj->setToSetupPose(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + jsval jsret = JSVAL_NULL; + jsret = blendfunc_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_setSkin(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getBlendFunc : Invalid Native Object"); - if (argc == 0) { - const cocos2d::BlendFunc& ret = cobj->getBlendFunc(); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Error processing arguments"); + bool ret = cobj->setSkin(arg0); jsval jsret = JSVAL_NULL; - jsret = blendfunc_to_jsval(cx, ret); + jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setSkin : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_drawSkeleton(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_drawSkeleton : Invalid Native Object"); - if (argc == 2) { - cocos2d::Mat4 arg0; - unsigned int arg1; - ok &= jsval_to_matrix(cx, argv[0], &arg0); - ok &= jsval_to_uint32(cx, argv[1], &arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_drawSkeleton : Error processing arguments"); - cobj->drawSkeleton(arg0, arg1); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setToSetupPose : Invalid Native Object"); + if (argc == 0) { + cobj->setToSetupPose(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_drawSkeleton : wrong number of arguments: %d, was expecting %d", argc, 2); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setToSetupPose : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_spine_SkeletonRenderer_updateWorldTransform(JSContext *cx, uint32_t argc, jsval *vp) @@ -256,19 +258,24 @@ bool js_cocos2dx_spine_SkeletonRenderer_updateWorldTransform(JSContext *cx, uint JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_updateWorldTransform : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_initialize(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_initialize : Invalid Native Object"); - if (argc == 0) { - cobj->initialize(); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB : Error processing arguments"); + cobj->setOpacityModifyRGB(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_initialize : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp) @@ -291,38 +298,38 @@ bool js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled(JSContext *cx, uint JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getSkeleton : Invalid Native Object"); if (argc == 0) { - bool ret = cobj->getDebugBonesEnabled(); + spSkeleton* ret = cobj->getSkeleton(); jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); + #pragma warning NO CONVERSION FROM NATIVE FOR spSkeleton*; JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getSkeleton : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getTimeScale : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled : Invalid Native Object"); if (argc == 0) { - double ret = cobj->getTimeScale(); + bool ret = cobj->getDebugBonesEnabled(); jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); + jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getTimeScale : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_spine_SkeletonRenderer_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp) @@ -345,43 +352,21 @@ bool js_cocos2dx_spine_SkeletonRenderer_setBlendFunc(JSContext *cx, uint32_t arg JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setBlendFunc : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_setSkin(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonRenderer_setSkin : Error processing arguments"); - bool ret = cobj->setSkin(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_setSkin : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_spine_SkeletonRenderer_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_spine_SkeletonRenderer_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); spine::SkeletonRenderer* cobj = (spine::SkeletonRenderer *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getSkeleton : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonRenderer_getTimeScale : Invalid Native Object"); if (argc == 0) { - spSkeleton* ret = cobj->getSkeleton(); + double ret = cobj->getTimeScale(); jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR spSkeleton*; + jsret = DOUBLE_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getSkeleton : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_getTimeScale : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_spine_SkeletonRenderer_createWithFile(JSContext *cx, uint32_t argc, jsval *vp) @@ -489,206 +474,6 @@ bool js_cocos2dx_spine_SkeletonRenderer_createWithFile(JSContext *cx, uint32_t a JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_createWithFile : wrong number of arguments"); return false; } -bool js_cocos2dx_spine_SkeletonRenderer_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - JSObject *obj = NULL; - spine::SkeletonRenderer* cobj = NULL; - do { - if (argc == 1) { - spSkeletonData* arg0; - #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData* - ok = false; - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonRenderer(arg0); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); - } - } while(0); - - do { - if (argc == 2) { - spSkeletonData* arg0; - #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData* - ok = false; - if (!ok) { ok = true; break; } - bool arg1; - arg1 = JS::ToBoolean(JS::RootedValue(cx, argv[1])); - cobj = new (std::nothrow) spine::SkeletonRenderer(arg0, arg1); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); - } - } while(0); - - do { - if (argc == 0) { - cobj = new (std::nothrow) spine::SkeletonRenderer(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); - } - } while(0); - - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - spAtlas* arg1; - #pragma warning NO CONVERSION TO NATIVE FOR spAtlas* - ok = false; - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonRenderer(arg0, arg1); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); - } - } while(0); - - do { - if (argc == 3) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - spAtlas* arg1; - #pragma warning NO CONVERSION TO NATIVE FOR spAtlas* - ok = false; - if (!ok) { ok = true; break; } - double arg2; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &arg2); - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonRenderer(arg0, arg1, arg2); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); - } - } while(0); - - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - std::string arg1; - ok &= jsval_to_std_string(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonRenderer(arg0, arg1); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); - } - } while(0); - - do { - if (argc == 3) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - std::string arg1; - ok &= jsval_to_std_string(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - double arg2; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &arg2); - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonRenderer(arg0, arg1, arg2); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonRenderer"); - } - } while(0); - - if (cobj) { - if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); - return true; - } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonRenderer_constructor : wrong number of arguments"); - return false; -} - extern JSObject *jsb_cocos2d_Node_prototype; @@ -716,24 +501,23 @@ void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JSObject *global static JSFunctionSpec funcs[] = { JS_FN("setTimeScale", js_cocos2dx_spine_SkeletonRenderer_setTimeScale, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getDebugSlotsEnabled", js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setAttachment", js_cocos2dx_spine_SkeletonRenderer_setAttachment, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setBonesToSetupPose", js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isOpacityModifyRGB", js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("drawSkeleton", js_cocos2dx_spine_SkeletonRenderer_drawSkeleton, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDebugSlotsEnabled", js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDebugSlotsEnabled", js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setBonesToSetupPose", js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSlotsToSetupPose", js_cocos2dx_spine_SkeletonRenderer_setSlotsToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setOpacityModifyRGB", js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setToSetupPose", js_cocos2dx_spine_SkeletonRenderer_setToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setAttachment", js_cocos2dx_spine_SkeletonRenderer_setAttachment, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBlendFunc", js_cocos2dx_spine_SkeletonRenderer_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("drawSkeleton", js_cocos2dx_spine_SkeletonRenderer_drawSkeleton, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSkin", js_cocos2dx_spine_SkeletonRenderer_setSkin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setToSetupPose", js_cocos2dx_spine_SkeletonRenderer_setToSetupPose, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateWorldTransform", js_cocos2dx_spine_SkeletonRenderer_updateWorldTransform, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initialize", js_cocos2dx_spine_SkeletonRenderer_initialize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setOpacityModifyRGB", js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDebugBonesEnabled", js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSkeleton", js_cocos2dx_spine_SkeletonRenderer_getSkeleton, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDebugBonesEnabled", js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getTimeScale", js_cocos2dx_spine_SkeletonRenderer_getTimeScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBlendFunc", js_cocos2dx_spine_SkeletonRenderer_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setSkin", js_cocos2dx_spine_SkeletonRenderer_setSkin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getSkeleton", js_cocos2dx_spine_SkeletonRenderer_getSkeleton, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTimeScale", js_cocos2dx_spine_SkeletonRenderer_getTimeScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -746,7 +530,7 @@ void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JSObject *global cx, global, jsb_cocos2d_Node_prototype, jsb_spine_SkeletonRenderer_class, - js_cocos2dx_spine_SkeletonRenderer_constructor, 0, // constructor + dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties @@ -784,17 +568,24 @@ bool js_cocos2dx_spine_SkeletonAnimation_setStartListener(JSContext *cx, uint32_ if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](int larg0) -> void { - jsval largv[1]; - largv[0] = int32_to_jsval(cx, larg0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](int larg0) -> void { + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setStartListener : Error processing arguments"); @@ -820,11 +611,13 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, ui #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* ok = false; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](int larg0, spEvent* larg1) -> void { - jsval largv[2]; - largv[0] = int32_to_jsval(cx, larg0); - do { + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](int larg0, spEvent* larg1) -> void { + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + do { if (larg1) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spEvent*)larg1); largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -832,13 +625,18 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener(JSContext *cx, ui largv[1] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(2, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setTrackEventListener : Error processing arguments"); @@ -881,18 +679,25 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener(JSContext *cx, #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* ok = false; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](int larg0, int larg1) -> void { - jsval largv[2]; - largv[0] = int32_to_jsval(cx, larg0); - largv[1] = int32_to_jsval(cx, larg1); - jsval rval; - bool ok = func->invoke(2, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](int larg0, int larg1) -> void { + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + largv[1] = int32_to_jsval(cx, larg1); + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setTrackCompleteListener : Error processing arguments"); @@ -945,17 +750,24 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener(JSContext *cx, ui #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* ok = false; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](int larg0) -> void { - jsval largv[1]; - largv[0] = int32_to_jsval(cx, larg0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](int larg0) -> void { + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setTrackStartListener : Error processing arguments"); @@ -998,18 +810,25 @@ bool js_cocos2dx_spine_SkeletonAnimation_setCompleteListener(JSContext *cx, uint if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](int larg0, int larg1) -> void { - jsval largv[2]; - largv[0] = int32_to_jsval(cx, larg0); - largv[1] = int32_to_jsval(cx, larg1); - jsval rval; - bool ok = func->invoke(2, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](int larg0, int larg1) -> void { + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + largv[1] = int32_to_jsval(cx, larg1); + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setCompleteListener : Error processing arguments"); @@ -1035,17 +854,24 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint #pragma warning NO CONVERSION TO NATIVE FOR spTrackEntry* ok = false; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); - auto lambda = [=](int larg0) -> void { - jsval largv[1]; - largv[0] = int32_to_jsval(cx, larg0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg1 = lambda; + if(JS_TypeOfValue(cx, argv[1]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[1])); + auto lambda = [=](int larg0) -> void { + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg1 = lambda; + } + else + { + arg1 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener : Error processing arguments"); @@ -1068,11 +894,13 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_ if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](int larg0, spEvent* larg1) -> void { - jsval largv[2]; - largv[0] = int32_to_jsval(cx, larg0); - do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](int larg0, spEvent* larg1) -> void { + jsval largv[2]; + largv[0] = int32_to_jsval(cx, larg0); + do { if (larg1) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (spEvent*)larg1); largv[1] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -1080,13 +908,18 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_ largv[1] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(2, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setEventListener : Error processing arguments"); @@ -1133,17 +966,24 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](int larg0) -> void { - jsval largv[1]; - largv[0] = int32_to_jsval(cx, larg0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](int larg0) -> void { + jsval largv[1]; + largv[0] = int32_to_jsval(cx, larg0); + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_spine_SkeletonAnimation_setEndListener : Error processing arguments"); @@ -1155,21 +995,6 @@ bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_setEndListener : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_spine_SkeletonAnimation_initialize(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - spine::SkeletonAnimation* cobj = (spine::SkeletonAnimation *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_spine_SkeletonAnimation_initialize : Invalid Native Object"); - if (argc == 0) { - cobj->initialize(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_initialize : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_spine_SkeletonAnimation_clearTracks(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -1342,160 +1167,6 @@ bool js_cocos2dx_spine_SkeletonAnimation_createWithFile(JSContext *cx, uint32_t JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_createWithFile : wrong number of arguments"); return false; } -bool js_cocos2dx_spine_SkeletonAnimation_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - - JSObject *obj = NULL; - spine::SkeletonAnimation* cobj = NULL; - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - spAtlas* arg1; - #pragma warning NO CONVERSION TO NATIVE FOR spAtlas* - ok = false; - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonAnimation(arg0, arg1); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); - } - } while(0); - - do { - if (argc == 3) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - spAtlas* arg1; - #pragma warning NO CONVERSION TO NATIVE FOR spAtlas* - ok = false; - if (!ok) { ok = true; break; } - double arg2; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &arg2); - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonAnimation(arg0, arg1, arg2); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); - } - } while(0); - - do { - if (argc == 1) { - spSkeletonData* arg0; - #pragma warning NO CONVERSION TO NATIVE FOR spSkeletonData* - ok = false; - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonAnimation(arg0); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); - } - } while(0); - - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - std::string arg1; - ok &= jsval_to_std_string(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonAnimation(arg0, arg1); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); - } - } while(0); - - do { - if (argc == 3) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - if (!ok) { ok = true; break; } - std::string arg1; - ok &= jsval_to_std_string(cx, argv[1], &arg1); - if (!ok) { ok = true; break; } - double arg2; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[2]), &arg2); - if (!ok) { ok = true; break; } - cobj = new (std::nothrow) spine::SkeletonAnimation(arg0, arg1, arg2); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS_AddNamedObjectRoot(cx, &p->obj, "spine::SkeletonAnimation"); - } - } while(0); - - if (cobj) { - if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); - - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); - return true; - } - JS_ReportError(cx, "js_cocos2dx_spine_SkeletonAnimation_constructor : wrong number of arguments"); - return false; -} - extern JSObject *jsb_spine_SkeletonRenderer_prototype; @@ -1534,7 +1205,6 @@ void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JSObject *globa JS_FN("setEventListener", js_cocos2dx_spine_SkeletonAnimation_setEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMix", js_cocos2dx_spine_SkeletonAnimation_setMix, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEndListener", js_cocos2dx_spine_SkeletonAnimation_setEndListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initialize", js_cocos2dx_spine_SkeletonAnimation_initialize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clearTracks", js_cocos2dx_spine_SkeletonAnimation_clearTracks, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clearTrack", js_cocos2dx_spine_SkeletonAnimation_clearTrack, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onAnimationStateEvent", js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -1550,7 +1220,7 @@ void js_register_cocos2dx_spine_SkeletonAnimation(JSContext *cx, JSObject *globa cx, global, jsb_spine_SkeletonRenderer_prototype, jsb_spine_SkeletonAnimation_class, - js_cocos2dx_spine_SkeletonAnimation_constructor, 0, // constructor + dummy_constructor, 0, // no constructor properties, funcs, NULL, // no static properties diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.hpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.hpp index 2b6ebdd50e..7b3b15fa5e 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.hpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_spine_auto.hpp @@ -13,26 +13,24 @@ void js_cocos2dx_spine_SkeletonRenderer_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_spine_SkeletonRenderer(JSContext *cx, JSObject *global); void register_all_cocos2dx_spine(JSContext* cx, JSObject* obj); bool js_cocos2dx_spine_SkeletonRenderer_setTimeScale(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_isOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_drawSkeleton(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_setDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_getDebugSlotsEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_setBonesToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_setSlotsToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_setAttachment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_drawSkeleton(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_setSkin(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_setToSetupPose(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_updateWorldTransform(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_initialize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_setOpacityModifyRGB(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_setDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_getDebugBonesEnabled(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_setSkin(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_getSkeleton(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_spine_SkeletonRenderer_getTimeScale(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonRenderer_createWithFile(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonRenderer_SkeletonRenderer(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_spine_SkeletonAnimation_class; extern JSObject *jsb_spine_SkeletonAnimation_prototype; @@ -53,11 +51,9 @@ bool js_cocos2dx_spine_SkeletonAnimation_setTrackEndListener(JSContext *cx, uint bool js_cocos2dx_spine_SkeletonAnimation_setEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonAnimation_setMix(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonAnimation_setEndListener(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonAnimation_initialize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonAnimation_clearTracks(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonAnimation_clearTrack(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonAnimation_onAnimationStateEvent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_spine_SkeletonAnimation_createWithFile(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_spine_SkeletonAnimation_SkeletonAnimation(JSContext *cx, uint32_t argc, jsval *vp); #endif diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.cpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.cpp index ee13bf0dd2..ff873cd2b8 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.cpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.cpp @@ -529,61 +529,23 @@ void js_register_cocos2dx_studio_ActionObject(JSContext *cx, JSObject *global) { JSClass *jsb_cocostudio_ActionManagerEx_class; JSObject *jsb_cocostudio_ActionManagerEx_prototype; -bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionManagerEx_stopActionByName(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; - - JSObject *obj = NULL; - cocostudio::ActionManagerEx* cobj = NULL; - obj = JS_THIS_OBJECT(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_playActionByName : Invalid Native Object"); - do { - if (argc == 3) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - if (!ok) { ok = true; break; } - const char* arg1; - std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); - if (!ok) { ok = true; break; } - cocos2d::CallFunc* arg2; - do { - if (!argv[2].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg2 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1, arg2); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ActionObject*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); - - do { - if (argc == 2) { - const char* arg0; - std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); - if (!ok) { ok = true; break; } - const char* arg1; - std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); - if (!ok) { ok = true; break; } - cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { + cocostudio::ActionManagerEx* cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_stopActionByName : Invalid Native Object"); + if (argc == 2) { + const char* arg0; + const char* arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionManagerEx_stopActionByName : Error processing arguments"); + cocostudio::ActionObject* ret = cobj->stopActionByName(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { if (ret) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ActionObject*)ret); jsret = OBJECT_TO_JSVAL(jsProxy->obj); @@ -591,12 +553,11 @@ bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t jsret = JSVAL_NULL; } } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - } while(0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } - JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_playActionByName : wrong number of arguments"); + JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_stopActionByName : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } bool js_cocos2dx_studio_ActionManagerEx_getActionByName(JSContext *cx, uint32_t argc, jsval *vp) @@ -671,6 +632,76 @@ bool js_cocos2dx_studio_ActionManagerEx_initWithBinary(JSContext *cx, uint32_t a JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_initWithBinary : wrong number of arguments: %d, was expecting %d", argc, 4); return false; } +bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocostudio::ActionManagerEx* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocostudio::ActionManagerEx *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionManagerEx_playActionByName : Invalid Native Object"); + do { + if (argc == 3) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + cocos2d::CallFunc* arg2; + do { + if (!argv[2].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::CallFunc*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ActionObject*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + if (!ok) { ok = true; break; } + const char* arg1; + std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); + if (!ok) { ok = true; break; } + cocostudio::ActionObject* ret = cobj->playActionByName(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::ActionObject*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_studio_ActionManagerEx_playActionByName : wrong number of arguments"); + return false; +} bool js_cocos2dx_studio_ActionManagerEx_releaseActions(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -742,9 +773,10 @@ void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JSObject *global }; static JSFunctionSpec funcs[] = { - JS_FN("playActionByName", js_cocos2dx_studio_ActionManagerEx_playActionByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("stopActionByName", js_cocos2dx_studio_ActionManagerEx_stopActionByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionByName", js_cocos2dx_studio_ActionManagerEx_getActionByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithBinary", js_cocos2dx_studio_ActionManagerEx_initWithBinary, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("playActionByName", js_cocos2dx_studio_ActionManagerEx_playActionByName, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("releaseActions", js_cocos2dx_studio_ActionManagerEx_releaseActions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -8456,122 +8488,6 @@ bool js_cocos2dx_studio_ActionTimelineCache_createActionFromJson(JSContext *cx, JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_createActionFromJson : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_ActionTimelineCache_createActionFromProtocolBuffers(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimelineCache* cobj = (cocostudio::timeline::ActionTimelineCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineCache_createActionFromProtocolBuffers : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineCache_createActionFromProtocolBuffers : Error processing arguments"); - cocostudio::timeline::ActionTimeline* ret = cobj->createActionFromProtocolBuffers(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ActionTimeline*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_createActionFromProtocolBuffers : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_ActionTimelineCache_createActionFromXML(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimelineCache* cobj = (cocostudio::timeline::ActionTimelineCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineCache_createActionFromXML : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineCache_createActionFromXML : Error processing arguments"); - cocostudio::timeline::ActionTimeline* ret = cobj->createActionFromXML(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ActionTimeline*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_createActionFromXML : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromProtocolBuffers(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimelineCache* cobj = (cocostudio::timeline::ActionTimelineCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromProtocolBuffers : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromProtocolBuffers : Error processing arguments"); - cocostudio::timeline::ActionTimeline* ret = cobj->loadAnimationActionWithFileFromProtocolBuffers(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ActionTimeline*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromProtocolBuffers : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromXML(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimelineCache* cobj = (cocostudio::timeline::ActionTimelineCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromXML : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromXML : Error processing arguments"); - cocostudio::timeline::ActionTimeline* ret = cobj->loadAnimationActionWithFileFromXML(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ActionTimeline*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromXML : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_studio_ActionTimelineCache_purge(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -8682,63 +8598,27 @@ bool js_cocos2dx_studio_ActionTimelineCache_removeAction(JSContext *cx, uint32_t JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_removeAction : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_ActionTimelineCache_loadActionTimelineFromXML(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimelineCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc == 0) { + cocostudio::timeline::ActionTimelineCache::destroyInstance(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_destroyInstance : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_studio_ActionTimelineCache_createAction(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimelineCache* cobj = (cocostudio::timeline::ActionTimelineCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimelineCache_loadActionTimelineFromXML : Invalid Native Object"); if (argc == 1) { - const tinyxml2::XMLElement* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (const tinyxml2::XMLElement*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineCache_loadActionTimelineFromXML : Error processing arguments"); - cocostudio::timeline::ActionTimeline* ret = cobj->loadActionTimelineFromXML(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ActionTimeline*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_loadActionTimelineFromXML : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_ActionTimelineCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) -{ - if (argc == 0) { - cocostudio::timeline::ActionTimelineCache::destroyInstance(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimelineCache_destroyInstance : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_studio_ActionTimelineCache_createAction(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineCache_createAction : Error processing arguments"); - cocostudio::timeline::ActionTimeline* ret = cocostudio::timeline::ActionTimelineCache::createAction(arg0); - jsval jsret = JSVAL_NULL; + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimelineCache_createAction : Error processing arguments"); + cocostudio::timeline::ActionTimeline* ret = cocostudio::timeline::ActionTimelineCache::createAction(arg0); + jsval jsret = JSVAL_NULL; do { if (ret) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::ActionTimeline*)ret); @@ -8800,16 +8680,11 @@ void js_register_cocos2dx_studio_ActionTimelineCache(JSContext *cx, JSObject *gl static JSFunctionSpec funcs[] = { JS_FN("createActionFromJson", js_cocos2dx_studio_ActionTimelineCache_createActionFromJson, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createActionFromProtocolBuffers", js_cocos2dx_studio_ActionTimelineCache_createActionFromProtocolBuffers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createActionFromXML", js_cocos2dx_studio_ActionTimelineCache_createActionFromXML, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadAnimationActionWithFileFromProtocolBuffers", js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromProtocolBuffers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadAnimationActionWithFileFromXML", js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromXML, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("purge", js_cocos2dx_studio_ActionTimelineCache_purge, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_ActionTimelineCache_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadAnimationActionWithFile", js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadAnimationActionWithContent", js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithContent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAction", js_cocos2dx_studio_ActionTimelineCache_removeAction, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("loadActionTimelineFromXML", js_cocos2dx_studio_ActionTimelineCache_loadActionTimelineFromXML, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -11774,21 +11649,78 @@ void js_register_cocos2dx_studio_ActionTimelineData(JSContext *cx, JSObject *glo JSClass *jsb_cocostudio_timeline_ActionTimeline_class; JSObject *jsb_cocostudio_timeline_ActionTimeline_prototype; -bool js_cocos2dx_studio_ActionTimeline_getTimelines(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getTimelines : Invalid Native Object"); - if (argc == 0) { - const cocos2d::Vector& ret = cobj->getTimelines(); - jsval jsret = JSVAL_NULL; - jsret = ccvector_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](cocostudio::timeline::Frame* larg0) -> void { + jsval largv[1]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::Frame*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc : Error processing arguments"); + cobj->setFrameEventCallFunc(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getTimelines : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_addTimeline(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_addTimeline : Invalid Native Object"); + if (argc == 1) { + cocostudio::timeline::Timeline* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_addTimeline : Error processing arguments"); + cobj->addTimeline(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_addTimeline : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_studio_ActionTimeline_getCurrentFrame(JSContext *cx, uint32_t argc, jsval *vp) @@ -11840,86 +11772,31 @@ bool js_cocos2dx_studio_ActionTimeline_pause(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_pause : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc : Invalid Native Object"); - if (argc == 1) { - std::function arg0; - do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](cocostudio::timeline::Frame* larg0) -> void { - jsval largv[1]; - do { - if (larg0) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocostudio::timeline::Frame*)larg0); - largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - largv[0] = JSVAL_NULL; - } - } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; - } while(0) - ; - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc : Error processing arguments"); - cobj->setFrameEventCallFunc(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_ActionTimeline_resume(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_resume : Invalid Native Object"); - if (argc == 0) { - cobj->resume(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_resume : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_studio_ActionTimeline_getDuration(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getDuration : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_init : Invalid Native Object"); if (argc == 0) { - int ret = cobj->getDuration(); + bool ret = cobj->init(); jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); + jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_init : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_ActionTimeline_addTimeline(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_removeTimeline(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_addTimeline : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_removeTimeline : Invalid Native Object"); if (argc == 1) { cocostudio::timeline::Timeline* arg0; do { @@ -11930,124 +11807,117 @@ bool js_cocos2dx_studio_ActionTimeline_addTimeline(JSContext *cx, uint32_t argc, arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_addTimeline : Error processing arguments"); - cobj->addTimeline(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_removeTimeline : Error processing arguments"); + cobj->removeTimeline(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_addTimeline : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_ActionTimeline_getEndFrame(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getEndFrame : Invalid Native Object"); - if (argc == 0) { - int ret = cobj->getEndFrame(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getEndFrame : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_removeTimeline : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_ActionTimeline_setCurrentFrame(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setCurrentFrame : Invalid Native Object"); - if (argc == 1) { - int arg0; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setCurrentFrame : Error processing arguments"); - cobj->setCurrentFrame(arg0); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc : Invalid Native Object"); + if (argc == 1) { + std::function arg0; + do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=]() -> void { + jsval rval; + bool ok = func->invoke(0, nullptr, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc : Error processing arguments"); + cobj->setLastFrameCallFunc(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setCurrentFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_ActionTimeline_setTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_getTimelines(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setTimeSpeed : Invalid Native Object"); - if (argc == 1) { - double arg0; - ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setTimeSpeed : Error processing arguments"); - cobj->setTimeSpeed(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getTimelines : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Vector& ret = cobj->getTimelines(); + jsval jsret = JSVAL_NULL; + jsret = ccvector_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setTimeSpeed : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getTimelines : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_ActionTimeline_init(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_resume(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_init : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_resume : Invalid Native Object"); if (argc == 0) { - bool ret = cobj->init(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); + cobj->resume(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_init : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_resume : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_ActionTimeline_setDuration(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_getTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setDuration : Invalid Native Object"); - if (argc == 1) { - int arg0; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setDuration : Error processing arguments"); - cobj->setDuration(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getTimeSpeed : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getTimeSpeed(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setDuration : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getTimeSpeed : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_ActionTimeline_getTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_getDuration(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getTimeSpeed : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getDuration : Invalid Native Object"); if (argc == 0) { - double ret = cobj->getTimeSpeed(); + int ret = cobj->getDuration(); jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); + jsret = int32_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getTimeSpeed : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getDuration : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_studio_ActionTimeline_gotoFrameAndPause(JSContext *cx, uint32_t argc, jsval *vp) @@ -12160,46 +12030,111 @@ bool js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay(JSContext *cx, uint32_t JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay : wrong number of arguments"); return false; } -bool js_cocos2dx_studio_ActionTimeline_removeTimeline(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_removeTimeline : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc : Invalid Native Object"); + if (argc == 0) { + cobj->clearFrameEventCallFunc(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_getEndFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_getEndFrame : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getEndFrame(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_getEndFrame : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_setTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setTimeSpeed : Invalid Native Object"); if (argc == 1) { - cocostudio::timeline::Timeline* arg0; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocostudio::timeline::Timeline*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_removeTimeline : Error processing arguments"); - cobj->removeTimeline(arg0); + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setTimeSpeed : Error processing arguments"); + cobj->setTimeSpeed(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_removeTimeline : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setTimeSpeed : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_ActionTimeline_clearLastFrameCallFunc(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_clearLastFrameCallFunc : Invalid Native Object"); if (argc == 0) { - cobj->clearFrameEventCallFunc(); + cobj->clearLastFrameCallFunc(); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_clearLastFrameCallFunc : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_setDuration(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setDuration : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setDuration : Error processing arguments"); + cobj->setDuration(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setDuration : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_studio_ActionTimeline_setCurrentFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::timeline::ActionTimeline* cobj = (cocostudio::timeline::ActionTimeline *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_ActionTimeline_setCurrentFrame : Invalid Native Object"); + if (argc == 1) { + int arg0; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_ActionTimeline_setCurrentFrame : Error processing arguments"); + cobj->setCurrentFrame(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_studio_ActionTimeline_setCurrentFrame : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_studio_ActionTimeline_create(JSContext *cx, uint32_t argc, jsval *vp) @@ -12274,25 +12209,27 @@ void js_register_cocos2dx_studio_ActionTimeline(JSContext *cx, JSObject *global) }; static JSFunctionSpec funcs[] = { - JS_FN("getTimelines", js_cocos2dx_studio_ActionTimeline_getTimelines, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFrameEventCallFunc", js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addTimeline", js_cocos2dx_studio_ActionTimeline_addTimeline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentFrame", js_cocos2dx_studio_ActionTimeline_getCurrentFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStartFrame", js_cocos2dx_studio_ActionTimeline_getStartFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("pause", js_cocos2dx_studio_ActionTimeline_pause, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setFrameEventCallFunc", js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("resume", js_cocos2dx_studio_ActionTimeline_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getDuration", js_cocos2dx_studio_ActionTimeline_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("addTimeline", js_cocos2dx_studio_ActionTimeline_addTimeline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getEndFrame", js_cocos2dx_studio_ActionTimeline_getEndFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCurrentFrame", js_cocos2dx_studio_ActionTimeline_setCurrentFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setTimeSpeed", js_cocos2dx_studio_ActionTimeline_setTimeSpeed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_studio_ActionTimeline_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setDuration", js_cocos2dx_studio_ActionTimeline_setDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeTimeline", js_cocos2dx_studio_ActionTimeline_removeTimeline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setLastFrameCallFunc", js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTimelines", js_cocos2dx_studio_ActionTimeline_getTimelines, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resume", js_cocos2dx_studio_ActionTimeline_resume, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTimeSpeed", js_cocos2dx_studio_ActionTimeline_getTimeSpeed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDuration", js_cocos2dx_studio_ActionTimeline_getDuration, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("gotoFrameAndPause", js_cocos2dx_studio_ActionTimeline_gotoFrameAndPause, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPlaying", js_cocos2dx_studio_ActionTimeline_isPlaying, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("gotoFrameAndPlay", js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeTimeline", js_cocos2dx_studio_ActionTimeline_removeTimeline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("clearFrameEventCallFunc", js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEndFrame", js_cocos2dx_studio_ActionTimeline_getEndFrame, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setTimeSpeed", js_cocos2dx_studio_ActionTimeline_setTimeSpeed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("clearLastFrameCallFunc", js_cocos2dx_studio_ActionTimeline_clearLastFrameCallFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDuration", js_cocos2dx_studio_ActionTimeline_setDuration, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCurrentFrame", js_cocos2dx_studio_ActionTimeline_setCurrentFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -12332,86 +12269,39 @@ void js_register_cocos2dx_studio_ActionTimeline(JSContext *cx, JSObject *global) JSClass *jsb_cocos2d_CSLoader_class; JSObject *jsb_cocos2d_CSLoader_prototype; -bool js_cocos2dx_studio_CSLoader_createNodeFromJson(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_CSLoader_setJsonPath(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromJson : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_setJsonPath : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromJson : Error processing arguments"); - cocos2d::Node* ret = cobj->createNodeFromJson(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_createNodeFromJson : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_CSLoader_nodeFromXML(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_nodeFromXML : Invalid Native Object"); - if (argc == 2) { - const tinyxml2::XMLElement* arg0; - std::string arg1; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (const tinyxml2::XMLElement*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - ok &= jsval_to_std_string(cx, argv[1], &arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_nodeFromXML : Error processing arguments"); - cocos2d::Node* ret = cobj->nodeFromXML(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_setJsonPath : Error processing arguments"); + cobj->setJsonPath(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_nodeFromXML : wrong number of arguments: %d, was expecting %d", argc, 2); + JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_setJsonPath : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_CSLoader_createNodeFromProtocolBuffers(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_CSLoader_createNodeFromJson(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromProtocolBuffers : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromJson : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromProtocolBuffers : Error processing arguments"); - cocos2d::Node* ret = cobj->createNodeFromProtocolBuffers(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromJson : Error processing arguments"); + cocos2d::Node* ret = cobj->createNodeFromJson(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { @@ -12425,62 +12315,7 @@ bool js_cocos2dx_studio_CSLoader_createNodeFromProtocolBuffers(JSContext *cx, ui return true; } - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_createNodeFromProtocolBuffers : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_CSLoader_init(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_init : Invalid Native Object"); - if (argc == 0) { - cobj->init(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_init : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_studio_CSLoader_setRecordXMLPath(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_setRecordXMLPath : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_setRecordXMLPath : Error processing arguments"); - cobj->setRecordXMLPath(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_setRecordXMLPath : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_CSLoader_setJsonPath(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_setJsonPath : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_setJsonPath : Error processing arguments"); - cobj->setJsonPath(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_setJsonPath : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_createNodeFromJson : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_studio_CSLoader_loadNodeWithFile(JSContext *cx, uint32_t argc, jsval *vp) @@ -12512,116 +12347,91 @@ bool js_cocos2dx_studio_CSLoader_loadNodeWithFile(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_loadNodeWithFile : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_CSLoader_loadNodeWithContent(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_CSLoader_bindCallback(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_loadNodeWithContent : Invalid Native Object"); - if (argc == 1) { + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_bindCallback : Invalid Native Object"); + if (argc == 4) { std::string arg0; + std::string arg1; + cocos2d::ui::Widget* arg2; + cocos2d::Node* arg3; ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_loadNodeWithContent : Error processing arguments"); - cocos2d::Node* ret = cobj->loadNodeWithContent(arg0); - jsval jsret = JSVAL_NULL; + ok &= jsval_to_std_string(cx, argv[1], &arg1); do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } + if (!argv[2].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_loadNodeWithContent : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_CSLoader_isRecordProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_isRecordProtocolBuffersPath : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isRecordProtocolBuffersPath(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_isRecordProtocolBuffersPath : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_studio_CSLoader_isRecordXMLPath(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_isRecordXMLPath : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isRecordXMLPath(); + do { + if (!argv[3].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[3]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg3 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg3, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_bindCallback : Error processing arguments"); + bool ret = cobj->bindCallback(arg0, arg1, arg2, arg3); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_isRecordXMLPath : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_bindCallback : wrong number of arguments: %d, was expecting %d", argc, 4); return false; } -bool js_cocos2dx_studio_CSLoader_getProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_CSLoader_purge(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_getProtocolBuffersPath : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_purge : Invalid Native Object"); if (argc == 0) { - std::string ret = cobj->getProtocolBuffersPath(); - jsval jsret = JSVAL_NULL; - jsret = std_string_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); + cobj->purge(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_getProtocolBuffersPath : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_purge : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_CSLoader_getXMLPath(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_CSLoader_init(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_getXMLPath : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_init : Invalid Native Object"); if (argc == 0) { - std::string ret = cobj->getXMLPath(); - jsval jsret = JSVAL_NULL; - jsret = std_string_to_jsval(cx, ret); - JS_SET_RVAL(cx, vp, jsret); + cobj->init(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_getXMLPath : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_init : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_CSLoader_createNodeFromXML(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_studio_CSLoader_loadNodeWithContent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromXML : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_loadNodeWithContent : Invalid Native Object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_createNodeFromXML : Error processing arguments"); - cocos2d::Node* ret = cobj->createNodeFromXML(arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_loadNodeWithContent : Error processing arguments"); + cocos2d::Node* ret = cobj->loadNodeWithContent(arg0); jsval jsret = JSVAL_NULL; do { if (ret) { @@ -12635,7 +12445,7 @@ bool js_cocos2dx_studio_CSLoader_createNodeFromXML(JSContext *cx, uint32_t argc, return true; } - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_createNodeFromXML : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_loadNodeWithContent : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_studio_CSLoader_isRecordJsonPath(JSContext *cx, uint32_t argc, jsval *vp) @@ -12655,26 +12465,6 @@ bool js_cocos2dx_studio_CSLoader_isRecordJsonPath(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_isRecordJsonPath : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_studio_CSLoader_setRecordProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_setRecordProtocolBuffersPath : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_setRecordProtocolBuffersPath : Error processing arguments"); - cobj->setRecordProtocolBuffersPath(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_setRecordProtocolBuffersPath : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_studio_CSLoader_getJsonPath(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -12712,90 +12502,6 @@ bool js_cocos2dx_studio_CSLoader_setRecordJsonPath(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_setRecordJsonPath : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_studio_CSLoader_setProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_setProtocolBuffersPath : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_setProtocolBuffersPath : Error processing arguments"); - cobj->setProtocolBuffersPath(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_setProtocolBuffersPath : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_CSLoader_purge(JSContext *cx, uint32_t argc, jsval *vp) -{ - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_purge : Invalid Native Object"); - if (argc == 0) { - cobj->purge(); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_purge : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_studio_CSLoader_setXMLPath(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_setXMLPath : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_setXMLPath : Error processing arguments"); - cobj->setXMLPath(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_setXMLPath : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_studio_CSLoader_nodeFromXMLFile(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::CSLoader* cobj = (cocos2d::CSLoader *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_studio_CSLoader_nodeFromXMLFile : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_studio_CSLoader_nodeFromXMLFile : Error processing arguments"); - cocos2d::Node* ret = cobj->nodeFromXMLFile(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Node*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - JS_SET_RVAL(cx, vp, jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_studio_CSLoader_nodeFromXMLFile : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_studio_CSLoader_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) { if (argc == 0) { @@ -12902,27 +12608,16 @@ void js_register_cocos2dx_studio_CSLoader(JSContext *cx, JSObject *global) { }; static JSFunctionSpec funcs[] = { - JS_FN("createNodeFromJson", js_cocos2dx_studio_CSLoader_createNodeFromJson, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("nodeFromXML", js_cocos2dx_studio_CSLoader_nodeFromXML, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createNodeFromProtocolBuffers", js_cocos2dx_studio_CSLoader_createNodeFromProtocolBuffers, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("init", js_cocos2dx_studio_CSLoader_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setRecordXMLPath", js_cocos2dx_studio_CSLoader_setRecordXMLPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setJsonPath", js_cocos2dx_studio_CSLoader_setJsonPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createNodeFromJson", js_cocos2dx_studio_CSLoader_createNodeFromJson, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadNodeWithFile", js_cocos2dx_studio_CSLoader_loadNodeWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("bindCallback", js_cocos2dx_studio_CSLoader_bindCallback, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("purge", js_cocos2dx_studio_CSLoader_purge, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_studio_CSLoader_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadNodeWithContent", js_cocos2dx_studio_CSLoader_loadNodeWithContent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isRecordProtocolBuffersPath", js_cocos2dx_studio_CSLoader_isRecordProtocolBuffersPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isRecordXMLPath", js_cocos2dx_studio_CSLoader_isRecordXMLPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getProtocolBuffersPath", js_cocos2dx_studio_CSLoader_getProtocolBuffersPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getXMLPath", js_cocos2dx_studio_CSLoader_getXMLPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createNodeFromXML", js_cocos2dx_studio_CSLoader_createNodeFromXML, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isRecordJsonPath", js_cocos2dx_studio_CSLoader_isRecordJsonPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setRecordProtocolBuffersPath", js_cocos2dx_studio_CSLoader_setRecordProtocolBuffersPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getJsonPath", js_cocos2dx_studio_CSLoader_getJsonPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setRecordJsonPath", js_cocos2dx_studio_CSLoader_setRecordJsonPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setProtocolBuffersPath", js_cocos2dx_studio_CSLoader_setProtocolBuffersPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("purge", js_cocos2dx_studio_CSLoader_purge, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setXMLPath", js_cocos2dx_studio_CSLoader_setXMLPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("nodeFromXMLFile", js_cocos2dx_studio_CSLoader_nodeFromXMLFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.hpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.hpp index 368a8599b1..edcec9c1e6 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.hpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_studio_auto.hpp @@ -39,9 +39,10 @@ bool js_cocos2dx_studio_ActionManagerEx_constructor(JSContext *cx, uint32_t argc void js_cocos2dx_studio_ActionManagerEx_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ActionManagerEx(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); -bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionManagerEx_stopActionByName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionManagerEx_getActionByName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionManagerEx_initWithBinary(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionManagerEx_playActionByName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionManagerEx_releaseActions(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionManagerEx_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionManagerEx_getInstance(JSContext *cx, uint32_t argc, jsval *vp); @@ -487,16 +488,11 @@ void js_cocos2dx_studio_ActionTimelineCache_finalize(JSContext *cx, JSObject *ob void js_register_cocos2dx_studio_ActionTimelineCache(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); bool js_cocos2dx_studio_ActionTimelineCache_createActionFromJson(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimelineCache_createActionFromProtocolBuffers(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimelineCache_createActionFromXML(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromProtocolBuffers(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFileFromXML(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_purge(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_loadAnimationActionWithContent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_removeAction(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimelineCache_loadActionTimelineFromXML(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_createAction(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimelineCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); @@ -718,25 +714,27 @@ bool js_cocos2dx_studio_ActionTimeline_constructor(JSContext *cx, uint32_t argc, void js_cocos2dx_studio_ActionTimeline_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_ActionTimeline(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); -bool js_cocos2dx_studio_ActionTimeline_getTimelines(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_addTimeline(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_getCurrentFrame(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_getStartFrame(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_pause(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_setFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_resume(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_getDuration(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_addTimeline(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_getEndFrame(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_setCurrentFrame(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_setTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_init(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_setDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_removeTimeline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_setLastFrameCallFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_getTimelines(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_resume(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_getTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_getDuration(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_gotoFrameAndPause(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_isPlaying(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_gotoFrameAndPlay(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_ActionTimeline_removeTimeline(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_clearFrameEventCallFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_getEndFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_setTimeSpeed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_clearLastFrameCallFunc(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_setDuration(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_ActionTimeline_setCurrentFrame(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_ActionTimeline_ActionTimeline(JSContext *cx, uint32_t argc, jsval *vp); @@ -747,27 +745,16 @@ bool js_cocos2dx_studio_CSLoader_constructor(JSContext *cx, uint32_t argc, jsval void js_cocos2dx_studio_CSLoader_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_studio_CSLoader(JSContext *cx, JSObject *global); void register_all_cocos2dx_studio(JSContext* cx, JSObject* obj); -bool js_cocos2dx_studio_CSLoader_createNodeFromJson(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_nodeFromXML(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_createNodeFromProtocolBuffers(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_init(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_setRecordXMLPath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_setJsonPath(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_CSLoader_createNodeFromJson(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_loadNodeWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_CSLoader_bindCallback(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_CSLoader_purge(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_studio_CSLoader_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_loadNodeWithContent(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_isRecordProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_isRecordXMLPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_getProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_getXMLPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_createNodeFromXML(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_isRecordJsonPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_setRecordProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_getJsonPath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_setRecordJsonPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_setProtocolBuffersPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_purge(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_setXMLPath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_studio_CSLoader_nodeFromXMLFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_createNode(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_studio_CSLoader_createTimeline(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.cpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.cpp index 2404620c5c..c05abcbaeb 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -697,21 +697,24 @@ bool js_cocos2dx_ui_Widget_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Widget_setFlippedX : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_Widget_init(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Widget_setCallbackName(JSContext *cx, uint32_t argc, jsval *vp) { + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_init : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->init(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_setCallbackName : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setCallbackName : Error processing arguments"); + cobj->setCallbackName(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Widget_init : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setCallbackName : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_ui_Widget_getVirtualRenderer(JSContext *cx, uint32_t argc, jsval *vp) @@ -964,26 +967,52 @@ bool js_cocos2dx_ui_Widget_getLayoutParameter(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_ui_Widget_getLayoutParameter : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Widget_addCCSEventListener(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_hitTest : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_addCCSEventListener : Invalid Native Object"); if (argc == 1) { - cocos2d::Vec2 arg0; - ok &= jsval_to_vector2(cx, argv[0], &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_hitTest : Error processing arguments"); - bool ret = cobj->hitTest(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - JS_SET_RVAL(cx, vp, jsret); + std::function arg0; + do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](cocos2d::Ref* larg0, int larg1) -> void { + jsval largv[2]; + do { + if (larg0) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); + largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + largv[0] = JSVAL_NULL; + } + } while (0); + largv[1] = int32_to_jsval(cx, larg1); + jsval rval; + bool ok = func->invoke(2, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } + } while(0) + ; + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_addCCSEventListener : Error processing arguments"); + cobj->addCCSEventListener(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Widget_hitTest : wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "js_cocos2dx_ui_Widget_addCCSEventListener : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } bool js_cocos2dx_ui_Widget_getPositionType(JSContext *cx, uint32_t argc, jsval *vp) @@ -1146,6 +1175,23 @@ bool js_cocos2dx_ui_Widget_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *v JS_ReportError(cx, "js_cocos2dx_ui_Widget_isTouchEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Widget_getCallbackName(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_getCallbackName : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getCallbackName(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCallbackName : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Widget_getActionTag(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -1277,6 +1323,23 @@ bool js_cocos2dx_ui_Widget_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Widget_setFlippedY : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Widget_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_init : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_init : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Widget_setEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -1439,6 +1502,42 @@ bool js_cocos2dx_ui_Widget_isBright(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Widget_isBright : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_dispatchFocusEvent : Invalid Native Object"); + if (argc == 2) { + cocos2d::ui::Widget* arg0; + cocos2d::ui::Widget* arg1; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + do { + if (!argv[1].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_dispatchFocusEvent : Error processing arguments"); + cobj->dispatchFocusEvent(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_dispatchFocusEvent : wrong number of arguments: %d, was expecting %d", argc, 2); + return false; +} bool js_cocos2dx_ui_Widget_setUnifySizeEnabled(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -1500,6 +1599,28 @@ bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCurrentFocusedWidget : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_hitTest : Invalid Native Object"); + if (argc == 1) { + cocos2d::Vec2 arg0; + ok &= jsval_to_vector2(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_hitTest : Error processing arguments"); + bool ret = cobj->hitTest(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_hitTest : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Widget_requestFocus(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -1618,42 +1739,21 @@ bool js_cocos2dx_ui_Widget_getSizeType(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Widget_getSizeType : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Widget_getCallbackType(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_interceptTouchEvent : Invalid Native Object"); - if (argc == 3) { - cocos2d::ui::Widget::TouchEventType arg0; - cocos2d::ui::Widget* arg1; - cocos2d::Touch* arg2; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - do { - if (!argv[1].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[1]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); - } while (0); - do { - if (!argv[2].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg2 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_interceptTouchEvent : Error processing arguments"); - cobj->interceptTouchEvent(arg0, arg1, arg2); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_getCallbackType : Invalid Native Object"); + if (argc == 0) { + const std::string& ret = cobj->getCallbackType(); + jsval jsret = JSVAL_NULL; + jsret = std_string_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Widget_interceptTouchEvent : wrong number of arguments: %d, was expecting %d", argc, 3); + JS_ReportError(cx, "js_cocos2dx_ui_Widget_getCallbackType : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_ui_Widget_getTouchEndPosition(JSContext *cx, uint32_t argc, jsval *vp) @@ -1739,10 +1839,12 @@ bool js_cocos2dx_ui_Widget_addClickEventListener(JSContext *cx, uint32_t argc, j if (argc == 1) { std::function arg0; do { - std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); - auto lambda = [=](cocos2d::Ref* larg0) -> void { - jsval largv[1]; - do { + if(JS_TypeOfValue(cx, argv[0]) == JSTYPE_FUNCTION) + { + std::shared_ptr func(new JSFunctionWrapper(cx, JS_THIS_OBJECT(cx, vp), argv[0])); + auto lambda = [=](cocos2d::Ref* larg0) -> void { + jsval largv[1]; + do { if (larg0) { js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Ref*)larg0); largv[0] = OBJECT_TO_JSVAL(jsProxy->obj); @@ -1750,13 +1852,18 @@ bool js_cocos2dx_ui_Widget_addClickEventListener(JSContext *cx, uint32_t argc, j largv[0] = JSVAL_NULL; } } while (0); - jsval rval; - bool ok = func->invoke(1, &largv[0], rval); - if (!ok && JS_IsExceptionPending(cx)) { - JS_ReportPendingException(cx); - } - }; - arg0 = lambda; + jsval rval; + bool ok = func->invoke(1, &largv[0], rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + arg0 = lambda; + } + else + { + arg0 = nullptr; + } } while(0) ; JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_addClickEventListener : Error processing arguments"); @@ -1844,25 +1951,19 @@ bool js_cocos2dx_ui_Widget_setSizeType(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Widget_setSizeType : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_dispatchFocusEvent : Invalid Native Object"); - if (argc == 2) { - cocos2d::ui::Widget* arg0; + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_interceptTouchEvent : Invalid Native Object"); + if (argc == 3) { + cocos2d::ui::Widget::TouchEventType arg0; cocos2d::ui::Widget* arg1; - do { - if (!argv[0].isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); + cocos2d::Touch* arg2; + ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); do { if (!argv[1].isObject()) { ok = false; break; } js_proxy_t *jsProxy; @@ -1871,13 +1972,21 @@ bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsva arg1 = (cocos2d::ui::Widget*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_dispatchFocusEvent : Error processing arguments"); - cobj->dispatchFocusEvent(arg0, arg1); + do { + if (!argv[2].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[2]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg2 = (cocos2d::Touch*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg2, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_interceptTouchEvent : Error processing arguments"); + cobj->interceptTouchEvent(arg0, arg1, arg2); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } - JS_ReportError(cx, "js_cocos2dx_ui_Widget_dispatchFocusEvent : wrong number of arguments: %d, was expecting %d", argc, 2); + JS_ReportError(cx, "js_cocos2dx_ui_Widget_interceptTouchEvent : wrong number of arguments: %d, was expecting %d", argc, 3); return false; } bool js_cocos2dx_ui_Widget_setBright(JSContext *cx, uint32_t argc, jsval *vp) @@ -1900,6 +2009,26 @@ bool js_cocos2dx_ui_Widget_setBright(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Widget_setBright : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Widget_setCallbackType(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Widget* cobj = (cocos2d::ui::Widget *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Widget_setCallbackType : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Widget_setCallbackType : Error processing arguments"); + cobj->setCallbackType(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Widget_setCallbackType : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Widget_isSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); @@ -2025,7 +2154,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JSObject *global) { JS_FN("getCustomSize", js_cocos2dx_ui_Widget_getCustomSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLeftBoundary", js_cocos2dx_ui_Widget_getLeftBoundary, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFlippedX", js_cocos2dx_ui_Widget_setFlippedX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("_init", js_cocos2dx_ui_Widget_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCallbackName", js_cocos2dx_ui_Widget_setCallbackName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVirtualRenderer", js_cocos2dx_ui_Widget_getVirtualRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setPropagateTouchEvents", js_cocos2dx_ui_Widget_setPropagateTouchEvents, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isUnifySizeEnabled", js_cocos2dx_ui_Widget_isUnifySizeEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2039,7 +2168,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JSObject *global) { JS_FN("getVirtualRendererSize", js_cocos2dx_ui_Widget_getVirtualRendererSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isHighlighted", js_cocos2dx_ui_Widget_isHighlighted, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLayoutParameter", js_cocos2dx_ui_Widget_getLayoutParameter, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("hitTest", js_cocos2dx_ui_Widget_hitTest, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addCCSEventListener", js_cocos2dx_ui_Widget_addCCSEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionType", js_cocos2dx_ui_Widget_getPositionType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTopBoundary", js_cocos2dx_ui_Widget_getTopBoundary, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ignoreContentAdaptWithSize", js_cocos2dx_ui_Widget_ignoreContentAdaptWithSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2048,6 +2177,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JSObject *global) { JS_FN("isFocused", js_cocos2dx_ui_Widget_isFocused, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchBeganPosition", js_cocos2dx_ui_Widget_getTouchBeganPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchEnabled", js_cocos2dx_ui_Widget_isTouchEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCallbackName", js_cocos2dx_ui_Widget_getCallbackName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getActionTag", js_cocos2dx_ui_Widget_getActionTag, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getWorldPosition", js_cocos2dx_ui_Widget_getWorldPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isFocusEnabled", js_cocos2dx_ui_Widget_isFocusEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2055,6 +2185,7 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JSObject *global) { JS_FN("setActionTag", js_cocos2dx_ui_Widget_setActionTag, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchEnabled", js_cocos2dx_ui_Widget_setTouchEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFlippedY", js_cocos2dx_ui_Widget_setFlippedY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("_init", js_cocos2dx_ui_Widget_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEnabled", js_cocos2dx_ui_Widget_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getRightBoundary", js_cocos2dx_ui_Widget_getRightBoundary, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBrightStyle", js_cocos2dx_ui_Widget_setBrightStyle, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2063,15 +2194,17 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JSObject *global) { JS_FN("setFocusEnabled", js_cocos2dx_ui_Widget_setFocusEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBottomBoundary", js_cocos2dx_ui_Widget_getBottomBoundary, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isBright", js_cocos2dx_ui_Widget_isBright, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("dispatchFocusEvent", js_cocos2dx_ui_Widget_dispatchFocusEvent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUnifySizeEnabled", js_cocos2dx_ui_Widget_setUnifySizeEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isPropagateTouchEvents", js_cocos2dx_ui_Widget_isPropagateTouchEvents, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentFocusedWidget", js_cocos2dx_ui_Widget_getCurrentFocusedWidget, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hitTest", js_cocos2dx_ui_Widget_hitTest, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestFocus", js_cocos2dx_ui_Widget_requestFocus, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("updateSizeAndPosition", js_cocos2dx_ui_Widget_updateSizeAndPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("onFocusChange", js_cocos2dx_ui_Widget_onFocusChange, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchMovePosition", js_cocos2dx_ui_Widget_getTouchMovePosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getSizeType", js_cocos2dx_ui_Widget_getSizeType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("interceptTouchEvent", js_cocos2dx_ui_Widget_interceptTouchEvent, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCallbackType", js_cocos2dx_ui_Widget_getCallbackType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTouchEndPosition", js_cocos2dx_ui_Widget_getTouchEndPosition, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPositionPercent", js_cocos2dx_ui_Widget_getPositionPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("propagateTouchEvent", js_cocos2dx_ui_Widget_propagateTouchEvent, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -2080,8 +2213,9 @@ void js_register_cocos2dx_ui_Widget(JSContext *cx, JSObject *global) { JS_FN("isFlippedY", js_cocos2dx_ui_Widget_isFlippedY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isClippingParentContainsPoint", js_cocos2dx_ui_Widget_isClippingParentContainsPoint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSizeType", js_cocos2dx_ui_Widget_setSizeType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("dispatchFocusEvent", js_cocos2dx_ui_Widget_dispatchFocusEvent, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("interceptTouchEvent", js_cocos2dx_ui_Widget_interceptTouchEvent, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBright", js_cocos2dx_ui_Widget_setBright, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCallbackType", js_cocos2dx_ui_Widget_setCallbackType, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isSwallowTouches", js_cocos2dx_ui_Widget_isSwallowTouches, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2d_ui_Widget_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END @@ -11206,6 +11340,1218 @@ void js_register_cocos2dx_ui_RelativeBox(JSContext *cx, JSObject *global) { } } +JSClass *jsb_cocos2d_ui_Scale9Sprite_class; +JSObject *jsb_cocos2d_ui_Scale9Sprite_prototype; + +bool js_cocos2dx_ui_Scale9Sprite_disableCascadeColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_disableCascadeColor : Invalid Native Object"); + if (argc == 0) { + cobj->disableCascadeColor(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_disableCascadeColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_updateWithSprite : Invalid Native Object"); + do { + if (argc == 6) { + cocos2d::Sprite* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, argv[3], &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, argv[4], &arg4); + if (!ok) { ok = true; break; } + cocos2d::Rect arg5; + ok &= jsval_to_ccrect(cx, argv[5], &arg5); + if (!ok) { ok = true; break; } + bool ret = cobj->updateWithSprite(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); + cocos2d::Rect arg3; + ok &= jsval_to_ccrect(cx, argv[3], &arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->updateWithSprite(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_updateWithSprite : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_isFlippedX : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFlippedX(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_isFlippedX : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setFlippedY : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setFlippedY : Error processing arguments"); + cobj->setFlippedY(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setFlippedY : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setFlippedX : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setFlippedX : Error processing arguments"); + cobj->setFlippedX(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setFlippedX : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setScale9Enabled : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(JS::RootedValue(cx, argv[0])); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setScale9Enabled : Error processing arguments"); + cobj->setScale9Enabled(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_disableCascadeOpacity(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_disableCascadeOpacity : Invalid Native Object"); + if (argc == 0) { + cobj->disableCascadeOpacity(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_disableCascadeOpacity : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetBottom : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetBottom : Error processing arguments"); + cobj->setInsetBottom(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setInsetBottom : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName : Invalid Native Object"); + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSpriteFrameName(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSpriteFrameName(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getSprite(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getSprite : Invalid Native Object"); + if (argc == 0) { + cocos2d::Sprite* ret = cobj->getSprite(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getSprite : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetTop : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetTop : Error processing arguments"); + cobj->setInsetTop(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setInsetTop : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_init : Invalid Native Object"); + do { + if (argc == 4) { + cocos2d::Sprite* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); + cocos2d::Rect arg3; + ok &= jsval_to_ccrect(cx, argv[3], &arg3); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0, arg1, arg2, arg3); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 0) { + bool ret = cobj->init(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + cocos2d::Sprite* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cocos2d::Rect arg2; + ok &= jsval_to_ccrect(cx, argv[2], &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 6) { + cocos2d::Sprite* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(JS::RootedValue(cx, argv[2])); + cocos2d::Vec2 arg3; + ok &= jsval_to_vector2(cx, argv[3], &arg3); + if (!ok) { ok = true; break; } + cocos2d::Size arg4; + ok &= jsval_to_ccsize(cx, argv[4], &arg4); + if (!ok) { ok = true; break; } + cocos2d::Rect arg5; + ok &= jsval_to_ccrect(cx, argv[5], &arg5); + if (!ok) { ok = true; break; } + bool ret = cobj->init(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_init : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setPreferredSize : Invalid Native Object"); + if (argc == 1) { + cocos2d::Size arg0; + ok &= jsval_to_ccsize(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setPreferredSize : Error processing arguments"); + cobj->setPreferredSize(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getInsetRight : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getInsetRight(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getInsetRight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setSpriteFrame : Invalid Native Object"); + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setSpriteFrame : Error processing arguments"); + cobj->setSpriteFrame(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + cocos2d::Rect arg1; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setSpriteFrame : Error processing arguments"); + cobj->setSpriteFrame(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setSpriteFrame : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getInsetBottom : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getInsetBottom(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getInsetBottom : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_resizableSpriteWithCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_resizableSpriteWithCapInsets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_resizableSpriteWithCapInsets : Error processing arguments"); + cocos2d::ui::Scale9Sprite* ret = cobj->resizableSpriteWithCapInsets(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_resizableSpriteWithCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_isScale9Enabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isScale9Enabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_isScale9Enabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getCapInsets : Invalid Native Object"); + if (argc == 0) { + cocos2d::Rect ret = cobj->getCapInsets(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getCapInsets : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getOriginalSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getOriginalSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getOriginalSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithFile : Invalid Native Object"); + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cocos2d::Rect arg2; + ok &= jsval_to_ccrect(cx, argv[2], &arg2); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_initWithFile : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getInsetTop(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getInsetTop : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getInsetTop(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getInsetTop : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setInsetLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetLeft : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetLeft : Error processing arguments"); + cobj->setInsetLeft(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setInsetLeft : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + JSObject *obj = NULL; + cocos2d::ui::Scale9Sprite* cobj = NULL; + obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame : Invalid Native Object"); + do { + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSpriteFrame(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + do { + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + bool ret = cobj->initWithSpriteFrame(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while(0); + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getPreferredSize : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getPreferredSize(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getPreferredSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setCapInsets : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, argv[0], &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setCapInsets : Error processing arguments"); + cobj->setCapInsets(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setCapInsets : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_isFlippedY : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isFlippedY(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_isFlippedY : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_getInsetLeft(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_getInsetLeft : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getInsetLeft(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_getInsetLeft : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_setInsetRight(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Scale9Sprite* cobj = (cocos2d::ui::Scale9Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetRight : Invalid Native Object"); + if (argc == 1) { + double arg0; + ok &= JS::ToNumber( cx, JS::RootedValue(cx, argv[0]), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Scale9Sprite_setInsetRight : Error processing arguments"); + cobj->setInsetRight(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_setInsetRight : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + do { + if (argc == 3) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cocos2d::Rect arg2; + ok &= jsval_to_ccrect(cx, argv[2], &arg2); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + std::string arg1; + ok &= jsval_to_std_string(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_create : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrameName(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, argv[0], &arg0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrameName(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrameName : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + + do { + if (argc == 2) { + cocos2d::SpriteFrame* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, argv[1], &arg1); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrame(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + + do { + if (argc == 1) { + cocos2d::SpriteFrame* arg0; + do { + if (!argv[0].isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* ret = cocos2d::ui::Scale9Sprite::createWithSpriteFrame(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::ui::Scale9Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame : wrong number of arguments"); + return false; +} +bool js_cocos2dx_ui_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + bool ok = true; + cocos2d::ui::Scale9Sprite* cobj = new (std::nothrow) cocos2d::ui::Scale9Sprite(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Scale9Sprite"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); + return true; +} + + +extern JSObject *jsb_cocos2d_Node_prototype; + +void js_cocos2d_ui_Scale9Sprite_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Scale9Sprite)", obj); +} + +static bool js_cocos2d_ui_Scale9Sprite_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + cocos2d::ui::Scale9Sprite *nobj = new (std::nothrow) cocos2d::ui::Scale9Sprite(); + if (nobj) { + nobj->autorelease(); + } + js_proxy_t* p = jsb_new_proxy(nobj, obj); + JS_AddNamedObjectRoot(cx, &p->obj, "cocos2d::ui::Scale9Sprite"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", argc, argv); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return true; +} +void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JSObject *global) { + jsb_cocos2d_ui_Scale9Sprite_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_ui_Scale9Sprite_class->name = "Scale9Sprite"; + jsb_cocos2d_ui_Scale9Sprite_class->addProperty = JS_PropertyStub; + jsb_cocos2d_ui_Scale9Sprite_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_ui_Scale9Sprite_class->getProperty = JS_PropertyStub; + jsb_cocos2d_ui_Scale9Sprite_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_ui_Scale9Sprite_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_ui_Scale9Sprite_class->resolve = JS_ResolveStub; + jsb_cocos2d_ui_Scale9Sprite_class->convert = JS_ConvertStub; + jsb_cocos2d_ui_Scale9Sprite_class->finalize = js_cocos2d_ui_Scale9Sprite_finalize; + jsb_cocos2d_ui_Scale9Sprite_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + {"__nativeObj", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT, JSOP_WRAPPER(js_is_native_obj), JSOP_NULLWRAPPER}, + {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} + }; + + static JSFunctionSpec funcs[] = { + JS_FN("disableCascadeColor", js_cocos2dx_ui_Scale9Sprite_disableCascadeColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("updateWithSprite", js_cocos2dx_ui_Scale9Sprite_updateWithSprite, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFlippedX", js_cocos2dx_ui_Scale9Sprite_isFlippedX, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFlippedY", js_cocos2dx_ui_Scale9Sprite_setFlippedY, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setFlippedX", js_cocos2dx_ui_Scale9Sprite_setFlippedX, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setScale9Enabled", js_cocos2dx_ui_Scale9Sprite_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("disableCascadeOpacity", js_cocos2dx_ui_Scale9Sprite_disableCascadeOpacity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInsetBottom", js_cocos2dx_ui_Scale9Sprite_setInsetBottom, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSpriteFrameName", js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSprite", js_cocos2dx_ui_Scale9Sprite_getSprite, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInsetTop", js_cocos2dx_ui_Scale9Sprite_setInsetTop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", js_cocos2dx_ui_Scale9Sprite_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setPreferredSize", js_cocos2dx_ui_Scale9Sprite_setPreferredSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsetRight", js_cocos2dx_ui_Scale9Sprite_getInsetRight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSpriteFrame", js_cocos2dx_ui_Scale9Sprite_setSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsetBottom", js_cocos2dx_ui_Scale9Sprite_getInsetBottom, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("resizableSpriteWithCapInsets", js_cocos2dx_ui_Scale9Sprite_resizableSpriteWithCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isScale9Enabled", js_cocos2dx_ui_Scale9Sprite_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsets", js_cocos2dx_ui_Scale9Sprite_getCapInsets, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOriginalSize", js_cocos2dx_ui_Scale9Sprite_getOriginalSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithFile", js_cocos2dx_ui_Scale9Sprite_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsetTop", js_cocos2dx_ui_Scale9Sprite_getInsetTop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInsetLeft", js_cocos2dx_ui_Scale9Sprite_setInsetLeft, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithSpriteFrame", js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getPreferredSize", js_cocos2dx_ui_Scale9Sprite_getPreferredSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsets", js_cocos2dx_ui_Scale9Sprite_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isFlippedY", js_cocos2dx_ui_Scale9Sprite_isFlippedY, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getInsetLeft", js_cocos2dx_ui_Scale9Sprite_getInsetLeft, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setInsetRight", js_cocos2dx_ui_Scale9Sprite_setInsetRight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("ctor", js_cocos2d_ui_Scale9Sprite_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("create", js_cocos2dx_ui_Scale9Sprite_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrameName", js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("createWithSpriteFrame", js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_ui_Scale9Sprite_prototype = JS_InitClass( + cx, global, + jsb_cocos2d_Node_prototype, + jsb_cocos2d_ui_Scale9Sprite_class, + js_cocos2dx_ui_Scale9Sprite_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "Scale9Sprite", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_ui_Scale9Sprite_class; + p->proto = jsb_cocos2d_ui_Scale9Sprite_prototype; + p->parentProto = jsb_cocos2d_Node_prototype; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + JSClass *jsb_cocos2d_ui_EditBox_class; JSObject *jsb_cocos2d_ui_EditBox_prototype; @@ -11934,6 +13280,7 @@ void register_all_cocos2dx_ui(JSContext* cx, JSObject* obj) { js_register_cocos2dx_ui_TextBMFont(cx, obj); js_register_cocos2dx_ui_LoadingBar(cx, obj); js_register_cocos2dx_ui_TextField(cx, obj); + js_register_cocos2dx_ui_Scale9Sprite(cx, obj); js_register_cocos2dx_ui_VBox(cx, obj); js_register_cocos2dx_ui_RichElement(cx, obj); js_register_cocos2dx_ui_RichElementCustomNode(cx, obj); diff --git a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.hpp b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.hpp index 780c28be60..979a6acded 100644 --- a/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/frameworks/js-bindings/bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -58,7 +58,7 @@ bool js_cocos2dx_ui_Widget_setSizePercent(JSContext *cx, uint32_t argc, jsval *v bool js_cocos2dx_ui_Widget_getCustomSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getLeftBoundary(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Widget_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_setCallbackName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getVirtualRenderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setPropagateTouchEvents(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isUnifySizeEnabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -72,7 +72,7 @@ bool js_cocos2dx_ui_Widget_isIgnoreContentAdaptWithSize(JSContext *cx, uint32_t bool js_cocos2dx_ui_Widget_getVirtualRendererSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isHighlighted(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getLayoutParameter(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_addCCSEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getPositionType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getTopBoundary(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_ignoreContentAdaptWithSize(JSContext *cx, uint32_t argc, jsval *vp); @@ -81,6 +81,7 @@ bool js_cocos2dx_ui_Widget_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isFocused(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getTouchBeganPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_getCallbackName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getActionTag(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getWorldPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isFocusEnabled(JSContext *cx, uint32_t argc, jsval *vp); @@ -88,6 +89,7 @@ bool js_cocos2dx_ui_Widget_setFocused(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setActionTag(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setTouchEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_init(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getRightBoundary(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setBrightStyle(JSContext *cx, uint32_t argc, jsval *vp); @@ -96,15 +98,17 @@ bool js_cocos2dx_ui_Widget_clone(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setFocusEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getBottomBoundary(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isBright(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setUnifySizeEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isPropagateTouchEvents(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getCurrentFocusedWidget(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_hitTest(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_requestFocus(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_updateSizeAndPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_onFocusChange(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getTouchMovePosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getSizeType(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_getCallbackType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getTouchEndPosition(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_getPositionPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_propagateTouchEvent(JSContext *cx, uint32_t argc, jsval *vp); @@ -113,8 +117,9 @@ bool js_cocos2dx_ui_Widget_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isClippingParentContainsPoint(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setSizeType(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Widget_dispatchFocusEvent(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_interceptTouchEvent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_setBright(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Widget_setCallbackType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_isSwallowTouches(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_enableDpadNavigation(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Widget_create(JSContext *cx, uint32_t argc, jsval *vp); @@ -601,6 +606,47 @@ bool js_cocos2dx_ui_RelativeBox_initWithSize(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_ui_RelativeBox_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_RelativeBox_RelativeBox(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocos2d_ui_Scale9Sprite_class; +extern JSObject *jsb_cocos2d_ui_Scale9Sprite_prototype; + +bool js_cocos2dx_ui_Scale9Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_ui_Scale9Sprite_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_ui_Scale9Sprite(JSContext *cx, JSObject *global); +void register_all_cocos2dx_ui(JSContext* cx, JSObject* obj); +bool js_cocos2dx_ui_Scale9Sprite_disableCascadeColor(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_updateWithSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setFlippedY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setFlippedX(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_disableCascadeOpacity(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getSprite(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setInsetTop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getInsetRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getInsetBottom(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_resizableSpriteWithCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getOriginalSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getInsetTop(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setInsetLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getPreferredSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_getInsetLeft(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_setInsetRight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_create(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Scale9Sprite_Scale9Sprite(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocos2d_ui_EditBox_class; extern JSObject *jsb_cocos2d_ui_EditBox_prototype; diff --git a/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp b/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp index a10a402f29..439a63c37d 100644 --- a/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp +++ b/frameworks/js-bindings/bindings/manual/ScriptingCore.cpp @@ -354,6 +354,24 @@ bool JSBCore_os(JSContext *cx, uint32_t argc, jsval *vp) return true; }; +bool JSB_cleanScript(JSContext *cx, uint32_t argc, jsval *vp) +{ + if (argc != 1) + { + JS_ReportError(cx, "Invalid number of arguments in JSB_cleanScript"); + return false; + } + jsval *argv = JS_ARGV(cx, vp); + JSString *jsPath = JSVAL_TO_STRING(argv[0]); + JSB_PRECONDITION2(jsPath, cx, false, "Error js file in clean script"); + JSStringWrapper wrapper(jsPath); + ScriptingCore::getInstance()->cleanScript(wrapper.get()); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + + return true; +}; + bool JSB_core_restartVM(JSContext *cx, uint32_t argc, jsval *vp) { JSB_PRECONDITION2(argc==0, cx, false, "Invalid number of arguments in executeScript"); @@ -394,11 +412,12 @@ void registerDefaultClasses(JSContext* cx, JSObject* global) { JS_DefineFunction(cx, global, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT); - + JS_DefineFunction(cx, global, "__getPlatform", JSBCore_platform, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getOS", JSBCore_os, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__getVersion", JSBCore_version, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, global, "__restartVM", JSB_core_restartVM, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE ); + JS_DefineFunction(cx, global, "__cleanScript", JSB_cleanScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); } static void sc_finalize(JSFreeOp *freeOp, JSObject *obj) { @@ -422,6 +441,11 @@ ScriptingCore::ScriptingCore() // set utf8 strings internally (we don't need utf16) // XXX: Removed in SpiderMonkey 19.0 //JS_SetCStringsAreUTF8(); + initRegister(); +} + +void ScriptingCore::initRegister() +{ this->addRegisterCallback(registerDefaultClasses); this->_runLoop = new SimpleRunLoop(); } @@ -576,12 +600,12 @@ JSScript* ScriptingCore::getScript(const char *path) { // a) check jsc file first std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT; - if (filename_script[byteCodePath]) + if (filename_script.find(byteCodePath) != filename_script.end()) return filename_script[byteCodePath]; // b) no jsc file, check js file std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(path); - if (filename_script[fullPath]) + if (filename_script.find(fullPath) != filename_script.end()) return filename_script[fullPath]; return NULL; @@ -703,9 +727,15 @@ bool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* cx) } void ScriptingCore::reset() +{ + Director::getInstance()->restart(); +} + +void ScriptingCore::restartVM() { cleanup(); - start(); + initRegister(); + CCApplication::getInstance()->applicationDidFinishLaunching(); } ScriptingCore::~ScriptingCore() @@ -741,6 +771,7 @@ void ScriptingCore::cleanup() _js_global_type_map.clear(); filename_script.clear(); + registrationList.clear(); } void ScriptingCore::reportError(JSContext *cx, const char *message, JSErrorReport *report) @@ -1344,6 +1375,13 @@ int ScriptingCore::sendEvent(ScriptEvent* evt) if (NULL == evt) return 0; + // special type, can't use this code after JSAutoCompartment + if (evt->type == kRestartGame) + { + restartVM(); + return 0; + } + JSAutoCompartment ac(_cx, _global); switch (evt->type) diff --git a/frameworks/js-bindings/bindings/manual/ScriptingCore.h b/frameworks/js-bindings/bindings/manual/ScriptingCore.h index 0ae50e5a18..96c2292fed 100644 --- a/frameworks/js-bindings/bindings/manual/ScriptingCore.h +++ b/frameworks/js-bindings/bindings/manual/ScriptingCore.h @@ -37,7 +37,7 @@ #include #include -#define ENGINE_VERSION "Cocos2d-JS v3.1" +#define ENGINE_VERSION "Cocos2d-JS v3.2" void js_log(const char *format, ...); @@ -247,7 +247,7 @@ class ScriptingCore : public cocos2d::ScriptEngineProtocol private: void string_report(jsval val); - + void initRegister(); public: int handleNodeEvent(void* data); int handleComponentEvent(void* data); @@ -257,6 +257,8 @@ class ScriptingCore : public cocos2d::ScriptEngineProtocol bool handleTouchEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, cocos2d::Touch* touch, cocos2d::Event* event, jsval* jsvalRet = nullptr); bool handleMouseEvent(void* nativeObj, cocos2d::EventMouse::MouseEventType eventType, cocos2d::Event* event, jsval* jsvalRet = nullptr); bool handleKeybardEvent(void* nativeObj, cocos2d::EventKeyboard::KeyCode keyCode, bool isPressed, cocos2d::Event* event); + + void restartVM(); }; JSObject* NewGlobalObject(JSContext* cx, bool debug = false); diff --git a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp index 745648346c..2857be8b8f 100644 --- a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp +++ b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.cpp @@ -2433,6 +2433,62 @@ bool JSB_cpArbiter_totalKE(JSContext *cx, uint32_t argc, jsval *vp) { return true; } +bool js_get_cpArbiter_a(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpShape* shape = arbiter->a; + if(shape){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(shape); + if(jsobj){ + vp.set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + +bool js_get_cpArbiter_b(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpShape* shape = arbiter->b; + if(shape){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(shape); + if(jsobj){ + vp.set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + +bool js_get_cpArbiter_body_a(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpBody* body = arbiter->body_a; + if(body){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(body); + if(jsobj){ + vp.set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + +bool js_get_cpArbiter_body_b(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpArbiter* arbiter = (cpArbiter*) proxy->handle; + cpBody* body = arbiter->body_b; + if(body){ + JSObject* jsobj = jsb_get_jsobject_for_proxy(body); + if(jsobj){ + vp.set(OBJECT_TO_JSVAL(jsobj)); + return true; + } + } + return false; +} + void JSB_cpArbiter_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpArbiter_class = (JSClass *)calloc(1, sizeof(JSClass)); @@ -2448,6 +2504,10 @@ void JSB_cpArbiter_createClass(JSContext *cx, JSObject* globalObj, const char* n JSB_cpArbiter_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { + {"a", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpArbiter_a), JSOP_NULLWRAPPER}, + {"b", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpArbiter_b), JSOP_NULLWRAPPER}, + {"body_a", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpArbiter_body_a), JSOP_NULLWRAPPER}, + {"body_b", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpArbiter_body_b), JSOP_NULLWRAPPER}, {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { @@ -3108,70 +3168,76 @@ bool JSB_cpSpace_useSpatialHash(JSContext *cx, uint32_t argc, jsval *vp) { void JSB_cpSpace_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { - JSB_cpSpace_class = (JSClass *)calloc(1, sizeof(JSClass)); - JSB_cpSpace_class->name = name; - JSB_cpSpace_class->addProperty = JS_PropertyStub; - JSB_cpSpace_class->delProperty = JS_DeletePropertyStub; - JSB_cpSpace_class->getProperty = JS_PropertyStub; - JSB_cpSpace_class->setProperty = JS_StrictPropertyStub; - JSB_cpSpace_class->enumerate = JS_EnumerateStub; - JSB_cpSpace_class->resolve = JS_ResolveStub; - JSB_cpSpace_class->convert = JS_ConvertStub; - JSB_cpSpace_class->finalize = JSB_cpSpace_finalize; - JSB_cpSpace_class->flags = JSCLASS_HAS_PRIVATE; - - static JSPropertySpec properties[] = { - {0, 0, 0, 0, 0} - }; - static JSFunctionSpec funcs[] = { - JS_FN("activateShapesTouchingShape", JSB_cpSpace_activateShapesTouchingShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("containsBody", JSB_cpSpace_containsBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("containsConstraint", JSB_cpSpace_containsConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("containsShape", JSB_cpSpace_containsShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("destroy", JSB_cpSpace_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCollisionBias", JSB_cpSpace_getCollisionBias, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCollisionPersistence", JSB_cpSpace_getCollisionPersistence, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCollisionSlop", JSB_cpSpace_getCollisionSlop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCurrentTimeStep", JSB_cpSpace_getCurrentTimeStep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getDamping", JSB_cpSpace_getDamping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getEnableContactGraph", JSB_cpSpace_getEnableContactGraph, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getGravity", JSB_cpSpace_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getIdleSpeedThreshold", JSB_cpSpace_getIdleSpeedThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getIterations", JSB_cpSpace_getIterations, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getSleepTimeThreshold", JSB_cpSpace_getSleepTimeThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getStaticBody", JSB_cpSpace_getStaticBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("init", JSB_cpSpace_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isLocked", JSB_cpSpace_isLocked, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("pointQueryFirst", JSB_cpSpace_pointQueryFirst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("reindexShape", JSB_cpSpace_reindexShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("reindexShapesForBody", JSB_cpSpace_reindexShapesForBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("reindexStatic", JSB_cpSpace_reindexStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCollisionBias", JSB_cpSpace_setCollisionBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCollisionPersistence", JSB_cpSpace_setCollisionPersistence, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCollisionSlop", JSB_cpSpace_setCollisionSlop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setDamping", JSB_cpSpace_setDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setEnableContactGraph", JSB_cpSpace_setEnableContactGraph, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setGravity", JSB_cpSpace_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setIdleSpeedThreshold", JSB_cpSpace_setIdleSpeedThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setIterations", JSB_cpSpace_setIterations, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setSleepTimeThreshold", JSB_cpSpace_setSleepTimeThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("step", JSB_cpSpace_step, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("useSpatialHash", JSB_cpSpace_useSpatialHash, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("addShape", JSB_cpSpace_addShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("addCollisionHandler", JSB_cpSpace_addCollisionHandler, 7, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("addStaticShape", JSB_cpSpace_addStaticShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeConstraint", JSB_cpSpace_removeConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeBody", JSB_cpSpace_removeBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeCollisionHandler", JSB_cpSpace_removeCollisionHandler, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeStaticShape", JSB_cpSpace_removeStaticShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("addConstraint", JSB_cpSpace_addConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("addBody", JSB_cpSpace_addBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeShape", JSB_cpSpace_removeShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - static JSFunctionSpec st_funcs[] = { - JS_FS_END - }; + JSB_cpSpace_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpSpace_class->name = name; + JSB_cpSpace_class->addProperty = JS_PropertyStub; + JSB_cpSpace_class->delProperty = JS_DeletePropertyStub; + JSB_cpSpace_class->getProperty = JS_PropertyStub; + JSB_cpSpace_class->setProperty = JS_StrictPropertyStub; + JSB_cpSpace_class->enumerate = JS_EnumerateStub; + JSB_cpSpace_class->resolve = JS_ResolveStub; + JSB_cpSpace_class->convert = JS_ConvertStub; + JSB_cpSpace_class->finalize = JSB_cpSpace_finalize; + JSB_cpSpace_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + { 0, 0, 0, 0, 0 } + }; + static JSFunctionSpec funcs[] = { + JS_FN("activateShapesTouchingShape", JSB_cpSpace_activateShapesTouchingShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("containsBody", JSB_cpSpace_containsBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("containsConstraint", JSB_cpSpace_containsConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("containsShape", JSB_cpSpace_containsShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("destroy", JSB_cpSpace_destroy, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCollisionBias", JSB_cpSpace_getCollisionBias, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCollisionPersistence", JSB_cpSpace_getCollisionPersistence, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCollisionSlop", JSB_cpSpace_getCollisionSlop, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCurrentTimeStep", JSB_cpSpace_getCurrentTimeStep, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDamping", JSB_cpSpace_getDamping, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEnableContactGraph", JSB_cpSpace_getEnableContactGraph, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getGravity", JSB_cpSpace_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIdleSpeedThreshold", JSB_cpSpace_getIdleSpeedThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getIterations", JSB_cpSpace_getIterations, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSleepTimeThreshold", JSB_cpSpace_getSleepTimeThreshold, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getStaticBody", JSB_cpSpace_getStaticBody, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("init", JSB_cpSpace_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isLocked", JSB_cpSpace_isLocked, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pointQueryFirst", JSB_cpSpace_pointQueryFirst, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reindexShape", JSB_cpSpace_reindexShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reindexShapesForBody", JSB_cpSpace_reindexShapesForBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("reindexStatic", JSB_cpSpace_reindexStatic, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCollisionBias", JSB_cpSpace_setCollisionBias, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCollisionPersistence", JSB_cpSpace_setCollisionPersistence, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCollisionSlop", JSB_cpSpace_setCollisionSlop, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDamping", JSB_cpSpace_setDamping, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setEnableContactGraph", JSB_cpSpace_setEnableContactGraph, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setGravity", JSB_cpSpace_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIdleSpeedThreshold", JSB_cpSpace_setIdleSpeedThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setIterations", JSB_cpSpace_setIterations, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setSleepTimeThreshold", JSB_cpSpace_setSleepTimeThreshold, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("step", JSB_cpSpace_step, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("useSpatialHash", JSB_cpSpace_useSpatialHash, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addShape", JSB_cpSpace_addShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addCollisionHandler", JSB_cpSpace_addCollisionHandler, 6, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setDefaultCollisionHandler", JSB_cpSpace_setDefaultCollisionHandler, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addStaticShape", JSB_cpSpace_addStaticShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeConstraint", JSB_cpSpace_removeConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeBody", JSB_cpSpace_removeBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeCollisionHandler", JSB_cpSpace_removeCollisionHandler, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeStaticShape", JSB_cpSpace_removeStaticShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addConstraint", JSB_cpSpace_addConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addBody", JSB_cpSpace_addBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("removeShape", JSB_cpSpace_removeShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("pointQuery", JSB_cpSpace_pointQuery, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("nearestPointQuery", JSB_cpSpace_nearestPointQuery, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("segmentQuery", JSB_cpSpace_segmentQuery, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("bbQuery", JSB_cpSpace_bbQuery, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("addPostStepCallback", JSB_cpSpace_addPostStepCallback, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; JSB_cpSpace_object = JS_InitClass(cx, globalObj, JSB_cpBase_object, JSB_cpSpace_class, JSB_cpSpace_constructor,0,properties,funcs,NULL,st_funcs); // bool found; @@ -3976,6 +4042,38 @@ bool JSB_cpBody_world2Local(JSContext *cx, uint32_t argc, jsval *vp) { return true; } +bool js_get_cpBody_vx(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpBody* body = (cpBody*) proxy->handle; + vp.set(DOUBLE_TO_JSVAL(body->v.x)); + return true; +} + +bool js_get_cpBody_vy(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpBody* body = (cpBody*) proxy->handle; + vp.set(DOUBLE_TO_JSVAL(body->v.y)); + return true; +} + +bool js_get_cpBody_inverse_m(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpBody* body = (cpBody*) proxy->handle; + vp.set(DOUBLE_TO_JSVAL(body->m_inv)); + return true; +} + +bool js_get_cpBody_inverse_i(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpBody* body = (cpBody*) proxy->handle; + vp.set(DOUBLE_TO_JSVAL(body->i_inv)); + return true; +} + void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpBody_class = (JSClass *)calloc(1, sizeof(JSClass)); @@ -3991,6 +4089,10 @@ void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name JSB_cpBody_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { + {"vx", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpBody_vx), JSOP_NULLWRAPPER}, + {"vy", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpBody_vy), JSOP_NULLWRAPPER}, + {"m_inv", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpBody_inverse_m), JSOP_NULLWRAPPER}, + {"i_inv", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpBody_inverse_i), JSOP_NULLWRAPPER}, {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { @@ -4038,6 +4140,9 @@ void JSB_cpBody_createClass(JSContext *cx, JSObject* globalObj, const char* name JS_FN("world2Local", JSB_cpBody_world2Local, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setUserData", JSB_cpBody_setUserData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getUserData", JSB_cpBody_getUserData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("eachShape", JSB_cpBody_eachShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("eachConstraint", JSB_cpBody_eachConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("eachArbiter", JSB_cpBody_eachArbiter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { @@ -4503,6 +4608,60 @@ bool JSB_cpShape_active(JSContext *cx, uint32_t argc, jsval *vp){ return true; } +bool JSB_cpShape_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 1, cx, false, "Invalid number of arguments" ); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* shape = (cpShape*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + + cpVect p; + bool ok = jsval_to_cpVect(cx, argvp[0], &p); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo(); + cpShapeNearestPointQuery(shape, p, info); + JSObject *jsobj = JS_NewObject(cx, JSB_cpNearestPointQueryInfo_class, JSB_cpNearestPointQueryInfo_object, NULL); + jsb_set_jsobject_for_proxy(jsobj, info); + jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); + + return true; +} + +bool JSB_cpShape_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpShape* shape = (cpShape*) proxy->handle; + jsval *argvp = JS_ARGV(cx,vp); + + cpVect a; + cpVect b; + bool ok = jsval_to_cpVect(cx, argvp[0], &a); + ok &= jsval_to_cpVect(cx, argvp[1], &b); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + cpSegmentQueryInfo* info = new cpSegmentQueryInfo(); + if(cpShapeSegmentQuery(shape, a, b, info)) + { + JSObject* jsobj = JS_NewObject(cx, JSB_cpSegmentQueryInfo_class, JSB_cpSegmentQueryInfo_object, NULL); + jsb_set_jsobject_for_proxy(jsobj, info); + jsb_set_c_proxy_for_jsobject(jsobj, info, JSB_C_FLAG_CALL_FREE); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); + } + else + { + delete info; + JS_SET_RVAL(cx, vp, JSVAL_NULL); + } + return true; +} + static bool js_get_cpShape_bbl(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) { struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); cpShape* shape = (cpShape*) proxy->handle; @@ -4603,6 +4762,8 @@ void JSB_cpShape_createClass(JSContext *cx, JSObject* globalObj, const char* nam JS_FN("setSurfaceVelocity", JSB_cpShape_setSurfaceVelocity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("update", JSB_cpShape_update, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("active", JSB_cpShape_active, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("nearestPointQuery", JSB_cpShape_nearestPointQuery, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("segmentQuery", JSB_cpShape_segmentQuery, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; static JSFunctionSpec st_funcs[] = { @@ -4861,6 +5022,26 @@ bool JSB_cpSegmentShape_setNeighbors(JSContext *cx, uint32_t argc, jsval *vp) { return true; } +static bool js_get_cpSegmentShape_a_tangent(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpSegmentShape* shape = (cpSegmentShape*) proxy->handle; + cpVect vec = shape->a_tangent; + jsval ret = cpVect_to_jsval( cx, vec); + vp.set(ret); + return true; +} + +static bool js_get_cpSegmentShape_b_tangent(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpSegmentShape* shape = (cpSegmentShape*) proxy->handle; + cpVect vec = shape->b_tangent; + jsval ret = cpVect_to_jsval( cx, vec); + vp.set(ret); + return true; +} + void JSB_cpSegmentShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpSegmentShape_class = (JSClass *)calloc(1, sizeof(JSClass)); @@ -4876,6 +5057,8 @@ void JSB_cpSegmentShape_createClass(JSContext *cx, JSObject* globalObj, const ch JSB_cpSegmentShape_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { + {"a_tangent", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpSegmentShape_a_tangent), JSOP_NULLWRAPPER}, + {"b_tangent", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpSegmentShape_b_tangent), JSOP_NULLWRAPPER}, {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { @@ -4958,6 +5141,59 @@ bool JSB_cpPolyShape_getVert(JSContext *cx, uint32_t argc, jsval *vp) { return true; } +static bool js_get_cpPolyShape_verts(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpPolyShape* shape = (cpPolyShape*) proxy->handle; + int numVerts = shape->numVerts; + cpVect* verts = shape->verts; + + JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); + int i = 0; + while (i < numVerts) { + cpVect vec = verts[i]; + + JS::RootedValue x(cx); + JS::RootedValue y(cx); + x = DOUBLE_TO_JSVAL(vec.x); + y = DOUBLE_TO_JSVAL(vec.y); + JS_SetElement(cx, jsretArr, i*2, &x); + JS_SetElement(cx, jsretArr, i*2+1, &y); + i++; + } + vp.set(OBJECT_TO_JSVAL(jsretArr)); + return true; +} + +static bool js_get_cpPolyShape_planes(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpPolyShape* shape = (cpPolyShape*) proxy->handle; + int numVerts = shape->numVerts; + cpSplittingPlane* planes = shape->planes; + + JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); + int i = 0; + while(i < numVerts){ + cpSplittingPlane *plane = planes + i; + JS::RootedValue elem(cx); + + JSObject *jsobj = jsb_get_jsobject_for_proxy(plane); + if(!jsobj) + { + jsobj = JS_NewObject(cx, JSB_cpSplittingPlane_class, JSB_cpSplittingPlane_object, NULL); + jsb_set_jsobject_for_proxy(jsobj, plane); + jsb_set_c_proxy_for_jsobject(jsobj, plane, JSB_C_FLAG_DO_NOT_CALL_FREE); + } + + elem = OBJECT_TO_JSVAL(jsobj); + JS_SetElement(cx, jsretArr, i, &elem); + i++; + } + vp.set(OBJECT_TO_JSVAL(jsretArr)); + return true; +} + void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* name ) { JSB_cpPolyShape_class = (JSClass *)calloc(1, sizeof(JSClass)); @@ -4973,6 +5209,8 @@ void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* JSB_cpPolyShape_class->flags = JSCLASS_HAS_PRIVATE; static JSPropertySpec properties[] = { + {"verts", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpPolyShape_verts), JSOP_NULLWRAPPER}, + {"planes", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpPolyShape_planes), JSOP_NULLWRAPPER}, {0, 0, 0, 0, 0} }; static JSFunctionSpec funcs[] = { @@ -4989,6 +5227,70 @@ void JSB_cpPolyShape_createClass(JSContext *cx, JSObject* globalObj, const char* // JS_SetPropertyAttributes(cx, globalObj, name, JSPROP_ENUMERATE | JSPROP_READONLY, &found); } +// SplittingPlane +JSObject *JSB_cpSplittingPlane_object = NULL; +JSClass *JSB_cpSplittingPlane_class = NULL; + +// Destructor +void JSB_cpSplittingPlane_finalize(JSFreeOp *fop, JSObject *jsthis) +{ + jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + if( proxy ) { + CCLOGINFO("jsbindings: finalizing JS object %p (cpSplittingPlane), handle: %p", jsthis, proxy->handle); + + jsb_del_jsobject_for_proxy(proxy->handle); + jsb_del_c_proxy_for_jsobject(jsthis); + + //no need to free cpSplittingPlane, cpSplittingPlane will be freed by it's shape + } +} + +bool js_get_cpSplitting_n(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpSplittingPlane* plane = (cpSplittingPlane*) proxy->handle; + cpVect vec = plane->n; + vp.set(cpVect_to_jsval(cx, vec)); + return true; +} + +bool js_get_cpSplitting_d(JSContext *cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp) +{ + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(obj); + cpSplittingPlane* plane = (cpSplittingPlane*) proxy->handle; + vp.set(DOUBLE_TO_JSVAL(plane->d)); + return true; +} + +void JSB_cpSplittingPlane_createClass(JSContext *cx, JSObject* globalObj, const char* name ) +{ + JSB_cpSplittingPlane_class = (JSClass *)calloc(1, sizeof(JSClass)); + JSB_cpSplittingPlane_class->name = name; + JSB_cpSplittingPlane_class->addProperty = JS_PropertyStub; + JSB_cpSplittingPlane_class->delProperty = JS_DeletePropertyStub; + JSB_cpSplittingPlane_class->getProperty = JS_PropertyStub; + JSB_cpSplittingPlane_class->setProperty = JS_StrictPropertyStub; + JSB_cpSplittingPlane_class->enumerate = JS_EnumerateStub; + JSB_cpSplittingPlane_class->resolve = JS_ResolveStub; + JSB_cpSplittingPlane_class->convert = JS_ConvertStub; + JSB_cpSplittingPlane_class->finalize = JSB_cpSplittingPlane_finalize; + JSB_cpSplittingPlane_class->flags = JSCLASS_HAS_PRIVATE; + + static JSPropertySpec properties[] = { + {"n", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpSplitting_n), JSOP_NULLWRAPPER}, + {"d", 0, JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_SHARED, JSOP_WRAPPER(js_get_cpSplitting_d), JSOP_NULLWRAPPER}, + {0, 0, 0, 0, 0} + }; + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + static JSFunctionSpec st_funcs[] = { + JS_FS_END + }; + + JSB_cpSplittingPlane_object = JS_InitClass(cx, globalObj, NULL, JSB_cpSplittingPlane_class, NULL,0,properties,funcs,NULL,st_funcs); +} + bool JSB_cpSegmentQueryInfo_hitPoint(JSContext *cx, uint32_t argc, jsval *vp){ JSB_PRECONDITION2( argc == 2, cx, false, "Invalid number of arguments" ); diff --git a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.h b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.h index 177ad37f73..1ac11afa92 100644 --- a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.h +++ b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes.h @@ -67,4 +67,7 @@ void JSB_cpSegmentQueryInfo_createClass(JSContext *cx, JSObject* globalObj, cons extern JSObject *JSB_cpNearestPointQueryInfo_object; extern JSClass *JSB_cpNearestPointQueryInfo_class; void JSB_cpNearestPointQueryInfo_createClass(JSContext *cx, JSObject* globalObj, const char* name ); +extern JSObject *JSB_cpSplittingPlane_object; +extern JSClass *JSB_cpSplittingPlane_class; +void JSB_cpSplittingPlane_createClass(JSContext *cx, JSObject* globalObj, const char* name ); #endif // JSB_INCLUDE_CHIPMUNK diff --git a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h index cd19abd013..635d3fbbbf 100644 --- a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h +++ b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_auto_classes_registration.h @@ -26,4 +26,5 @@ JSB_cpSegmentShape_createClass(cx, chipmunk, "SegmentShape"); JSB_cpPolyShape_createClass(cx, chipmunk, "PolyShape"); JSB_cpSegmentQueryInfo_createClass(cx, chipmunk, "SegmentQueryInfo"); JSB_cpNearestPointQueryInfo_createClass(cx, chipmunk, "NearestPointQueryInfo"); +JSB_cpSplittingPlane_createClass(cx, chipmunk, "SplittingPlane"); #endif // JSB_INCLUDE_CHIPMUNK diff --git a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp index 953f9df975..3b4452c9e7 100644 --- a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -806,7 +806,9 @@ static void myCollisionPost(cpArbiter *arb, cpSpace *space, void *data) static void myCollisionSeparate(cpArbiter *arb, cpSpace *space, void *data) { struct collision_handler *handler = (struct collision_handler*) data; - + if(! handler->cx || !handler->space) + return; + jsval args[2]; if( handler->is_oo ) { args[0] = c_class_to_jsval(handler->cx, arb, JSB_cpArbiter_object, JSB_cpArbiter_class, "cpArbiter"); @@ -974,6 +976,79 @@ bool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) return __jsb_cpSpace_addCollisionHandler(cx, vp, JS_ARGV(cx,vp), (cpSpace*)handle, 1); } +bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc==4, cx, false, "Invalid number of arguments"); + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*) proxy->handle; + + collision_handler *handler = (collision_handler*) malloc( sizeof(collision_handler) ); + JSB_PRECONDITION(handler, "Error allocating memory"); + + handler->typeA = 0; + handler->typeB = 0; + handler->jsthis = jsthis; + + jsval *argv = JS_ARGV(cx,vp); + handler->begin = !JSVAL_IS_NULL(argv[0]) ? JSVAL_TO_OBJECT(argv[0]) : NULL; + handler->pre = !JSVAL_IS_NULL(argv[1]) ? JSVAL_TO_OBJECT(argv[1]) : NULL; + handler->post = !JSVAL_IS_NULL(argv[2]) ? JSVAL_TO_OBJECT(argv[2]) : NULL; + handler->separate = !JSVAL_IS_NULL(argv[3]) ? JSVAL_TO_OBJECT(argv[3]) : NULL; + + // Object Oriented API ? + handler->is_oo = 1; + + // owner of the collision handler + handler->space = space; + handler->cx = cx; + + cpSpaceSetDefaultCollisionHandler(space, + !handler->begin ? NULL : &myCollisionBegin, + !handler->pre ? NULL : &myCollisionPre, + !handler->post ? NULL : &myCollisionPost, + !handler->separate ? NULL : &myCollisionSeparate, + handler ); + + // + // Already added ? If so, remove it. + // Then add new entry + // + struct collision_handler *hashElement = NULL; + unsigned long paired_key = pair_ints(handler->typeA, handler->typeB ); + HASH_FIND_INT(collision_handler_hash, &paired_key, hashElement); + if( hashElement ) { + if( hashElement->begin ) { + JS_RemoveObjectRoot(cx, &hashElement->begin); + } + if( hashElement->pre ) + JS_RemoveObjectRoot(cx, &hashElement->pre); + if( hashElement->post ) + JS_RemoveObjectRoot(cx, &hashElement->post); + if( hashElement->separate ) + JS_RemoveObjectRoot(cx, &hashElement->separate); + HASH_DEL( collision_handler_hash, hashElement ); + free( hashElement ); + } + + handler->hash_key = paired_key; + HASH_ADD_INT( collision_handler_hash, hash_key, handler ); + + // Root it + if( handler->begin ) + JS_AddNamedObjectRoot(cx, &handler->begin, "begin collision_handler"); + if( handler->pre ) + JS_AddNamedObjectRoot(cx, &handler->pre, "pre collision_handler"); + if( handler->post ) + JS_AddNamedObjectRoot(cx, &handler->post, "post collision_handler"); + if( handler->separate ) + JS_AddNamedObjectRoot(cx, &handler->separate, "separate collision_handler"); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + + return true; +} + #pragma mark removeCollisionHandler static @@ -1258,12 +1333,12 @@ bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp){ cpVect start; cpVect end; cpLayers layers; - unsigned int group; + cpGroup group; bool ok = true; ok &= jsval_to_cpVect( cx, argvp[0], &start ); ok &= jsval_to_cpVect( cx, argvp[1], &end ); ok &= jsval_to_uint32( cx, argvp[2], &layers ); - ok &= jsval_to_uint( cx, argvp[3], &group ); + ok &= jsval_to_uint( cx, argvp[3], (unsigned int*)&group ); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); cpSegmentQueryInfo *out = new cpSegmentQueryInfo(); @@ -1295,7 +1370,7 @@ bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *v cpVect point; cpFloat maxDistance; cpLayers layers; - unsigned int group; + cpGroup group; bool ok = true; ok &= jsval_to_cpVect( cx, argvp[0], &point ); if(JSVAL_IS_INT(argvp[1])) @@ -1309,7 +1384,7 @@ bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *v maxDistance = JSVAL_TO_DOUBLE(argvp[1]); } ok &= jsval_to_uint32( cx, argvp[2], &layers ); - ok &= jsval_to_uint( cx, argvp[3], &group ); + ok &= jsval_to_uint( cx, argvp[3], (unsigned int*)&group ); JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); cpNearestPointQueryInfo* info = new cpNearestPointQueryInfo(); @@ -1330,6 +1405,405 @@ bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *v return true; } +struct JSB_cp_each_UserData +{ + JSContext *cx; + jsval* func; +}; + +void JSB_cpSpace_pointQuery_func(cpShape *shape, void *data) +{ + JSObject *jsCpObject = jsb_get_jsobject_for_proxy(shape); + if(jsCpObject) + { + JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; + jsval* func = ((JSB_cp_each_UserData*)data)->func; + jsval rval; + jsval argv = OBJECT_TO_JSVAL(jsCpObject); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS_CallFunctionValue(cx, NULL, *func, 1, &argv, &rval); + + } +} + +bool JSB_cpSpace_pointQuery(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 4, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSObject* jsthis = JSVAL_TO_OBJECT(args.thisv()); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*) proxy->handle; + + cpVect point; + cpLayers layers; + cpGroup group; + + bool ok = jsval_to_cpVect(cx, args.get(0), &point); + ok &= jsval_to_uint32(cx, args.get(1), &layers); + ok &= jsval_to_uint(cx, args.get(2), (unsigned int*)&group); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = const_cast(args.get(3).address()); + + cpSpacePointQuery(space, point, layers, group, JSB_cpSpace_pointQuery_func, data); + free(data); + + args.rval().setUndefined(); + return true; +} + +void JSB_cpSpace_nearestPointQuery_func(cpShape *shape, cpFloat distance, cpVect point, void *data) +{ + JSObject *jsCpObject = jsb_get_jsobject_for_proxy(shape); + if(jsCpObject) + { + JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; + jsval* func = ((JSB_cp_each_UserData*)data)->func; + jsval rval; + jsval argv[3]; + argv[0] = OBJECT_TO_JSVAL(jsCpObject); + argv[1] = DOUBLE_TO_JSVAL(distance); + argv[2] = cpVect_to_jsval(cx, point); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS_CallFunctionValue(cx, NULL, *func, 3, argv, &rval); + + } +} + +bool JSB_cpSpace_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 5, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSObject* jsthis = JSVAL_TO_OBJECT(args.thisv()); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*) proxy->handle; + + cpVect point; + cpFloat maxDistance; + cpLayers layers; + cpGroup group; + + bool ok = jsval_to_cpVect(cx, args.get(0), &point); + ok &= JS::ToNumber(cx, args.get(1), &maxDistance); + ok &= jsval_to_uint32(cx, args.get(2), &layers); + ok &= jsval_to_uint(cx, args.get(3), (unsigned int*)&group); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = const_cast(args.get(4).address()); + + cpSpaceNearestPointQuery(space, point, maxDistance, layers, group, JSB_cpSpace_nearestPointQuery_func, data); + + free(data); + args.rval().setUndefined(); + return true; +} + +void JSB_cpSpace_segmentQuery_func(cpShape *shape, cpFloat t, cpVect n, void *data) +{ + JSObject *jsCpObject = jsb_get_jsobject_for_proxy(shape); + if(jsCpObject) + { + JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; + jsval* func = ((JSB_cp_each_UserData*)data)->func; + jsval rval; + jsval argv[3]; + argv[0] = OBJECT_TO_JSVAL(jsCpObject); + argv[1] = DOUBLE_TO_JSVAL(t); + argv[2] = cpVect_to_jsval(cx, n); + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS_CallFunctionValue(cx, NULL, *func, 3, argv, &rval); + + } +} + +bool JSB_cpSpace_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 5, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSObject* jsthis = JSVAL_TO_OBJECT(args.thisv()); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*) proxy->handle; + + cpVect start; + cpVect end; + cpLayers layers; + cpGroup group; + + bool ok = jsval_to_cpVect(cx, args.get(0), &start); + ok = jsval_to_cpVect(cx, args.get(1), &end); + ok &= jsval_to_uint32(cx, args.get(2), &layers); + ok &= jsval_to_uint(cx, args.get(3), (unsigned int*)&group); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = const_cast(args.get(4).address()); + + cpSpaceSegmentQuery(space, start, end, layers, group, JSB_cpSpace_segmentQuery_func, data); + + free(data); + args.rval().setUndefined(); + return true; +} + +#define JSB_cpSpace_bbQuery_func JSB_cpSpace_pointQuery_func + +bool JSB_cpSpace_bbQuery(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 4, cx, false, "Invalid number of arguments"); + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + + JSObject* jsthis = JSVAL_TO_OBJECT(args.thisv()); + struct jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*) proxy->handle; + + cpBB bb; + cpLayers layers; + cpGroup group; + + bool ok = jsval_to_cpBB(cx, args.get(0), &bb); + ok &= jsval_to_uint32(cx, args.get(1), &layers); + ok &= jsval_to_uint(cx, args.get(2), (unsigned int*)&group); + JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = const_cast(args.get(3).address()); + + cpSpaceBBQuery(space, bb, layers, group, JSB_cpSpace_bbQuery_func, data); + + free(data); + args.rval().setUndefined(); + return true; +} + +template +void JSB_cpSpace_each_func(T* cpObject, void *data) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JSObject *jsCpObject = jsb_get_jsobject_for_proxy(cpObject); + if(jsCpObject) + { + JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; + jsval* func = ((JSB_cp_each_UserData*)data)->func; + jsval rval; + jsval argv = OBJECT_TO_JSVAL(jsCpObject); + + JS_CallFunctionValue(cx, NULL, *func, 1, &argv, &rval); + + } +} + +bool JSB_cpSpace_eachShape(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*)proxy->handle; + jsval *argvp = JS_ARGV(cx, vp); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = argvp; + + cpSpaceEachShape(space, JSB_cpSpace_each_func, data); + free(data); + return true; +} + +bool JSB_cpSpace_eachBody(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*)proxy->handle; + jsval *argvp = JS_ARGV(cx, vp); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = argvp; + + cpSpaceEachBody(space, JSB_cpSpace_each_func, data); + free(data); + return true; +} + +bool JSB_cpSpace_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*)proxy->handle; + jsval *argvp = JS_ARGV(cx, vp); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = argvp; + + cpSpaceEachConstraint(space, JSB_cpSpace_each_func, data); + free(data); + return true; +} + +struct __PostStep_data{ + JSContext* cx; + JS::Heap func; +}; + +void __JSB_PostStep_callback(cpSpace *space, void *key, __PostStep_data *data) +{ + JSContext* cx = data->cx; + jsval func = const_cast(data->func.get()); + jsval rval; + jsval argv; + + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JS_CallFunctionValue(cx, NULL, func, 0, &argv, &rval); + + free(data); +} + +bool JSB_cpSpace_addPostStepCallback(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); + + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject* jsthis = JSVAL_TO_OBJECT(args.thisv()); + jsb_c_proxy_s* proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpSpace* space = (cpSpace*)proxy->handle; + + __PostStep_data* volatile data = (__PostStep_data*)malloc(sizeof(__PostStep_data)); + if (!data) + return false; + + data->cx = cx; + data->func = args.get(0); + + cpSpaceAddPostStepCallback(space, (cpPostStepFunc)__JSB_PostStep_callback, data, data); + +// free(data); + args.rval().setUndefined(); + return true; +} + +template +void JSB_cpBody_each_func(cpBody* body, T* cpObject, void* data) +{ + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + + JSObject *jsCpObject = jsb_get_jsobject_for_proxy(cpObject); + if(jsCpObject) + { + JSContext* cx = ((JSB_cp_each_UserData*)data)->cx; + jsval* func = ((JSB_cp_each_UserData*)data)->func; + jsval rval; + jsval argv = OBJECT_TO_JSVAL(jsCpObject); + + JS_CallFunctionValue(cx, NULL, *func, 1, &argv, &rval); + + } +} + +bool JSB_cpBody_eachShape(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* body = (cpBody*)proxy->handle; + jsval *argvp = JS_ARGV(cx, vp); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = argvp; + + cpBodyEachShape(body, JSB_cpBody_each_func, data); + free(data); + return true; +} + +bool JSB_cpBody_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* body = (cpBody*)proxy->handle; + jsval *argvp = JS_ARGV(cx, vp); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = argvp; + + cpBodyEachConstraint(body, JSB_cpBody_each_func, data); + free(data); + return true; +} + +bool JSB_cpBody_eachArbiter(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSB_PRECONDITION2(argc == 1, cx, false, "Invalid number of arguments"); + + JSObject* jsthis = (JSObject *)JS_THIS_OBJECT(cx, vp); + struct jsb_c_proxy_s *proxy = jsb_get_c_proxy_for_jsobject(jsthis); + cpBody* body = (cpBody*)proxy->handle; + jsval *argvp = JS_ARGV(cx, vp); + + JSB_cp_each_UserData *data = (JSB_cp_each_UserData*)malloc(sizeof(JSB_cp_each_UserData)); + if (!data) + return false; + + data->cx = cx; + data->func = argvp; + + cpBodyEachArbiter(body, JSB_cpBody_each_func, data); + free(data); + return true; +} + #pragma mark - Arbiter #pragma mark getBodies @@ -1752,7 +2226,7 @@ bool JSB_cpPolyShape_constructor(JSContext *cx, uint32_t argc, jsval *vp) JSB_PRECONDITION(ok, "Error processing arguments"); cpShape *shape = cpPolyShapeNew(body, numVerts, verts, offset); - jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_DO_NOT_CALL_FREE); + jsb_set_c_proxy_for_jsobject(jsobj, shape, JSB_C_FLAG_CALL_FREE); jsb_set_jsobject_for_proxy(jsobj, shape); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); diff --git a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.h b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.h index 95d865e124..aea05e82a9 100644 --- a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.h +++ b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.h @@ -50,6 +50,7 @@ bool JSB_cpCentroidForPoly(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpRecenterPoly(JSContext *cx, uint32_t argc, jsval *vp); // "Methods" from the OO API +bool JSB_cpSpace_setDefaultCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpSpace_addCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpSpace_removeCollisionHandler(JSContext *cx, uint32_t argc, jsval *vp); @@ -64,7 +65,14 @@ bool JSB_cpSpace_removeShape(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpSpace_removeStaticShape(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpSpace_segmentQueryFirst(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpSpace_nearestPointQueryNearest(JSContext *cx, uint32_t argc, jsval *vp); - +bool JSB_cpSpace_eachShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_eachBody(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_pointQuery(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_nearestPointQuery(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_segmentQuery(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_bbQuery(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpSpace_addPostStepCallback(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpArbiter_getBodies(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpArbiter_getShapes(JSContext *cx, uint32_t argc, jsval *vp); @@ -73,6 +81,10 @@ bool JSB_cpBody_constructor(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpBody_getUserData(JSContext *cx, uint32_t argc, jsval *vp); bool JSB_cpBody_setUserData(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBody_eachShape(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBody_eachConstraint(JSContext *cx, uint32_t argc, jsval *vp); +bool JSB_cpBody_eachArbiter(JSContext *cx, uint32_t argc, jsval *vp); + // convertions diff --git a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_registration.cpp b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_registration.cpp index 47c7464e8e..af88849429 100644 --- a/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_registration.cpp +++ b/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_registration.cpp @@ -53,8 +53,6 @@ void jsb_register_chipmunk(JSContext* cx, JSObject *object) // manual JS_DefineFunction(cx, chipmunk, "spaceAddCollisionHandler", JSB_cpSpaceAddCollisionHandler, 8, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "spaceRemoveCollisionHandler", JSB_cpSpaceRemoveCollisionHandler, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); - JS_DefineFunction(cx, JSB_cpSpace_object, "segmentQueryFirst", JSB_cpSpace_segmentQueryFirst, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); - JS_DefineFunction(cx, JSB_cpSpace_object, "nearestPointQueryNearest", JSB_cpSpace_nearestPointQueryNearest, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); JS_DefineFunction(cx, chipmunk, "arbiterGetBodies", JSB_cpArbiterGetBodies, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "arbiterGetShapes", JSB_cpArbiterGetShapes, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "bodyGetUserData", JSB_cpBodyGetUserData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); @@ -64,6 +62,13 @@ void jsb_register_chipmunk(JSContext* cx, JSObject *object) JS_DefineFunction(cx, chipmunk, "momentForPoly", JSB_cpMomentForPoly, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "centroidForPoly", JSB_cpCentroidForPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); JS_DefineFunction(cx, chipmunk, "recenterPoly", JSB_cpRecenterPoly, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE ); + + JS_DefineFunction(cx, JSB_cpSpace_object, "segmentQueryFirst", JSB_cpSpace_segmentQueryFirst, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, JSB_cpSpace_object, "nearestPointQueryNearest", JSB_cpSpace_nearestPointQueryNearest, 4, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, JSB_cpSpace_object, "eachShape", JSB_cpSpace_eachShape, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, JSB_cpSpace_object, "eachBody", JSB_cpSpace_eachBody, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, JSB_cpSpace_object, "eachConstraint", JSB_cpSpace_eachConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + register_CCPhysicsSprite(cx, object); register_CCPhysicsDebugNode(cx, object); } diff --git a/frameworks/js-bindings/bindings/manual/cocos2d_specifics.cpp b/frameworks/js-bindings/bindings/manual/cocos2d_specifics.cpp index 6ce8c81d90..320a9dd42f 100644 --- a/frameworks/js-bindings/bindings/manual/cocos2d_specifics.cpp +++ b/frameworks/js-bindings/bindings/manual/cocos2d_specifics.cpp @@ -2431,6 +2431,70 @@ bool js_cocos2dx_CCNode_setColor(JSContext *cx, uint32_t argc, jsval *vp) return false; } +bool js_cocos2dx_CCNode_pause(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JSVAL_TO_OBJECT(args.thisv()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_pause : Invalid Native Object"); + if (argc == 0) { + do { + JSObject *tmpObj = obj; + + __Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + if(arr){ + JSScheduleWrapper* wrapper = NULL; + for(ssize_t i = 0; i < arr->count(); ++i) { + wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); + if(wrapper) { + cobj->getScheduler()->pauseTarget(wrapper); + } + } + } + } while (0); + + cobj->pause(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_pause : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +bool js_cocos2dx_CCNode_resume(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JSObject *obj = JSVAL_TO_OBJECT(args.thisv()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Node* cobj = (cocos2d::Node *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Node_resume : Invalid Native Object"); + if (argc == 0) { + do { + JSObject *tmpObj = obj; + + __Array *arr = JSScheduleWrapper::getTargetForJSObject(tmpObj); + if(arr){ + JSScheduleWrapper* wrapper = NULL; + for(ssize_t i = 0; i < arr->count(); ++i) { + wrapper = (JSScheduleWrapper*)arr->getObjectAtIndex(i); + if(wrapper) { + cobj->getScheduler()->resumeTarget(wrapper); + } + } + } + } while (0); + + cobj->resume(); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Node_resume : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + bool js_cocos2dx_Component_onEnter(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *thisObj = JS_THIS_OBJECT(cx, vp); @@ -3798,7 +3862,7 @@ bool js_cocos2dx_CCFileUtils_getSearchPaths(JSContext *cx, uint32_t argc, jsval return false; } -bool js_cocos2dx_CCFileUtils_getByteArrayFromFile(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_CCFileUtils_getDataFromFile(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); bool ok = true; @@ -4141,7 +4205,7 @@ bool js_PlistParser_parse(JSContext *cx, unsigned argc, JS::Value *vp) { jsval strVal = std_string_to_jsval(cx, parsedStr); // create a new js obj of the parsed string JS::RootedValue outVal(cx); - ok = JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), static_cast(parsedStr.size()), &outVal); + ok = JS_ParseJSON(cx, JS_GetStringCharsZ(cx, JSVAL_TO_STRING(strVal)), static_cast(JS_GetStringLength(JSVAL_TO_STRING(strVal))), &outVal); if (ok) JS_SET_RVAL(cx, vp, outVal); @@ -4558,6 +4622,19 @@ void create_js_root_obj(JSContext* cx, JSObject* global, const std::string &name } } +void register_cocos2dx_js_core(JSContext* cx, JSObject* global) +{ + JS::RootedObject ccObj(cx); + create_js_root_obj(cx, global, "cc", &ccObj); + + JSObject *tmpObj; + + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.PlistParser; })()")); + JS_DefineFunction(cx, tmpObj, "getInstance", js_PlistParser_getInstance, 0, JSPROP_READONLY | JSPROP_PERMANENT); + tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.PlistParser.getInstance(); })()")); + JS_DefineFunction(cx, tmpObj, "parse", js_PlistParser_parse, 1, JSPROP_READONLY | JSPROP_PERMANENT); + +} void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) { JS::RootedObject ccObj(cx); @@ -4599,6 +4676,8 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "setContentSize", js_cocos2dx_CCNode_setContentSize, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "setAnchorPoint", js_cocos2dx_CCNode_setAnchorPoint, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "setColor", js_cocos2dx_CCNode_setColor, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "pause", js_cocos2dx_CCNode_pause, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_cocos2d_Node_prototype, "resume", js_cocos2dx_CCNode_resume, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Component_prototype, "onEnter", js_cocos2dx_Component_onEnter, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Component_prototype, "onExit", js_cocos2dx_Component_onExit, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); @@ -4616,7 +4695,7 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "unscheduleAllCallbacks", js_cocos2dx_CCScheduler_unscheduleAll, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "unscheduleAllCallbacksWithMinPriority", js_cocos2dx_CCScheduler_unscheduleAllCallbacksWithMinPriority, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_Scheduler_prototype, "isTargetPaused", js_cocos2dx_CCScheduler_isTargetPaused, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - + JS_DefineFunction(cx, jsb_cocos2d_TMXLayer_prototype, "getTileFlagsAt", js_cocos2dx_CCTMXLayer_getTileFlagsAt, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_DrawNode_prototype, "drawPoly", js_cocos2dx_CCDrawNode_drawPolygon, 4, JSPROP_ENUMERATE | JSPROP_PERMANENT); @@ -4634,7 +4713,7 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "createDictionaryWithContentsOfFile", js_cocos2dx_FileUtils_createDictionaryWithContentsOfFile, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "getByteArrayFromFile", js_cocos2dx_CCFileUtils_getByteArrayFromFile, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_cocos2d_FileUtils_prototype, "getDataFromFile", js_cocos2dx_CCFileUtils_getDataFromFile, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.EventListenerTouchOneByOne; })()")); JS_DefineFunction(cx, tmpObj, "create", js_EventListenerTouchOneByOne_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); @@ -4723,11 +4802,6 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, tmpObj, "create", js_callFunc, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_CallFuncN_prototype, "initWithFunction", js_cocos2dx_CallFunc_initWithFunction, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); - tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.PlistParser; })()")); - JS_DefineFunction(cx, tmpObj, "getInstance", js_PlistParser_getInstance, 0, JSPROP_READONLY | JSPROP_PERMANENT); - tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.PlistParser.getInstance(); })()")); - JS_DefineFunction(cx, tmpObj, "parse", js_PlistParser_parse, 1, JSPROP_READONLY | JSPROP_PERMANENT); - tmpObj = JSVAL_TO_OBJECT(anonEvaluate(cx, global, "(function () { return cc.GLProgram; })()")); JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCGLProgram_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); diff --git a/frameworks/js-bindings/bindings/manual/cocos2d_specifics.hpp b/frameworks/js-bindings/bindings/manual/cocos2d_specifics.hpp index 3cca242f93..907009b633 100644 --- a/frameworks/js-bindings/bindings/manual/cocos2d_specifics.hpp +++ b/frameworks/js-bindings/bindings/manual/cocos2d_specifics.hpp @@ -115,6 +115,7 @@ inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) { } jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string); +void register_cocos2dx_js_core(JSContext* cx, JSObject* obj); void register_cocos2dx_js_extensions(JSContext* cx, JSObject* obj); diff --git a/frameworks/js-bindings/bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp b/frameworks/js-bindings/bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp index 8c2a527e81..1400fc693c 100644 --- a/frameworks/js-bindings/bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp +++ b/frameworks/js-bindings/bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -158,7 +158,7 @@ static bool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx return true; } - else if (argc == 2) { + else if (argc == 1 || argc == 2) { JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); @@ -171,7 +171,14 @@ static bool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext *cx dict->setObject(tmpObj, "moveEvent"); tmpObj->setJSCallbackFunc(argv[0]); - tmpObj->setJSCallbackThis(argv[1]); + if (argc == 1) + { + tmpObj->setJSCallbackThis(JSVAL_NULL); + } + else + { + tmpObj->setJSCallbackThis(argv[1]); + } cobj->setMovementEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::movementCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); @@ -197,7 +204,7 @@ static bool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, u return true; } - else if (argc == 2) { + else if (argc == 1 || argc == 2) { JSArmatureWrapper *tmpObj = new JSArmatureWrapper(); tmpObj->autorelease(); @@ -210,7 +217,14 @@ static bool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, u dict->setObject(tmpObj, "frameEvent"); tmpObj->setJSCallbackFunc(argv[0]); - tmpObj->setJSCallbackThis(argv[1]); + if (argc == 1) + { + tmpObj->setJSCallbackThis(JSVAL_NULL); + } + else + { + tmpObj->setJSCallbackThis(argv[1]); + } cobj->setFrameEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::frameCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); diff --git a/frameworks/js-bindings/bindings/manual/platform/android/CCJavascriptJavaBridge.cpp b/frameworks/js-bindings/bindings/manual/platform/android/CCJavascriptJavaBridge.cpp index 262b5b1497..845edddff9 100644 --- a/frameworks/js-bindings/bindings/manual/platform/android/CCJavascriptJavaBridge.cpp +++ b/frameworks/js-bindings/bindings/manual/platform/android/CCJavascriptJavaBridge.cpp @@ -317,7 +317,12 @@ JS_BINDED_CONSTRUCTOR_IMPL(JavascriptJavaBridge) */ static void basic_object_finalize(JSFreeOp *freeOp, JSObject *obj) { - CCLOG("basic_object_finalize %p ...", obj); + CCLOG("jsbindings: finalizing JS object %p (JavascriptJavaBridge)", obj); + JavascriptJavaBridge* native = (JavascriptJavaBridge*)JS_GetPrivate(obj); + if(native) + { + delete native; + } } /** diff --git a/frameworks/js-bindings/bindings/manual/platform/ios/JavaScriptObjCBridge.mm b/frameworks/js-bindings/bindings/manual/platform/ios/JavaScriptObjCBridge.mm index cfa18b5559..783d4b695c 100644 --- a/frameworks/js-bindings/bindings/manual/platform/ios/JavaScriptObjCBridge.mm +++ b/frameworks/js-bindings/bindings/manual/platform/ios/JavaScriptObjCBridge.mm @@ -29,7 +29,10 @@ #import JavaScriptObjCBridge::CallInfo::~CallInfo(void) { - + if (m_returnType == TypeString) + { + delete m_ret.stringValue; + } } JS::Value JavaScriptObjCBridge::convertReturnValue(JSContext *cx, ReturnValue retValue, ValueType type) { @@ -188,9 +191,8 @@ } else if ([oval isKindOfClass:[NSString class]]) { - const char *abc = [oval cStringUsingEncoding:NSUTF8StringEncoding]; - string str(abc); - m_ret.stringValue = &str; + const char *content = [oval cStringUsingEncoding:NSUTF8StringEncoding]; + m_ret.stringValue = new string(content); m_returnType = TypeString; } else if ([oval isKindOfClass:[NSDictionary class]]) @@ -199,9 +201,8 @@ } else { - const char *abc = [[NSString stringWithFormat:@"%@", oval] cStringUsingEncoding:NSUTF8StringEncoding]; - string str(abc); - m_ret.stringValue = &str; + const char *content = [[NSString stringWithFormat:@"%@", oval] cStringUsingEncoding:NSUTF8StringEncoding]; + m_ret.stringValue = new string(content); m_returnType = TypeString; } } diff --git a/frameworks/js-bindings/bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp b/frameworks/js-bindings/bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp old mode 100644 new mode 100755 index b353df4ca3..7d014cbb32 --- a/frameworks/js-bindings/bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp +++ b/frameworks/js-bindings/bindings/manual/ui/jsb_cocos2dx_ui_manual.cpp @@ -147,6 +147,26 @@ static bool js_cocos2dx_UIWidget_addTouchEventListener(JSContext *cx, uint32_t a return true; } + else if(argc == 1){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); + cobj->addTouchEventListener([=](Ref* widget, Widget::TouchEventType type)->void{ + jsval arg[2]; + js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); + if(proxy) + arg[0] = OBJECT_TO_JSVAL(proxy->obj); + else + arg[0] = JSVAL_NULL; + arg[1] = int32_to_jsval(cx, (int32_t)type); + jsval rval; + + bool ok = func->invoke(2, arg, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }); + return true; + } JS_ReportError(cx, "Invalid number of arguments"); return false; } @@ -179,6 +199,26 @@ static bool js_cocos2dx_UICheckBox_addEventListener(JSContext *cx, uint32_t argc return true; } + else if(argc == 1){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); + cobj->addEventListener([=](Ref* widget, CheckBox::EventType type)->void{ + jsval arg[2]; + js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); + if(proxy) + arg[0] = OBJECT_TO_JSVAL(proxy->obj); + else + arg[0] = JSVAL_NULL; + arg[1] = int32_to_jsval(cx, (int32_t)type); + jsval rval; + + bool ok = func->invoke(2, arg, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }); + return true; + } JS_ReportError(cx, "Invalid number of arguments"); return false; } @@ -211,6 +251,26 @@ static bool js_cocos2dx_UISlider_addEventListener(JSContext *cx, uint32_t argc, return true; } + else if(argc == 1){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); + cobj->addEventListener([=](Ref* widget, Slider::EventType type)->void{ + jsval arg[2]; + js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); + if(proxy) + arg[0] = OBJECT_TO_JSVAL(proxy->obj); + else + arg[0] = JSVAL_NULL; + arg[1] = int32_to_jsval(cx, (int32_t)type); + jsval rval; + + bool ok = func->invoke(2, arg, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }); + return true; + } JS_ReportError(cx, "Invalid number of arguments"); return false; } @@ -243,6 +303,26 @@ static bool js_cocos2dx_UITextField_addEventListener(JSContext *cx, uint32_t arg return true; } + else if(argc == 1){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); + cobj->addEventListener([=](Ref* widget, TextField::EventType type)->void{ + jsval arg[2]; + js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); + if(proxy) + arg[0] = OBJECT_TO_JSVAL(proxy->obj); + else + arg[0] = JSVAL_NULL; + arg[1] = int32_to_jsval(cx, (int32_t)type); + jsval rval; + + bool ok = func->invoke(2, arg, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }); + return true; + } JS_ReportError(cx, "Invalid number of arguments"); return false; } @@ -275,6 +355,26 @@ static bool js_cocos2dx_UIPageView_addEventListener(JSContext *cx, uint32_t argc return true; } + else if(argc == 1){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); + cobj->addEventListener([=](Ref* widget, PageView::EventType type)->void{ + jsval arg[2]; + js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); + if(proxy) + arg[0] = OBJECT_TO_JSVAL(proxy->obj); + else + arg[0] = JSVAL_NULL; + arg[1] = int32_to_jsval(cx, (int32_t)type); + jsval rval; + + bool ok = func->invoke(2, arg, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }); + return true; + } JS_ReportError(cx, "Invalid number of arguments"); return false; } @@ -305,6 +405,25 @@ static bool js_cocos2dx_UIScrollView_addEventListener(JSContext *cx, uint32_t ar cobj->addEventListenerScrollView(tmpObj, scrollvieweventselector(JSStudioEventListenerWrapper::eventCallbackFunc)); + return true; + }else if(argc == 1){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); + cobj->addEventListener([=](Ref* widget, ScrollView::EventType type)->void{ + jsval arg[2]; + js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); + if(proxy) + arg[0] = OBJECT_TO_JSVAL(proxy->obj); + else + arg[0] = JSVAL_NULL; + arg[1] = int32_to_jsval(cx, (int32_t)type); + jsval rval; + + bool ok = func->invoke(2, arg, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }); return true; } JS_ReportError(cx, "Invalid number of arguments"); @@ -339,6 +458,28 @@ static bool js_cocos2dx_UIListView_addEventListener(JSContext *cx, uint32_t argc return true; } + else if(argc == 1){ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + std::shared_ptr func(new JSFunctionWrapper(cx, obj, args.get(0))); + auto lambda = [=](Ref* widget, ListView::EventType type)->void{ + jsval arg[2]; + js_proxy_t *proxy = js_get_or_create_proxy(cx, widget); + if(proxy) + arg[0] = OBJECT_TO_JSVAL(proxy->obj); + else + arg[0] = JSVAL_NULL; + arg[1] = int32_to_jsval(cx, (int32_t)type); + jsval rval; + + bool ok = func->invoke(2, arg, rval); + if (!ok && JS_IsExceptionPending(cx)) { + JS_ReportPendingException(cx); + } + }; + cocos2d::ui::ListView::ccListViewCallback cb = lambda; + cobj->addEventListener(cb); + return true; + } JS_ReportError(cx, "Invalid number of arguments"); return false; } @@ -541,4 +682,4 @@ void register_all_cocos2dx_ui_manual(JSContext* cx, JSObject* global) JS_DefineFunction(cx, jsb_cocos2d_ui_LayoutParameter_prototype, "getMargin", js_cocos2dx_LayoutParameter_getMargin, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocos2d_ui_EditBox_prototype, "setDelegate", js_cocos2dx_CCEditBox_setDelegate, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); -} \ No newline at end of file +} diff --git a/frameworks/js-bindings/bindings/proj.ios_mac/libjs_static.arm64.a b/frameworks/js-bindings/bindings/proj.ios_mac/libjs_static.arm64.a deleted file mode 100644 index ed81d1368b..0000000000 Binary files a/frameworks/js-bindings/bindings/proj.ios_mac/libjs_static.arm64.a and /dev/null differ diff --git a/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_create_apis.js b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_create_apis.js new file mode 100644 index 0000000000..f66f88e471 --- /dev/null +++ b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_create_apis.js @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +ccui.Widget.prototype.init = ccui.Widget.prototype._init; +ccui.RichText.prototype.init = function(){ + ccui.Widget.prototype.init.call(this); +}; +ccui.Slider.prototype.init = function(){ + ccui.Widget.prototype.init.call(this); + this.setTouchEnabled(true); +}; + +ccui.Widget.prototype._ctor + = ccui.RichText.prototype._ctor + = ccui.Slider.prototype._ctor + = ccui.Layout.prototype._ctor + = ccui.ListView.prototype._ctor + = ccui.PageView.prototype._ctor + = ccui.ScrollView.prototype._ctor + = function(){ + this.init(); + } + +ccui.Button.prototype._ctor = function (normalImage, selectedImage,disableImage, texType) { + texType !== undefined ? ccui.Button.prototype.init.call(this, normalImage, selectedImage,disableImage, texType) : ccui.Widget.prototype.init.call(this); + this.setTouchEnabled(true); +}; + +ccui.CheckBox.prototype._ctor = function (backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType) { + if (frontCrossDisabled !== undefined) { + texType = texType || ccui.Widget.LOCAL_TEXTURE; + ccui.CheckBox.prototype.init.call(this, backGround, backGroundSelected, cross, backGroundDisabled, frontCrossDisabled, texType); + } + else { + ccui.Widget.prototype.init.call(this); + } + this.setSelected(false); + this.setTouchEnabled(true); +}; + +ccui.ImageView.prototype._ctor = function(imageFileName, texType){ + if(texType !== undefined) + ccui.ImageView.prototype._init.call(this, imageFileName, texType); + else + ccui.Widget.prototype.init.call(this); +} + +ccui.LoadingBar.prototype._ctor = function(textureName, percentage){ + ccui.Widget.prototype.init.call(this); + + if(textureName !== undefined) + this.loadTexture(textureName); + if(percentage !== undefined) + this.setPercent(percentage); +}; + +ccui.TextAtlas.prototype._ctor = function(stringValue, charMapFile, itemWidth, itemHeight, startCharMap){ + ccui.Widget.prototype.init.call(this); + startCharMap !== undefined && this.setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap); +}; + +ccui.Text.prototype._ctor = function(textContent, fontName, fontSize){ + if(fontSize !== undefined) + ccui.Text.prototype.init.call(this, textContent, fontName, fontSize); + else + ccui.Widget.prototype.init.call(this); +}; + +ccui.TextBMFont.prototype._ctor = function(text, filename){ + ccui.Widget.prototype.init.call(this); + + if(filename !== undefined){ + this.setFntFile(filename); + this.setString(text); + } +}; + +ccui.TextField.prototype._ctor = function(placeholder, fontName, fontSize){ + ccui.Widget.prototype.init.call(this); + this.setTouchEnabled(true); + + if (placeholder !== undefined) + this.setPlaceHolder(placeholder); + if (fontName !== undefined) + this.setFontName(fontName); + if (fontSize !== undefined) + this.setFontSize(fontSize); +}; + +ccui.RichElementText.prototype._ctor = function(tag, color, opacity, text, fontName, fontSize){ + fontSize !== undefined && this.init(tag, color, opacity, text, fontName, fontSize); +}; + +ccui.RichElementImage.prototype._ctor = function(tag, color, opacity, filePath){ + filePath !== undefined && this.init(tag, color, opacity, filePath); +}; + +ccui.RichElementCustomNode.prototype._ctor = function(tag, color, opacity, customNode){ + customNode !== undefined && this.init(tag, color, opacity, customNode); +}; + +cc.Scale9Sprite.prototype._ctor = function(file, rect, capInsets){ + rect = rect || cc.rect(0, 0, 0, 0); + capInsets = capInsets || cc.rect(0, 0, 0, 0); + if(file != undefined){ + if(file instanceof cc.SpriteFrame) + this.initWithSpriteFrame(file, rect); + else{ + var frame = cc.spriteFrameCache.getSpriteFrame(file); + if(frame != null) + this.initWithSpriteFrame(frame, rect); + else + this.initWithFile(file, rect, capInsets); + } + }else{ + this.init(); + } +}; + +cc.EditBox.prototype._ctor = function(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg){ + normal9SpriteBg && this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg); +}; \ No newline at end of file diff --git a/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_deprecated.js b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_deprecated.js new file mode 100644 index 0000000000..5144d54931 --- /dev/null +++ b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_deprecated.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * + * 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. + */ + +// Deprecated functions + +var cc = cc || {}; + +(function() { + + ccui.Text.prototype.setText = function(text){ + logW("ccui.Text.setText", "ccui.Text.setString"); + this.setString(text); + }; + + ccui.Text.prototype.getStringValue = function(){ + logW("ccui.Text.getStringValue", "ccui.Text.getString"); + return this.getString(); + }; + +})(); diff --git a/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_property_apis.js b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_property_apis.js new file mode 100644 index 0000000000..4fd8a4861c --- /dev/null +++ b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_property_apis.js @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +var _proto = ccui.Widget.prototype; +cc.defineGetterSetter(_proto, "xPercent", _proto._getXPercent, _proto._setXPercent); +cc.defineGetterSetter(_proto, "yPercent", _proto._getYPercent, _proto._setYPercent); +cc.defineGetterSetter(_proto, "widthPercent", _proto._getWidthPercent, _proto._setWidthPercent); +cc.defineGetterSetter(_proto, "heightPercent", _proto._getHeightPercent, _proto._setHeightPercent); +cc.defineGetterSetter(_proto, "widgetParent", _proto.getWidgetParent); +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); +cc.defineGetterSetter(_proto, "focused", _proto.isFocused, _proto.setFocused); +cc.defineGetterSetter(_proto, "sizeType", _proto.getSizeType, _proto.setSizeType); +cc.defineGetterSetter(_proto, "widgetType", _proto.getWidgetType); +cc.defineGetterSetter(_proto, "touchEnabled", _proto.isTouchEnabled, _proto.setTouchEnabled); +cc.defineGetterSetter(_proto, "updateEnabled", _proto.isUpdateEnabled, _proto.setUpdateEnabled); +cc.defineGetterSetter(_proto, "bright", _proto.isBright, _proto.setBright); +cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); +cc.defineGetterSetter(_proto, "actionTag", _proto.getActionTag, _proto.setActionTag); +cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX); +cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); +cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); +cc.defineGetterSetter(_proto, "children", _proto.getChildren); +cc.defineGetterSetter(_proto, "childrenCount", _proto.getChildrenCount); + +_proto = ccui.Layout.prototype; +cc.defineGetterSetter(_proto, "clippingEnabled", _proto.isClippingEnabled, _proto.setClippingEnabled); +cc.defineGetterSetter(_proto, "clippingType", _proto.setClippingType); +cc.defineGetterSetter(_proto, "layoutType", _proto.getLayoutType, _proto.setLayoutType); + +_proto = ccui.Button.prototype; +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "titleText", _proto.getTitleText, _proto.setTitleText); +cc.defineGetterSetter(_proto, "titleFont", _proto._getTitleFont, _proto._setTitleFont); +cc.defineGetterSetter(_proto, "titleFontSize", _proto.getTitleFontSize, _proto.setTitleFontSize); +cc.defineGetterSetter(_proto, "titleFontName", _proto.getTitleFontName, _proto.setTitleFontName); +cc.defineGetterSetter(_proto, "titleFontColor", _proto.getTitleFontColor, _proto.setTitleFontColor); +cc.defineGetterSetter(_proto, "pressedActionEnabled", _proto.getPressedActionEnabled, _proto.setPressedActionEnabled); +cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); +cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); +cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); +cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); +cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); + +_proto = ccui.CheckBox.prototype; +cc.defineGetterSetter(_proto, "selected", _proto.getSelected, _proto.setSelected); +cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); +cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); +cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); +cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); + +_proto = ccui.Text.prototype; +cc.defineGetterSetter(_proto, "boundingWidth", _proto._getBoundingWidth, _proto._setBoundingWidth); +cc.defineGetterSetter(_proto, "boundingHeight", _proto._getBoundingHeight, _proto._setBoundingHeight); +cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); +cc.defineGetterSetter(_proto, "stringLength", _proto.getStringLength); +cc.defineGetterSetter(_proto, "font", _proto._getFont, _proto._setFont); +cc.defineGetterSetter(_proto, "fontName", _proto.getFontName, _proto.setFontName); +cc.defineGetterSetter(_proto, "fontSize", _proto.getFontSize, _proto.setFontSize); +cc.defineGetterSetter(_proto, "textAlign", _proto.getHorizontalAlignment, _proto.setTextHorizontalAlignment); +cc.defineGetterSetter(_proto, "verticalAlign", _proto.getVerticalAlignment, _proto.setTextVerticalAlignment); +cc.defineGetterSetter(_proto, "touchScaleEnabled", _proto.getTouchScaleEnabled, _proto.setTouchScaleEnabled); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); +cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); +cc.defineGetterSetter(_proto, "scaleX", _proto.getScaleX, _proto.setScaleX); +cc.defineGetterSetter(_proto, "scaleY", _proto.getScaleY, _proto.setScaleY); +cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); +cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); + +_proto = ccui.TextAtlas.prototype; +cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); +cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); + +_proto = ccui.TextBMFont.prototype; +cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); +cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); + +_proto = ccui.LoadingBar.prototype; +cc.defineGetterSetter(_proto, "direction", _proto.getDirection, _proto.setDirection); +cc.defineGetterSetter(_proto, "percent", _proto.getPercent, _proto.setPercent); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); + +_proto = ccui.Slider.prototype; +cc.defineGetterSetter(_proto, "percent", _proto.getPercent, _proto.setPercent); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); + +_proto = ccui.TextField.prototype; +cc.defineGetterSetter(_proto, "maxLengthEnabled", _proto.isMaxLengthEnabled, _proto.setMaxLengthEnabled); +cc.defineGetterSetter(_proto, "maxLength", _proto.getMaxLength, _proto.setMaxLength); +cc.defineGetterSetter(_proto, "passwordEnabled", _proto.isPasswordEnabled, _proto.setPasswordEnabled); +cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); +cc.defineGetterSetter(_proto, "font", _proto._getFont, _proto._setFont); +cc.defineGetterSetter(_proto, "fontSize", _proto.getFontSize, _proto.setFontSize); +cc.defineGetterSetter(_proto, "fontName", _proto.getFontName, _proto.setFontName); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); +cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); + +_proto = ccui.ScrollView.prototype; +cc.defineGetterSetter(_proto, "innerWidth", _proto._getInnerWidth, _proto._setInnerWidth); +cc.defineGetterSetter(_proto, "innerHeight", _proto._getInnerHeight, _proto._setInnerHeight); +cc.defineGetterSetter(_proto, "bounceEnabled", _proto.getBounceEnabled, _proto.setBounceEnabled); +cc.defineGetterSetter(_proto, "inertiaScrollEnabled", _proto.getInertiaScrollEnabled, _proto.setInertiaScrollEnabled); +cc.defineGetterSetter(_proto, "children", _proto.getChildren); +cc.defineGetterSetter(_proto, "childrenCount", _proto.getChildrenCount); +cc.defineGetterSetter(_proto, "layoutType", _proto.getLayoutType, _proto.setLayoutType); + +_proto = cc.Scale9Sprite.prototype; +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); +cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); +cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); +cc.defineGetterSetter(_proto, "preferredSize", _proto.getPreferredSize, _proto.setPreferredSize); +cc.defineGetterSetter(_proto, "capInsets", _proto.getCapInsets, _proto.setCapInsets); +cc.defineGetterSetter(_proto, "insetLeft", _proto.getInsetLeft, _proto.setInsetLeft); +cc.defineGetterSetter(_proto, "insetTop", _proto.getInsetTop, _proto.setInsetTop); +cc.defineGetterSetter(_proto, "insetRight", _proto.getInsetRight, _proto.setInsetRight); +cc.defineGetterSetter(_proto, "insetBottom", _proto.getInsetBottom, _proto.setInsetBottom); + +_proto = cc.EditBox.prototype; +cc.defineGetterSetter(_proto, "font", null, _proto._setFont); +cc.defineGetterSetter(_proto, "fontName", null, _proto.setFontName); +cc.defineGetterSetter(_proto, "fontSize", null, _proto.setFontSize); +cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); +cc.defineGetterSetter(_proto, "maxLength", _proto.getMaxLength, _proto.setMaxLength); + +_proto = ccui.ImageView.prototype; +cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); +cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); +cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); +cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); diff --git a/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_property_impls.js b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_property_impls.js new file mode 100644 index 0000000000..17ec7140b2 --- /dev/null +++ b/frameworks/js-bindings/bindings/script/ccui/jsb_ccui_property_impls.js @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +// Override width and height getter setter +_forceExtend(ccui.Widget.prototype, { + _getXPercent: function() { + return this.getPositionPercent().x; + }, + _getYPercent: function() { + return this.getPositionPercent().y; + }, + + _setXPercent: function(x) { + var p = cc.p(x, this.getPositionPercent().y); + this.setPositionPercent(p); + }, + _setYPercent: function(y) { + var p = cc.p(this.getPositionPercent().x, y); + this.setPositionPercent(p); + }, + + _getWidth: function() { + return this.getContentSize().width; + }, + _getHeight: function() { + return this.getContentSize().height; + }, + _getWidthPercent: function() { + return this.getSizePercent().width; + }, + _getHeightPercent: function() { + return this.getSizePercent().height; + }, + + _setWidth: function(w) { + var size = cc.size(w, this.getContentSize().height); + this.setContentSize(size); + }, + _setHeight: function(h) { + var size = cc.size(this.getContentSize().width, h); + this.setContentSize(size); + }, + _setWidthPercent: function(w) { + var size = cc.size(w, this.getSizePercent().height); + this.setSizePercent(size); + }, + _setHeightPercent: function(h) { + var size = cc.size(this.getSizePercent().width, h); + this.setSizePercent(size); + } +}); + +_safeExtend(ccui.Button.prototype, { + _fontStyleRE: /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/, + + _getTitleFont: function() { + var size = this.getTitleFontSize(); + var name = this.getTitleFontName(); + return size + "px '" + name + "'"; + }, + + _setTitleFont: function(fontStyle) { + var res = this._fontStyleRE.exec(fontStyle); + if(res) { + this.setTitleFontSize(parseInt(res[1])); + this.setTitleFontName(res[2]); + } + } +}); + +_safeExtend(ccui.Text.prototype, { + _getBoundingWidth: function() { + return this.getTextAreaSize().width; + }, + _getBoundingHeight: function() { + return this.getTextAreaSize().height; + }, + + _setBoundingWidth: function(w) { + var size = cc.size(w, this.getTextAreaSize().height); + this.setTextAreaSize(size); + }, + _setBoundingHeight: function(h) { + var size = cc.size(this.getTextAreaSize().width, h); + this.setTextAreaSize(size); + } +}); + +_safeExtend(ccui.TextField.prototype, { + _fontStyleRE: /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/, + + _getFont: function() { + var size = this.getFontSize(); + var name = this.getFontName(); + return size + "px '" + name + "'"; + }, + + _setFont: function(fontStyle) { + var res = this._fontStyleRE.exec(fontStyle); + if(res) { + this.setFontSize(parseInt(res[1])); + this.setFontName(res[2]); + } + } +}); + +_safeExtend(ccui.ScrollView.prototype, { + _getInnerWidth: function() { + return this.getInnerContainerSize().width; + }, + _getInnerHeight: function() { + return this.getInnerContainerSize().height; + }, + + _setInnerWidth: function(w) { + var size = cc.size(w, this.getInnerContainerSize().height); + this.setInnerContainerSize(size); + }, + _setInnerHeight: function(h) { + var size = cc.size(this.getInnerContainerSize().width, h); + this.setInnerContainerSize(size); + } +}); + +// _safeExtend(ccui.EditBox.prototype, { +// _setFont: function(fontStyle) { +// var res = cc.LabelTTF.prototype._fontStyleRE.exec(fontStyle); +// if(res) { +// this.setFontSize(parseInt(res[1])); +// this.setFontName(res[2]); +// } +// } +// }); \ No newline at end of file diff --git a/frameworks/js-bindings/bindings/script/jsb_cocos2d_ui.js b/frameworks/js-bindings/bindings/script/ccui/jsb_cocos2d_ui.js similarity index 92% rename from frameworks/js-bindings/bindings/script/jsb_cocos2d_ui.js rename to frameworks/js-bindings/bindings/script/ccui/jsb_cocos2d_ui.js index 177a2a7420..fdd0b5ca85 100644 --- a/frameworks/js-bindings/bindings/script/jsb_cocos2d_ui.js +++ b/frameworks/js-bindings/bindings/script/ccui/jsb_cocos2d_ui.js @@ -227,6 +227,16 @@ ccui.PRESSED_RENDERER_ZORDER = -2; ccui.DISABLED_RENDERER_ZORDER = -2; ccui.TITLE_RENDERER_ZORDER = -1; +ccui.Scale9Sprite.POSITIONS_CENTRE = 0; //CCScale9Sprite.js +ccui.Scale9Sprite.POSITIONS_TOP = 1; +ccui.Scale9Sprite.POSITIONS_LEFT = 2; +ccui.Scale9Sprite.POSITIONS_RIGHT = 3; +ccui.Scale9Sprite.POSITIONS_BOTTOM = 4; +ccui.Scale9Sprite.POSITIONS_TOPRIGHT = 5; +ccui.Scale9Sprite.POSITIONS_TOPLEFT = 6; +ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; +ccui.Scale9Sprite.POSITIONS_BOTTOMLEFT = 8; + /* * UICheckBox */ @@ -339,6 +349,11 @@ ccui.MarginZero = function(){ return new ccui.Margin(0,0,0,0); }; +// updateWithBatchNode deprecated in JSB +ccui.Scale9Sprite.prototype.updateWithBatchNode = function (batchNode, originalRect, rotated, capInsets) { + var sprite = new cc.Sprite(batchNode.getTexture()); + this.updateWithSprite(sprite, originalRect, rotated, cc.p(0, 0), cc.size(originalRect.width, originalRect.height), capInsets); +}; /* * UIWidget temporary solution to addChild @@ -346,10 +361,4 @@ ccui.MarginZero = function(){ */ ccui.Widget.prototype.addNode = ccui.Widget.prototype.addChild; ccui.Widget.prototype.getSize = ccui.Widget.prototype.getContentSize; -ccui.Widget.prototype.setSize = ccui.Widget.prototype.setContentSize; - -/* - * UITextField temporary solution to getString, wait for -x patch - */ -ccui.TextField.prototype.getString = ccui.TextField.prototype.getStringValue; -ccui.TextField.prototype.setString = ccui.TextField.prototype.setText; \ No newline at end of file +ccui.Widget.prototype.setSize = ccui.Widget.prototype.setContentSize; \ No newline at end of file diff --git a/frameworks/js-bindings/bindings/script/jsb_chipmunk.js b/frameworks/js-bindings/bindings/script/chipmunk/jsb_chipmunk.js similarity index 63% rename from frameworks/js-bindings/bindings/script/jsb_chipmunk.js rename to frameworks/js-bindings/bindings/script/chipmunk/jsb_chipmunk.js index 57ebb681bb..fa7bedc59a 100644 --- a/frameworks/js-bindings/bindings/script/jsb_chipmunk.js +++ b/frameworks/js-bindings/bindings/script/chipmunk/jsb_chipmunk.js @@ -149,16 +149,7 @@ cp.bb = function(l, b, r, t) { // var _proto = cp.Base.prototype; // "handle" needed in some cases -Object.defineProperties(cp.Base.prototype, - { - "handle" : { - get : function(){ - return this.getHandle(); - }, - enumerable : true, - configurable : true - } - }); +cc.defineGetterSetter(_proto, "handle", _proto.getHandle); // Properties, for Chipmunk-JS compatibility // Space properties @@ -264,60 +255,19 @@ Object.defineProperties(cp.Space.prototype, }); // Body properties -Object.defineProperties(cp.Body.prototype, - { - "a" : { - get : function(){ - return this.getAngle(); - }, - set : function(newValue){ - this.setAngle(newValue); - }, - enumerable : true, - configurable : true - }, - "w" : { - get : function(){ - return this.getAngVel(); - }, - set : function(newValue){ - this.setAngVel(newValue); - }, - enumerable : true, - configurable : true - }, - "p" : { - get : function(){ - return this.getPos(); - }, - set : function(newValue){ - this.setPos(newValue); - }, - enumerable : true, - configurable : true - }, - "v" : { - get : function(){ - return this.getVel(); - }, - set : function(newValue){ - this.setVel(newValue); - }, - enumerable : true, - configurable : true - }, - "i" : { - get : function(){ - return this.getMoment(); - }, - set : function(newValue){ - this.setMoment(newValue); - }, - enumerable : true, - configurable : true - } - - }); +_proto = cp.Body.prototype; +cc.defineGetterSetter(_proto, "a", _proto.getAngle, _proto.setAngle); +cc.defineGetterSetter(_proto, "w", _proto.getAngVel, _proto.setAngVel); +cc.defineGetterSetter(_proto, "p", _proto.getPos, _proto.setPos); +cc.defineGetterSetter(_proto, "v", _proto.getVel, _proto.setVel); +cc.defineGetterSetter(_proto, "f", _proto.getForce, _proto.setForce); +cc.defineGetterSetter(_proto, "t", _proto.getTorque, _proto.setTorque); +cc.defineGetterSetter(_proto, "v_limit", _proto.getVelLimit, _proto.setVelLimit); +cc.defineGetterSetter(_proto, "w_limit", _proto.getAngVelLimit, _proto.setAngVelLimit); +cc.defineGetterSetter(_proto, "space", _proto.getSpace); +cc.defineGetterSetter(_proto, "rot", _proto.getRot); +cc.defineGetterSetter(_proto, "m", _proto.getMass, _proto.setMass); +cc.defineGetterSetter(_proto, "i", _proto.getMoment, _proto.setMoment); // Shape properties _proto = cp.Shape.prototype; @@ -330,45 +280,97 @@ cc.defineGetterSetter(_proto, "space", _proto.getSpace); cc.defineGetterSetter(_proto, "surface_v", _proto.getSurfaceVelocity, _proto.setSurfaceVelocity); cc.defineGetterSetter(_proto, "e", _proto.getElasticity, _proto.setElasticity); cc.defineGetterSetter(_proto, "u", _proto.getFriction, _proto.setFriction); +_proto.cacheData = _proto.update; + +//CircleShape properties +_proto = cp.CircleShape.prototype; +_proto.type = "circle"; +cc.defineGetterSetter(_proto, "r", _proto.getRadius); +cc.defineGetterSetter(_proto, "c", _proto.getOffset); + +//SegmentShape properties +_proto = cp.SegmentShape.prototype; +_proto.type = "segment"; +cc.defineGetterSetter(_proto, "a", _proto.getA); +cc.defineGetterSetter(_proto, "b", _proto.getB); +cc.defineGetterSetter(_proto, "n", _proto.getNormal); +cc.defineGetterSetter(_proto, "r", _proto.getRadius); + +//PolyShape properties +_proto = cp.PolyShape.prototype; +_proto.type = "poly"; // Constraint properties -Object.defineProperties(cp.Constraint.prototype, - { - "maxForce" : { - get : function(){ - return this.getMaxForce(); - }, - set : function(newValue){ - this.setMaxForce(newValue); - }, - enumerable : true, - configurable : true - } - }); +_proto = cp.Constraint.prototype; +cc.defineGetterSetter(_proto, "a", _proto.getA); +cc.defineGetterSetter(_proto, "b", _proto.getB); +cc.defineGetterSetter(_proto, "space", _proto.getSpace); +cc.defineGetterSetter(_proto, "maxForce", _proto.getMaxForce, _proto.setMaxForce); +cc.defineGetterSetter(_proto, "errorBias", _proto.getErrorBias, _proto.setErrorBias); +cc.defineGetterSetter(_proto, "maxBias", _proto.getMaxBias, _proto.setMaxBias); // PinJoint properties -Object.defineProperties(cp.PinJoint.prototype, - { - "anchr1" : { - get : function(){ - return this.getAnchr1(); - }, - set : function(newValue){ - this.setAnchr1(newValue); - }, - enumerable : true, - configurable : true - }, - "anchr2" : { - get : function(){ - return this.getAnchr2(); - }, - set : function(newValue){ - this.setAnchr2(newValue); - }, - enumerable : true, - configurable : true - } - }); +_proto = cp.PinJoint.prototype; +cc.defineGetterSetter(_proto, "anchr1", _proto.getAnchr1, _proto.setAnchr1); +cc.defineGetterSetter(_proto, "anchr2", _proto.getAnchr2, _proto.setAnchr2); +cc.defineGetterSetter(_proto, "dist", _proto.getDist, _proto.setDist); + +//SlideJoint properties +_proto = cp.SlideJoint.prototype; +cc.defineGetterSetter(_proto, "anchr1", _proto.getAnchr1, _proto.setAnchr1); +cc.defineGetterSetter(_proto, "anchr2", _proto.getAnchr2, _proto.setAnchr2); +cc.defineGetterSetter(_proto, "min", _proto.getMin, _proto.setMin); +cc.defineGetterSetter(_proto, "max", _proto.getMax, _proto.setMax); + +//PivotJoint properties +_proto = cp.PivotJoint.prototype; +cc.defineGetterSetter(_proto, "anchr1", _proto.getAnchr1, _proto.setAnchr1); +cc.defineGetterSetter(_proto, "anchr2", _proto.getAnchr2, _proto.setAnchr2); + +//GrooveJoint properties +_proto = cp.GrooveJoint.prototype; +cc.defineGetterSetter(_proto, "anchr2", _proto.getAnchr2, _proto.setAnchr2); +cc.defineGetterSetter(_proto, "grv_a", _proto.getGrooveA, _proto.setGrooveA); +cc.defineGetterSetter(_proto, "grv_b", _proto.getGrooveB, _proto.setGrooveB); + +//DampedSpring properties +_proto = cp.DampedSpring.prototype; +cc.defineGetterSetter(_proto, "anchr1", _proto.getAnchr1, _proto.setAnchr1); +cc.defineGetterSetter(_proto, "anchr2", _proto.getAnchr2, _proto.setAnchr2); +cc.defineGetterSetter(_proto, "damping", _proto.getDamping, _proto.setDamping); +cc.defineGetterSetter(_proto, "restLength", _proto.getRestLength, _proto.setRestLength); +cc.defineGetterSetter(_proto, "stiffness", _proto.getStiffness, _proto.setStiffness); + +//DampedRotarySpring properties +_proto = cp.DampedRotarySpring.prototype; +cc.defineGetterSetter(_proto, "restAngle", _proto.getRestAngle, _proto.setRestAngle); +cc.defineGetterSetter(_proto, "stiffness", _proto.getStiffness, _proto.setStiffness); +cc.defineGetterSetter(_proto, "damping", _proto.getDamping, _proto.setDamping); + +//RotaryLimitJoint properties +_proto = cp.RotaryLimitJoint.prototype; +cc.defineGetterSetter(_proto, "min", _proto.getMin, _proto.setMin); +cc.defineGetterSetter(_proto, "max", _proto.getMax, _proto.setMax); + +//RatchetJoint properties +_proto = cp.RatchetJoint.prototype; +cc.defineGetterSetter(_proto, "angle", _proto.getAngle, _proto.setAngle); +cc.defineGetterSetter(_proto, "phase", _proto.getPhase, _proto.setPhase); +cc.defineGetterSetter(_proto, "ratchet", _proto.getRatchet, _proto.setRatchet); + +//GearJoint properties +_proto = cp.GearJoint.prototype; +cc.defineGetterSetter(_proto, "phase", _proto.getPhase, _proto.setPhase); +cc.defineGetterSetter(_proto, "ratio", _proto.getRatio, _proto.setRatio); + +//SimpleMotor properties +_proto = cp.SimpleMotor.prototype; +cc.defineGetterSetter(_proto, "rate", _proto.getRate, _proto.setRate); + +//Arbiter properties +_proto = cp.Arbiter.prototype; +cc.defineGetterSetter(_proto, "e", _proto.getElasticity, _proto.setElasticity); +cc.defineGetterSetter(_proto, "u", _proto.getFriction, _proto.setFriction); +cc.defineGetterSetter(_proto, "surface_vr", _proto.getSurfaceVelocity, _proto.setSurfaceVelocity); -_proto = null; \ No newline at end of file +_proto = null; diff --git a/frameworks/js-bindings/bindings/script/jsb_chipmunk_constants.js b/frameworks/js-bindings/bindings/script/chipmunk/jsb_chipmunk_constants.js similarity index 100% rename from frameworks/js-bindings/bindings/script/jsb_chipmunk_constants.js rename to frameworks/js-bindings/bindings/script/chipmunk/jsb_chipmunk_constants.js diff --git a/frameworks/js-bindings/bindings/script/jsb_cocos2d_extension.js b/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js similarity index 81% rename from frameworks/js-bindings/bindings/script/jsb_cocos2d_extension.js rename to frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js index d7969d3f44..7477ca64c2 100644 --- a/frameworks/js-bindings/bindings/script/jsb_cocos2d_extension.js +++ b/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js @@ -20,6 +20,44 @@ * THE SOFTWARE. */ +/** + * @type {Object} + * @name jsb.AssetsManager + * jsb.AssetsManager is the native AssetsManager for your game resources or scripts. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en + * Only available in JSB + */ +jsb.AssetsManager = cc.AssetsManager; +delete cc.AssetsManager; +/** + * @type {Object} + * @name jsb.EventListenerAssetsManager + * jsb.EventListenerAssetsManager is the native event listener for AssetsManager. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en + * Only available in JSB + */ +jsb.EventListenerAssetsManager = cc.EventListenerAssetsManager; +delete cc.EventListenerAssetsManager; +/** + * @type {Object} + * @name jsb.EventAssetsManager + * jsb.EventAssetsManager is the native event for AssetsManager. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en + * Only available in JSB + */ +jsb.EventAssetsManager = cc.EventAssetsManager; +delete cc.EventAssetsManager; + +// move from jsb_cocos2d +//start------------------------------ +cc.ControlButton.extend = cc.Class.extend; +cc.ControlColourPicker.extend = cc.Class.extend; +cc.ControlPotentiometer.extend = cc.Class.extend; +cc.ControlSlider.extend = cc.Class.extend; +cc.ControlStepper.extend = cc.Class.extend; +cc.ControlSwitch.extend = cc.Class.extend; +//end------------------------------ + // // cocos2d constants // @@ -186,16 +224,6 @@ cc.CONTROL_STEPPER_LABELFONT = "CourierNewPSMT"; cc.AUTOREPEAT_DELTATIME = 0.15; cc.AUTOREPEAT_INCREASETIME_INCREMENT = 12; -cc.Scale9Sprite.POSITIONS_CENTRE = 0; //CCScale9Sprite.js -cc.Scale9Sprite.POSITIONS_TOP = 1; -cc.Scale9Sprite.POSITIONS_LEFT = 2; -cc.Scale9Sprite.POSITIONS_RIGHT = 3; -cc.Scale9Sprite.POSITIONS_BOTTOM = 4; -cc.Scale9Sprite.POSITIONS_TOPRIGHT = 5; -cc.Scale9Sprite.POSITIONS_TOPLEFT = 6; -cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7; -cc.Scale9Sprite.POSITIONS_BOTTOMLEFT = 8; - jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST = 0; jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST = 1; @@ -209,48 +237,7 @@ jsb.EventAssetsManager.UPDATE_FINISHED = 8; jsb.EventAssetsManager.UPDATE_FAILED = 9; jsb.EventAssetsManager.ERROR_DECOMPRESS = 10; -// PhysicsDebugNode -cc.PhysicsDebugNode.create = function( space ) { - var s = space; - if( space.handle !== undefined ) - s = space.handle; - return cc.PhysicsDebugNode._create( s ); -}; - -cc.PhysicsDebugNode.prototype._ctor = function(space){ - this.init(); - var s = space; - if( space.handle !== undefined ) - s = space.handle; - this.setSpace(s); -}; - -cc.PhysicsDebugNode.prototype.setSpace = function( space ) { - var s = space; - if( space.handle !== undefined ) - s = space.handle; - return this._setSpace( s ); -}; - -// PhysicsSprite -cc.PhysicsSprite.prototype.setBody = function( body ) { - var b = body; - if( body.handle !== undefined ) - b = body.handle; - return this._setCPBody( b ); -}; - -cc.PhysicsSprite.prototype.getBody = function() { - return this.getCPBody(); -}; - cc.ScrollView.extend = cc.Class.extend; cc.TableView.extend = cc.Class.extend; cc.TableViewCell.extend = cc.Class.extend; -cc.GLNode.extend = cc.Class.extend; -// updateWithBatchNode deprecated in JSB -cc.Scale9Sprite.prototype.updateWithBatchNode = function (batchNode, originalRect, rotated, capInsets) { - var sprite = new cc.Sprite(batchNode.getTexture()); - this.updateWithSprite(sprite, originalRect, rotated, cc.p(0, 0), cc.size(originalRect.width, originalRect.height), capInsets); -}; diff --git a/frameworks/js-bindings/bindings/script/extension/jsb_ext_create_apis.js b/frameworks/js-bindings/bindings/script/extension/jsb_ext_create_apis.js new file mode 100644 index 0000000000..ab0b45867e --- /dev/null +++ b/frameworks/js-bindings/bindings/script/extension/jsb_ext_create_apis.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +/************************************************************ + * + * Constructors with built in init function + * + ************************************************************/ + +jsb.EventListenerAssetsManager.prototype._ctor = function(assetsManager, callback) { + callback !== undefined && this.init(assetsManager, callback); +}; + + + +cc.ControlButton.prototype._ctor = function(label, backgroundSprite, fontSize){ + if(fontSize != undefined) + this.initWithTitleAndFontNameAndFontSize(label, backgroundSprite, fontSize); + else if(backgroundSprite != undefined) + this.initWithLabelAndBackgroundSprite(label, backgroundSprite); + else if(label != undefined) + this.initWithBackgroundSprite(label); + else + this.init(); +}; + +cc.ControlColourPicker.prototype._ctor = function(){ + this.init(); +}; + +cc.ControlPotentiometer.prototype._ctor = function(backgroundFile, progressFile, thumbFile){ + if (thumbFile != undefined) { + // Prepare track for potentiometer + var backgroundSprite = cc.Sprite.create(backgroundFile); + + // Prepare thumb for potentiometer + var thumbSprite = cc.Sprite.create(thumbFile); + + // Prepare progress for potentiometer + var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); + this.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite); + } +}; + +cc.ControlSlider.prototype._ctor = function(bgFile, progressFile, thumbFile){ + if (thumbFile != undefined) { + // Prepare background for slider + bgSprite = cc.Sprite.create(bgFile); + + // Prepare progress for slider + progressSprite = cc.Sprite.create(progressFile); + + // Prepare thumb (menuItem) for slider + thumbSprite = cc.Sprite.create(thumbFile); + + this.initWithSprites(bgSprite, progressSprite, thumbSprite); + } +}; + +cc.ControlStepper.prototype._ctor = function(minusSprite, plusSprite){ + plusSprite !== undefined && this.initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite); +}; + +cc.ControlSwitch.prototype._ctor = function(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel){ + offLabel !== undefined && this.initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); +}; + +cc.TableView.prototype._ctor = function(dataSouurce, size, container){ + container == undefined ? this._init(dataSouurce, size) : this._init(dataSouurce, size, container); +}; + +cc.ScrollView.prototype._ctor = function(size, container) { + size == undefined ? this.init() : (container ? this.initWithViewSize(size, container) : this.initWithViewSize(size)); +}; + + diff --git a/frameworks/js-bindings/bindings/script/extension/jsb_ext_property_apis.js b/frameworks/js-bindings/bindings/script/extension/jsb_ext_property_apis.js new file mode 100644 index 0000000000..eba04c4541 --- /dev/null +++ b/frameworks/js-bindings/bindings/script/extension/jsb_ext_property_apis.js @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +var _proto = cc.Control.prototype; +cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); +cc.defineGetterSetter(_proto, "state", _proto.getState); +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); +cc.defineGetterSetter(_proto, "selected", _proto.isSelected, _proto.setSelected); +cc.defineGetterSetter(_proto, "highlighted", _proto.isHighlighted, _proto.setHighlighted); + +_proto = cc.ControlButton.prototype; +cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); +cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); +cc.defineGetterSetter(_proto, "adjustBackgroundImage", _proto.getAdjustBackgroundImage, _proto.setAdjustBackgroundImage); +cc.defineGetterSetter(_proto, "zoomOnTouchDown", _proto.getZoomOnTouchDown, _proto.setZoomOnTouchDown); +cc.defineGetterSetter(_proto, "preferredSize", _proto.getPreferredSize, _proto.setPreferredSize); +cc.defineGetterSetter(_proto, "labelAnchor", _proto.getLabelAnchorPoint, _proto.setLabelAnchorPoint); + +_proto = cc.ControlColourPicker.prototype; +cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); +cc.defineGetterSetter(_proto, "background", _proto.getBackground); + +_proto = cc.ControlHuePicker.prototype; +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); +cc.defineGetterSetter(_proto, "hue", _proto.getHue, _proto.setHue); +cc.defineGetterSetter(_proto, "huePercent", _proto.getHuePercentage, _proto.setHuePercentage); +cc.defineGetterSetter(_proto, "background", _proto.getBackground); +cc.defineGetterSetter(_proto, "slider", _proto.getSlider); +cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); + +_proto = cc.ControlPotentiometer.prototype; +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); +cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); +cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); +cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); +cc.defineGetterSetter(_proto, "progressTimer", _proto.getProgressTimer, _proto.setProgressTimer); +cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite, _proto.setThumbSprite); +cc.defineGetterSetter(_proto, "prevLocation", _proto.getPreviousLocation, _proto.setPreviousLocation); + +_proto = cc.ControlSaturationBrightnessPicker.prototype; +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); +cc.defineGetterSetter(_proto, "saturation", _proto.getSaturation); +cc.defineGetterSetter(_proto, "brightness", _proto.getBrightness); +cc.defineGetterSetter(_proto, "background", _proto.getBackground); +cc.defineGetterSetter(_proto, "overlay", _proto.getOverlay); +cc.defineGetterSetter(_proto, "shadow", _proto.getShadow); +cc.defineGetterSetter(_proto, "slider", _proto.getSlider); +cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); + +_proto = cc.ControlSlider.prototype; +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); +cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); +cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); +cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); +cc.defineGetterSetter(_proto, "minAllowedValue", _proto.getMinimumAllowedValue, _proto.setMinimumAllowedValue); +cc.defineGetterSetter(_proto, "maxAllowedValue", _proto.getMaximumAllowedValue, _proto.setMaximumAllowedValue); +cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite); +cc.defineGetterSetter(_proto, "progressSprite", _proto.getProgressSprite); +cc.defineGetterSetter(_proto, "backgroundSprite", _proto.getBackgroundSprite); + +_proto = cc.ControlSwitch.prototype; +cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + +_proto = cc.ScrollView.prototype; +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "direction", _proto.getDirection, _proto.setDirection); + +_proto = cc.ControlStepper.prototype; +cc.defineGetterSetter(_proto, "wraps", _proto.getWraps, _proto.setWraps); +cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); +cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); +cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); +cc.defineGetterSetter(_proto, "stepValue", _proto.getStepValue, _proto.setStepValue); +cc.defineGetterSetter(_proto, "continuous", _proto.isContinuous); +cc.defineGetterSetter(_proto, "minusSprite", _proto.getMinusSprite, _proto.setMinusSprite); +cc.defineGetterSetter(_proto, "plusSprite", _proto.getPlusSprite, _proto.setPlusSprite); +cc.defineGetterSetter(_proto, "minusLabel", _proto.getMinusLabel, _proto.setMinusLabel); +cc.defineGetterSetter(_proto, "plusSLabel", _proto.getPlusSLabel, _proto.setPlusSLabel); + +_proto = cc.TableViewCell.prototype; +cc.defineGetterSetter(_proto, "objectId", _proto.getObjectID, _proto.setObjectID); diff --git a/frameworks/js-bindings/bindings/script/jsb.js b/frameworks/js-bindings/bindings/script/jsb.js index d637047c7f..3bd89b3426 100644 --- a/frameworks/js-bindings/bindings/script/jsb.js +++ b/frameworks/js-bindings/bindings/script/jsb.js @@ -27,15 +27,83 @@ // DO NOT ALTER THE ORDER require('script/jsb_cocos2d_constants.js'); require('script/jsb_cocos2d.js'); -require('script/jsb_cocos2d_extension.js'); -require('script/jsb_cocos2d_studio.js'); -require('script/jsb_cocos2d_ui.js'); + require('script/jsb_property_impls.js'); require('script/jsb_property_apis.js'); require('script/jsb_create_apis.js'); -require('script/jsb_ext_create_apis.js'); -require('script/jsb_chipmunk_constants.js'); -require('script/jsb_chipmunk.js'); + +if (cc.GLNode) { + cc.GLNode.extend = cc.Class.extend; // move from jsb_cocos2d_extension +} + +if (window.ccs) { + require('script/studio/jsb_studio_boot.js'); + ccs.Armature.extend = cc.Class.extend; // move from jsb_cocos2d.js + require('script/studio/jsb_cocos2d_studio.js'); + require('script/studio/jsb_studio_property_apis.js'); + require('script/studio/jsb_studio_create_apis.js'); +} + +if (window.ccui) { + // move from jsb_boot.js line 912 + //start------------------------------ + cc.EditBox = ccui.EditBox; + delete ccui.EditBox; + + cc.Scale9Sprite = ccui.Scale9Sprite; + + // GUI + /** + * @type {Object} + * UI Helper + */ + ccui.helper = ccui.Helper; + //end------------------------------ + + // move from jsb_cocos2d + //start------------------------------ + ccui.Widget.extend = cc.Class.extend; + ccui.Button.extend = cc.Class.extend; + ccui.CheckBox.extend = cc.Class.extend; + ccui.ImageView.extend = cc.Class.extend; + ccui.LoadingBar.extend = cc.Class.extend; + ccui.RichText.extend = cc.Class.extend; + ccui.Slider.extend = cc.Class.extend; + ccui.Text.extend = cc.Class.extend; + ccui.TextAtlas.extend = cc.Class.extend; + ccui.TextBMFont.extend = cc.Class.extend; + ccui.TextField.extend = cc.Class.extend; + ccui.Layout.extend = cc.Class.extend; + ccui.ListView.extend = cc.Class.extend; + ccui.PageView.extend = cc.Class.extend; + ccui.ScrollView.extend = cc.Class.extend; + ccui.Scale9Sprite.extend = cc.Class.extend; + //end------------------------------ + + require('script/ccui/jsb_cocos2d_ui.js'); + require('script/ccui/jsb_ccui_property_impls.js'); + require('script/ccui/jsb_ccui_property_apis.js'); + require('script/ccui/jsb_ccui_create_apis.js'); + require('script/ccui/jsb_ccui_deprecated.js'); +} + +if (cc.ControlButton) { + require('script/extension/jsb_cocos2d_extension.js'); + require('script/extension/jsb_ext_property_apis.js'); + require('script/extension/jsb_ext_create_apis.js'); +} + +if (cc.PhysicsSprite) { + cc.PhysicsSprite.extend = cc.Class.extend;// move from jsb_cocos2d.js + require('script/physicsSprite/jsb_physicsSprite.js'); +} + +if (window.cp) { + // chipmunk + require('script/chipmunk/jsb_chipmunk_constants.js'); + require('script/chipmunk/jsb_chipmunk.js'); +} + require('script/jsb_opengl_constants.js'); require('script/jsb_opengl.js'); require('script/jsb_cocosbuilder.js'); diff --git a/frameworks/js-bindings/bindings/script/jsb_boot.js b/frameworks/js-bindings/bindings/script/jsb_boot.js index 08cc22ca62..74c28d913e 100644 --- a/frameworks/js-bindings/bindings/script/jsb_boot.js +++ b/frameworks/js-bindings/bindings/script/jsb_boot.js @@ -31,21 +31,108 @@ var window = window || this; * Iterate over an object or an array, executing a function for each matched element. * @param {object|array} obj * @param {function} iterator - * @param [{object}] context + * @param {object} [context] */ -cc.each = function(obj, iterator, context){ - if(!obj) return; - if(obj instanceof Array){ - for(var i = 0, li = obj.length; i < li; i++){ - if(iterator.call(context, obj[i], i) === false) return; +cc.each = function (obj, iterator, context) { + if (!obj) + return; + if (obj instanceof Array) { + for (var i = 0, li = obj.length; i < li; i++) { + if (iterator.call(context, obj[i], i) === false) + return; } - }else{ + } else { for (var key in obj) { - if(iterator.call(context, obj[key], key) === false) return; + if (iterator.call(context, obj[key], key) === false) + return; } } }; +/** + * Copy all of the properties in source objects to target object and return the target object. + * @param {object} target + * @param {object} *sources + * @returns {object} + */ +cc.extend = function(target) { + var sources = arguments.length >= 2 ? Array.prototype.slice.call(arguments, 1) : []; + + cc.each(sources, function(src) { + for(var key in src) { + if (src.hasOwnProperty(key)) { + target[key] = src[key]; + } + } + }); + return target; +}; + +/** + * Check the obj whether is function or not + * @param {*} obj + * @returns {boolean} + */ +cc.isFunction = function(obj) { + return typeof obj == 'function'; +}; + +/** + * Check the obj whether is number or not + * @param {*} obj + * @returns {boolean} + */ +cc.isNumber = function(obj) { + return typeof obj == 'number' || Object.prototype.toString.call(obj) == '[object Number]'; +}; + +/** + * Check the obj whether is string or not + * @param {*} obj + * @returns {boolean} + */ +cc.isString = function(obj) { + return typeof obj == 'string' || Object.prototype.toString.call(obj) == '[object String]'; +}; + +/** + * Check the obj whether is array or not + * @param {*} obj + * @returns {boolean} + */ +cc.isArray = function(obj) { + return Object.prototype.toString.call(obj) == '[object Array]'; +}; + +/** + * Check the obj whether is undefined or not + * @param {*} obj + * @returns {boolean} + */ +cc.isUndefined = function(obj) { + return typeof obj == 'undefined'; +}; + +/** + * Check the obj whether is object or not + * @param {*} obj + * @returns {boolean} + */ +cc.isObject = function(obj) { + var type = typeof obj; + + return type == 'function' || (obj && type == 'object'); +}; + +/** + * Check the url whether cross origin + * @param {String} url + * @returns {boolean} + */ +cc.isCrossOrigin = function (url) { + return false; +}; + /** * Common getter setter configuration function * @function @@ -885,13 +972,7 @@ cc.plistParser = cc.PlistParser.getInstance(); cc.fileUtils = cc.FileUtils.getInstance(); cc.fileUtils.setPopupNotify(false); -//ccs.nodeReader = ccs.NodeReader.getInstance(); -ccs.actionTimelineCache = ccs.ActionTimelineCache.getInstance(); -ccs.actionTimelineCache.createAction = ccs.ActionTimelineCache.createAction; -ccs.csLoader = ccs.CSLoader.getInstance(); -ccs.csLoader.createNode = ccs.CSLoader.createNode; -ccs.csLoader.createTimeLine = ccs.CSLoader.createTimeLine; /** * @type {Object} @@ -915,65 +996,6 @@ cc.screen = { } }; -cc.EditBox = ccui.EditBox; -delete ccui.EditBox; - -// GUI -/** - * @type {Object} - * UI Helper - */ -ccui.helper = ccui.Helper; - -// In extension -/** - * @type {Object} Base object for ccs.uiReader - * @name ccs.uiReader - */ -ccs.uiReader = null; -cc.defineGetterSetter(ccs, "uiReader", function() { - return ccs.GUIReader.getInstance(); -}); -ccs.GUIReader.prototype.clear = function() { - ccs.GUIReader.destroyInstance(); -}; -/** - * @type {Object} Format and manage armature configuration and armature animation - * @name ccs.armatureDataManager - */ -ccs.armatureDataManager = null; -cc.defineGetterSetter(ccs, "armatureDataManager", function() { - return ccs.ArmatureDataManager.getInstance(); -}); -ccs.ArmatureDataManager.prototype.clear = function() { - ccs.ArmatureDataManager.destroyInstance(); -}; -/** - * @type {Object} Base singleton object for ccs.sceneReader - * @name ccs.sceneReader - */ -ccs.sceneReader = null; -cc.defineGetterSetter(ccs, "sceneReader", function() { - return ccs.SceneReader.getInstance(); -}); -ccs.SceneReader.prototype.clear = function() { - ccs.SceneReader.destroyInstance(); -}; -ccs.SceneReader.prototype.version = function() { - return ccs.SceneReader.sceneReaderVersion(); -}; -/** - * @type {Object} Base singleton object for ccs.ActionManager - * @name ccs.actionManager - */ -ccs.actionManager = ccs.ActionManager.getInstance(); -ccs.ActionManager.prototype.clear = function() { - this.releaseActions(); -}; - -//ccs.spriteFrameCacheHelper = ccs.SpriteFrameCacheHelper.getInstance(); -//ccs.dataReaderHelper = ccs.DataReaderHelper.getInstance(); - //+++++++++++++++++++++++Define singleton objects end+++++++++++++++++++++++++++ @@ -994,33 +1016,6 @@ var jsb = jsb || {}; jsb.fileUtils = cc.fileUtils; delete cc.FileUtils; delete cc.fileUtils; -/** - * @type {Object} - * @name jsb.AssetsManager - * jsb.AssetsManager is the native AssetsManager for your game resources or scripts. - * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en - * Only available in JSB - */ -jsb.AssetsManager = cc.AssetsManager; -delete cc.AssetsManager; -/** - * @type {Object} - * @name jsb.EventListenerAssetsManager - * jsb.EventListenerAssetsManager is the native event listener for AssetsManager. - * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en - * Only available in JSB - */ -jsb.EventListenerAssetsManager = cc.EventListenerAssetsManager; -delete cc.EventListenerAssetsManager; -/** - * @type {Object} - * @name jsb.EventAssetsManager - * jsb.EventAssetsManager is the native event for AssetsManager. - * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en - * Only available in JSB - */ -jsb.EventAssetsManager = cc.EventAssetsManager; -delete cc.EventAssetsManager; /** * @type {Object} @@ -1332,6 +1327,12 @@ cc._initSys = function(config, CONFIG_KEY){ __restartVM(); }; + // clean a singal js file + locSys.cleanScript = function(jsFile) { + __cleanScript(jsFile); + }; + + locSys.dump = function(){ var self = this; var str = ""; @@ -1511,6 +1512,14 @@ cc.game = { config[CONFIG_KEY.frameRate] = frameRate; cc.director.setAnimationInterval(1.0/frameRate); }, + + /** + * Restart game. + */ + restart: function () { + __restartVM(); + }, + /** * Run game. */ @@ -1524,6 +1533,7 @@ cc.game = { self.onStart(); } }, + /** * Init config. * @param cb @@ -1549,8 +1559,9 @@ cc.game = { cc.log("Failed to read or parse project.json"); this.config = _init({}); } -// cc._initDebugSetting(this.config[CONFIG_KEY.debugMode]); + cc._initDebugSetting(this.config[CONFIG_KEY.debugMode]); cc.director.setDisplayStats(this.config[CONFIG_KEY.showFPS]); + cc.director.setAnimationInterval(1.0/this.config[CONFIG_KEY.frameRate]); cc._initSys(this.config, CONFIG_KEY); }, diff --git a/frameworks/js-bindings/bindings/script/jsb_cocos2d.js b/frameworks/js-bindings/bindings/script/jsb_cocos2d.js index 0702bc182c..fb1c7c551a 100644 --- a/frameworks/js-bindings/bindings/script/jsb_cocos2d.js +++ b/frameworks/js-bindings/bindings/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.1"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.2"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; @@ -172,6 +172,12 @@ cc.ONE_MINUS_DST_COLOR = 0x0307; cc.ONE_MINUS_CONSTANT_ALPHA = 0x8004; cc.ONE_MINUS_CONSTANT_COLOR = 0x8002; +//texture parameters +cc.LINEAR = 0x2601; +cc.REPEAT = 0x2901; +cc.CLAMP_TO_EDGE = 0x812f; +cc.MIRRORED_REPEAT = 0x8370; + cc.VERTEX_ATTRIB_FLAG_NONE = 0; cc.VERTEX_ATTRIB_FLAG_POSITION = 1 << 0; cc.VERTEX_ATTRIB_FLAG_COLOR = 1 << 1; @@ -1145,6 +1151,14 @@ cc.rectIntersectsRect = function( rectA, rectB ) return bool; }; +cc.rectOverlapsRect = function (rectA, rectB) +{ + return !((rectA.x + rectA.width < rectB.x) || + (rectB.x + rectB.width < rectA.x) || + (rectA.y + rectA.height < rectB.y) || + (rectB.y + rectB.height < rectA.y)); +}; + cc.rectUnion = function (rectA, rectB) { var rect = cc.rect(0, 0, 0, 0); rect.x = Math.min(rectA.x, rectB.x); @@ -1524,7 +1538,6 @@ cc.MenuItemImage.extend = cc.Class.extend; cc.MenuItemToggle.extend = cc.Class.extend; cc.Scene.extend = cc.Class.extend; cc.ClippingNode.extend = cc.Class.extend; -cc.Scale9Sprite.extend = cc.Class.extend; cc.ProgressTimer.extend = cc.Class.extend; cc.ParallaxNode.extend = cc.Class.extend; cc.DrawNode.extend = cc.Class.extend; @@ -1535,7 +1548,6 @@ cc.TiledGrid3D.extend = cc.Class.extend; cc.MotionStreak.extend = cc.Class.extend; cc.ParticleBatchNode.extend = cc.Class.extend; cc.ParticleSystem.extend = cc.Class.extend; -cc.PhysicsSprite.extend = cc.Class.extend; cc.TextFieldTTF.extend = cc.Class.extend; cc.RenderTexture.extend = cc.Class.extend; cc.TileMapAtlas.extend = cc.Class.extend; @@ -1543,28 +1555,7 @@ cc.TMXLayer.extend = cc.Class.extend; cc.TMXTiledMap.extend = cc.Class.extend; cc.TMXMapInfo.extend = cc.Class.extend; cc.TransitionScene.extend = cc.Class.extend; -ccs.Armature.extend = cc.Class.extend; -ccui.Widget.extend = cc.Class.extend; -ccui.Button.extend = cc.Class.extend; -ccui.CheckBox.extend = cc.Class.extend; -ccui.ImageView.extend = cc.Class.extend; -ccui.LoadingBar.extend = cc.Class.extend; -ccui.RichText.extend = cc.Class.extend; -ccui.Slider.extend = cc.Class.extend; -ccui.Text.extend = cc.Class.extend; -ccui.TextAtlas.extend = cc.Class.extend; -ccui.TextBMFont.extend = cc.Class.extend; -ccui.TextField.extend = cc.Class.extend; -ccui.Layout.extend = cc.Class.extend; -ccui.ListView.extend = cc.Class.extend; -ccui.PageView.extend = cc.Class.extend; -ccui.ScrollView.extend = cc.Class.extend; -cc.ControlButton.extend = cc.Class.extend; -cc.ControlColourPicker.extend = cc.Class.extend; -cc.ControlPotentiometer.extend = cc.Class.extend; -cc.ControlSlider.extend = cc.Class.extend; -cc.ControlStepper.extend = cc.Class.extend; -cc.ControlSwitch.extend = cc.Class.extend; + // Cocos2d-html5 supports multi scene resources preloading. // This is a compatible function for JSB. @@ -2831,4 +2822,28 @@ cc.Texture2D.prototype.setTexParameters = function (texParams, magFilter, wrapS, else minFilter = texParams; this._setTexParameters(minFilter, magFilter, wrapS, wrapT); -}; \ No newline at end of file +}; + + +// +// MenuItemImage support sprite frame name as paramter +// +var _p = cc.MenuItemImage.prototype; +_p._setNormalSpriteFrame = _p.setNormalSpriteFrame; +_p._setSelectedSpriteFrame = _p.setSelectedSpriteFrame; +_p._setDisabledSpriteFrame = _p.setDisabledSpriteFrame; +_p.setNormalSpriteFrame = function(frame) { + if (frame[0] == "#") + frame = cc.spriteFrameCache.getSpriteFrame(frame.substr(1)); + this._setNormalSpriteFrame(frame); +} +_p.setSelectedSpriteFrame = function(frame) { + if (frame[0] == "#") + frame = cc.spriteFrameCache.getSpriteFrame(frame.substr(1)); + this._setSelectedSpriteFrame(frame); +} +_p.setDisabledSpriteFrame = function(frame) { + if (frame[0] == "#") + frame = cc.spriteFrameCache.getSpriteFrame(frame.substr(1)); + this._setDisabledSpriteFrame(frame); +} diff --git a/frameworks/js-bindings/bindings/script/jsb_create_apis.js b/frameworks/js-bindings/bindings/script/jsb_create_apis.js index 7fb54bd522..a70fc904ee 100644 --- a/frameworks/js-bindings/bindings/script/jsb_create_apis.js +++ b/frameworks/js-bindings/bindings/script/jsb_create_apis.js @@ -316,34 +316,6 @@ cc.ParticleFire.prototype._ctor = cc.ParticleFireworks.prototype._ctor this.init(); }; -/************************ PhysicsSprite *************************/ -_p = cc.PhysicsSprite.prototype; -_p._ctor = function(fileName, rect){ - if (fileName === undefined) { - cc.PhysicsSprite.prototype.init.call(this); - }else if (typeof(fileName) === "string") { - if (fileName[0] === "#") { - //init with a sprite frame name - var frameName = fileName.substr(1, fileName.length - 1); - var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); - this.initWithSpriteFrame(spriteFrame); - } else { - //init with filename and rect - if(rect) - this.initWithFile(fileName, rect); - else - this.initWithFile(fileName); - } - }else if (typeof(fileName) === "object") { - if (fileName instanceof cc.Texture2D) { - //init with texture and rect - this.initWithTexture(fileName, rect); - } else if (fileName instanceof cc.SpriteFrame) { - //init with a sprite frame - this.initWithSpriteFrame(fileName); - } - } -}; /************************ ProgressTimer *************************/ _p = cc.ProgressTimer.prototype; @@ -904,47 +876,6 @@ cc.Sprite.create = function (fileName, rect) { return null; }; -cc.PhysicsSprite._create = cc.PhysicsSprite.create; -cc.PhysicsSprite.create = function (fileName, rect) { - var sprite; - - if (arguments.length == 0) { - sprite = cc.PhysicsSprite._create(); - return sprite; - } - - if (typeof(fileName) === "string") { - if (fileName[0] === "#") { - //init with a sprite frame name - var frameName = fileName.substr(1, fileName.length - 1); - var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); - sprite = cc.PhysicsSprite.createWithSpriteFrame(spriteFrame); - } else { - // Create with filename and rect - sprite = rect ? cc.PhysicsSprite._create(fileName, rect) : cc.PhysicsSprite._create(fileName); - } - if (sprite) - return sprite; - else return null; - } - - if (typeof(fileName) === "object") { - if (fileName instanceof cc.Texture2D) { - //init with texture and rect - sprite = rect ? cc.PhysicsSprite.createWithTexture(fileName, rect) : cc.PhysicsSprite.createWithTexture(fileName); - } else if (fileName instanceof cc.SpriteFrame) { - //init with a sprite frame - sprite = cc.PhysicsSprite.createWithSpriteFrame(fileName) - } - if (sprite) - return sprite; - else return null; - } - - return null; -}; - - cc.LabelTTF._create = cc.LabelTTF.create; /** * creates a cc.LabelTTF from a font name, alignment, dimension and font size diff --git a/frameworks/js-bindings/bindings/script/jsb_deprecated.js b/frameworks/js-bindings/bindings/script/jsb_deprecated.js index f1314731ac..193ebe3aeb 100644 --- a/frameworks/js-bindings/bindings/script/jsb_deprecated.js +++ b/frameworks/js-bindings/bindings/script/jsb_deprecated.js @@ -110,16 +110,6 @@ var cc = cc || {}; return cc.registerTargetedDelegate.apply(this, arguments); }; - ccui.Text.prototype.setText = function(text){ - logW("ccui.Text.setText", "ccui.Text.setString"); - this.setString(text); - }; - - ccui.Text.prototype.getStringValue = function(){ - logW("ccui.Text.getStringValue", "ccui.Text.getString"); - return this.getString(); - }; - cc.Touch.prototype.getId = function(){ logW("cc.Touch.getId", "cc.Touch.getID"); return this.getID(); diff --git a/frameworks/js-bindings/bindings/script/jsb_ext_create_apis.js b/frameworks/js-bindings/bindings/script/jsb_ext_create_apis.js deleted file mode 100644 index 30d1106d43..0000000000 --- a/frameworks/js-bindings/bindings/script/jsb_ext_create_apis.js +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2014 Chukong Technologies Inc. - * - * 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. - */ - -/************************************************************ - * - * Constructors with built in init function - * - ************************************************************/ -ccui.Widget.prototype.init = ccui.Widget.prototype._init; -ccui.Button.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); - this.setTouchEnabled(true); -}; -ccui.CheckBox.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); - this.setSelected(false); - this.setTouchEnabled(true); -}; -ccui.LoadingBar.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); -}; -ccui.RichText.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); -}; -ccui.Slider.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); - this.setTouchEnabled(true); -}; -ccui.Text.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); -}; -ccui.TextAtlas.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); -}; -ccui.TextBMFont.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); -}; -ccui.TextField.prototype.init = function(){ - ccui.Widget.prototype.init.call(this); - this.setTouchEnabled(true); -}; - -var _p = {}; -_p._ctor = function(){ - this.init(); -}; -ccui.Widget.prototype._ctor = ccui.Button.prototype._ctor - = ccui.CheckBox.prototype._ctor - = ccui.ImageView.prototype._ctor - = ccui.LoadingBar.prototype._ctor - = ccui.RichText.prototype._ctor - = ccui.Slider.prototype._ctor - = ccui.Text.prototype._ctor - = ccui.TextAtlas.prototype._ctor - = ccui.TextBMFont.prototype._ctor - = ccui.TextField.prototype._ctor - = ccui.Layout.prototype._ctor - = ccui.ListView.prototype._ctor - = ccui.PageView.prototype._ctor - = ccui.ScrollView.prototype._ctor - = _p._ctor; - -ccui.RichElementText.prototype._ctor = function(tag, color, opacity, text, fontName, fontSize){ - fontSize !== undefined && this.init(tag, color, opacity, text, fontName, fontSize); -}; - -ccui.RichElementImage.prototype._ctor = function(tag, color, opacity, filePath){ - filePath !== undefined && this.init(tag, color, opacity, filePath); -}; - -ccui.RichElementCustomNode.prototype._ctor = function(tag, color, opacity, customNode){ - customNode !== undefined && this.init(tag, color, opacity, customNode); -}; - -jsb.EventListenerAssetsManager.prototype._ctor = function(assetsManager, callback) { - callback !== undefined && this.init(assetsManager, callback); -}; - -cc.Scale9Sprite.prototype._ctor = function(file, rect, capInsets){ - rect = rect || cc.rect(0, 0, 0, 0); - capInsets = capInsets || cc.rect(0, 0, 0, 0); - if(file != undefined){ - if(file instanceof cc.SpriteFrame) - this.initWithSpriteFrame(file, rect); - else{ - var frame = cc.spriteFrameCache.getSpriteFrame(file); - if(frame != null) - this.initWithSpriteFrame(frame, rect); - else - this.initWithFile(file, rect, capInsets); - } - }else{ - this.init(); - } -}; - -cc.ControlButton.prototype._ctor = function(label, backgroundSprite, fontSize){ - if(fontSize != undefined) - this.initWithTitleAndFontNameAndFontSize(label, backgroundSprite, fontSize); - else if(backgroundSprite != undefined) - this.initWithLabelAndBackgroundSprite(label, backgroundSprite); - else if(label != undefined) - this.initWithBackgroundSprite(label); - else - this.init(); -}; - -cc.ControlColourPicker.prototype._ctor = function(){ - this.init(); -}; - -cc.ControlPotentiometer.prototype._ctor = function(backgroundFile, progressFile, thumbFile){ - if (thumbFile != undefined) { - // Prepare track for potentiometer - var backgroundSprite = cc.Sprite.create(backgroundFile); - - // Prepare thumb for potentiometer - var thumbSprite = cc.Sprite.create(thumbFile); - - // Prepare progress for potentiometer - var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); - this.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite); - } -}; - -cc.ControlSlider.prototype._ctor = function(bgFile, progressFile, thumbFile){ - if (thumbFile != undefined) { - // Prepare background for slider - bgSprite = cc.Sprite.create(bgFile); - - // Prepare progress for slider - progressSprite = cc.Sprite.create(progressFile); - - // Prepare thumb (menuItem) for slider - thumbSprite = cc.Sprite.create(thumbFile); - - this.initWithSprites(bgSprite, progressSprite, thumbSprite); - } -}; - -cc.ControlStepper.prototype._ctor = function(minusSprite, plusSprite){ - plusSprite !== undefined && this.initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite); -}; - -cc.ControlSwitch.prototype._ctor = function(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel){ - offLabel !== undefined && this.initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); -}; - -cc.TableView.prototype._ctor = function(dataSouurce, size, container){ - container == undefined ? this._init(dataSouurce, size) : this._init(dataSouurce, size, container); -}; - -cc.EditBox.prototype._ctor = function(size, normal9SpriteBg, press9SpriteBg, disabled9SpriteBg){ - normal9SpriteBg && this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg); -}; - -cc.ScrollView.prototype._ctor = function(size, container) { - size == undefined ? this.init() : (container ? this.initWithViewSize(size, container) : this.initWithViewSize(size)); -}; - - -/************************ Cocostudio *************************/ - -ccs.Armature.prototype._ctor = function(name, parentBone) { - parentBone !== undefined && ccs.Armature.prototype.init.call(this, name, parentBone); -}; - -ccs.Bone.prototype._ctor = function(name) { - name !== undefined && ccs.Bone.prototype.init.call(this, name); -}; - -ccs.ArmatureAnimation.prototype._ctor = function(armature) { - armature !== undefined && ccs.ArmatureAnimation.prototype.init.call(this, armature); -}; - -ccs.Tween.prototype._ctor = function(bone) { - bone !== undefined && ccs.Tween.prototype.init.call(this, bone); -}; - -ccs.BatchNode.prototype._ctor = function() { - ccs.BatchNode.prototype.init.call(this); -}; - -ccs.DecorativeDisplay.prototype._ctor = function() { - ccs.DecorativeDisplay.prototype.init.call(this); -}; - -ccs.DisplayManager.prototype._ctor = function(bone) { - bone !== undefined && ccs.DisplayManager.prototype.init.call(this, bone); -}; - -ccs.Skin.prototype._ctor = function(fileName, rect) { - if (fileName == null || fileName == "") { - ccs.Skin.prototype.init.call(this); - } else { - if(fileName[0] == "#"){ - ccs.Skin.prototype.initWithSpriteFrameName.call(this, fileName.substr(1)); - } else { - rect ? ccs.Skin.prototype.initWithFile.call(this, fileName) - : ccs.Skin.prototype.initWithFile.call(this, fileName, rect); - } - } -}; - -ccs.ColliderDetector.prototype._ctor = function(bone) { - bone !== undefined && ccs.ColliderDetector.prototype.init.call(this, bone); -}; - -ccs.TriggerObj.prototype._ctor = function() { - ccs.TriggerObj.prototype.init.call(this); -}; - -ccs.ComAttribute.prototype._ctor = function() { - ccs.ComAttribute.prototype.init.call(this); -}; - -ccs.ComAudio.prototype._ctor = function() { - ccs.ComAudio.prototype.init.call(this); -}; - -ccs.ComController.prototype._ctor = function() { - ccs.ComController.prototype.init.call(this); -}; - -ccs.ComRender.prototype._ctor = function() { - ccs.ComRender.prototype.init.call(this); -}; \ No newline at end of file diff --git a/frameworks/js-bindings/bindings/script/jsb_property_apis.js b/frameworks/js-bindings/bindings/script/jsb_property_apis.js index 9e3e679ddb..c50f4b9f87 100644 --- a/frameworks/js-bindings/bindings/script/jsb_property_apis.js +++ b/frameworks/js-bindings/bindings/script/jsb_property_apis.js @@ -107,13 +107,6 @@ cc.defineGetterSetter(_proto, "scale", _proto.getScale, _proto.setScale); cc.defineGetterSetter(_proto, "scaleX", _proto.getScaleX, _proto.setScaleX); cc.defineGetterSetter(_proto, "scaleY", _proto.getScaleY, _proto.setScaleY); -_proto = cc.PhysicsSprite.prototype; -cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); -cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX); -cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY); -cc.defineGetterSetter(_proto, "rotation", _proto.getRotation, _proto.setRotation); -cc.defineGetterSetter(_proto, "dirty", _proto.isDirty, _proto.setDirty); - _proto = cc.ProgressTimer.prototype; cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); @@ -122,123 +115,6 @@ cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); _proto = cc.TextFieldTTF.prototype; cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); -_proto = ccs.Bone.prototype; -cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); -cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); -cc.defineGetterSetter(_proto, "zIndex", _proto.getLocalZOrder, _proto.setLocalZOrder); - -_proto = ccui.Widget.prototype; -cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX); -cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY); -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); -cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); -cc.defineGetterSetter(_proto, "children", _proto.getChildren); -cc.defineGetterSetter(_proto, "childrenCount", _proto.getChildrenCount); - -_proto = ccui.ScrollView.prototype; -cc.defineGetterSetter(_proto, "children", _proto.getChildren); -cc.defineGetterSetter(_proto, "childrenCount", _proto.getChildrenCount); -cc.defineGetterSetter(_proto, "layoutType", _proto.getLayoutType, _proto.setLayoutType); - -_proto = ccui.Button.prototype; -cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); -cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); -cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); -cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); -cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); - -_proto = ccui.CheckBox.prototype; -cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); -cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); -cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); -cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); - -_proto = ccui.ImageView.prototype; -cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); -cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); -cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); -cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); - -_proto = ccui.Text.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); -cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); -cc.defineGetterSetter(_proto, "scaleX", _proto.getScaleX, _proto.setScaleX); -cc.defineGetterSetter(_proto, "scaleY", _proto.getScaleY, _proto.setScaleY); -cc.defineGetterSetter(_proto, "flippedX", _proto.isFlippedX, _proto.setFlippedX); -cc.defineGetterSetter(_proto, "flippedY", _proto.isFlippedY, _proto.setFlippedY); - -_proto = ccui.TextAtlas.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); -cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); - -_proto = ccui.TextBMFont.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); -cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); - -_proto = ccui.LoadingBar.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); - -_proto = ccui.Slider.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); - -_proto = ccui.TextField.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX); -cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY); - -_proto = cc.Control.prototype; -cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); - -_proto = cc.ControlButton.prototype; -cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); -cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); - -_proto = cc.ControlColourPicker.prototype; -cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); - -_proto = cc.ControlHuePicker.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); - -_proto = cc.ControlPotentiometer.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); - -_proto = cc.ControlSaturationBrightnessPicker.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); - -_proto = cc.ControlSlider.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); - -_proto = cc.ControlSwitch.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); - -_proto = cc.Scale9Sprite.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); -cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); -cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); - -_proto = cc.ScrollView.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); - - // Extends @@ -280,7 +156,6 @@ cc.defineGetterSetter(_proto, "scheduler", _proto.getScheduler, _proto.setSchedu cc.defineGetterSetter(_proto, "shaderProgram", _proto.getShaderProgram, _proto.setShaderProgram); cc.defineGetterSetter(_proto, "glServerState", _proto.getGLServerState, _proto.setGLServerState); cc.defineGetterSetter(_proto, "tag", _proto.getTag, _proto.setTag); -cc.defineGetterSetter(_proto, "userData", _proto.getUserData, _proto.setUserData); cc.defineGetterSetter(_proto, "userObject", _proto.getUserObject, _proto.setUserObject); cc.defineGetterSetter(_proto, "arrivalOrder", _proto.getArrivalOrder, _proto.setArrivalOrder); @@ -497,194 +372,3 @@ cc.defineGetterSetter(_proto, "mapWidth", _proto._getMapWidth, _proto._setMapWid cc.defineGetterSetter(_proto, "mapHeight", _proto._getMapHeight, _proto._setMapHeight); cc.defineGetterSetter(_proto, "tileWidth", _proto._getTileWidth, _proto._setTileWidth); cc.defineGetterSetter(_proto, "tileHeight", _proto._getTileHeight, _proto._setTileHeight); - -_proto = ccs.Armature.prototype; -cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone); -cc.defineGetterSetter(_proto, "animation", _proto.getAnimation, _proto.setAnimation); -cc.defineGetterSetter(_proto, "armatureData", _proto.getArmatureData, _proto.setArmatureData); -cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); -cc.defineGetterSetter(_proto, "batchNode", _proto.getBatchNode, _proto.setBatchNode); -cc.defineGetterSetter(_proto, "version", _proto.getVersion, _proto.setVersion); -cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); -cc.defineGetterSetter(_proto, "colliderFilter", _proto.setColliderFilter); - -_proto = ccs.Bone.prototype; -cc.defineGetterSetter(_proto, "boneData", _proto.getBoneData, _proto.setBoneData); -cc.defineGetterSetter(_proto, "armature", _proto.getArmature, _proto.setArmature); -cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone); -cc.defineGetterSetter(_proto, "childArmature", _proto.getChildArmature, _proto.setChildArmature); -cc.defineGetterSetter(_proto, "childrenBone", _proto.getChildrenBone); -cc.defineGetterSetter(_proto, "tween", _proto.getTween); -cc.defineGetterSetter(_proto, "tweenData", _proto.getTweenData); -cc.defineGetterSetter(_proto, "transformDirty", _proto.getTransformDirty, _proto.setTransformDirty); -cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter); -cc.defineGetterSetter(_proto, "displayManager", _proto.getDisplayManager, _proto.setDisplayManager); -cc.defineGetterSetter(_proto, "ignoreMovementBoneData", _proto.getIgnoreMovementBoneData, _proto.setIgnoreMovementBoneData); -cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); -cc.defineGetterSetter(_proto, "blendDirty", _proto.getBlendDirty, _proto.setBlendDirty); - -_proto = ccs.Skin.prototype; -cc.defineGetterSetter(_proto, "skinData", _proto.getSkinData, _proto.setSkinData); -cc.defineGetterSetter(_proto, "bone", _proto.getBone, _proto.setBone); -cc.defineGetterSetter(_proto, "displayName", _proto.getDisplayName); - -_proto = ccs.ColliderDetector.prototype; -cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter); -cc.defineGetterSetter(_proto, "active", _proto.getActive, _proto.setActive); -cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); - -_proto = ccui.Widget.prototype; -cc.defineGetterSetter(_proto, "xPercent", _proto._getXPercent, _proto._setXPercent); -cc.defineGetterSetter(_proto, "yPercent", _proto._getYPercent, _proto._setYPercent); -cc.defineGetterSetter(_proto, "widthPercent", _proto._getWidthPercent, _proto._setWidthPercent); -cc.defineGetterSetter(_proto, "heightPercent", _proto._getHeightPercent, _proto._setHeightPercent); -cc.defineGetterSetter(_proto, "widgetParent", _proto.getWidgetParent); -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "focused", _proto.isFocused, _proto.setFocused); -cc.defineGetterSetter(_proto, "sizeType", _proto.getSizeType, _proto.setSizeType); -cc.defineGetterSetter(_proto, "widgetType", _proto.getWidgetType); -cc.defineGetterSetter(_proto, "touchEnabled", _proto.isTouchEnabled, _proto.setTouchEnabled); -cc.defineGetterSetter(_proto, "updateEnabled", _proto.isUpdateEnabled, _proto.setUpdateEnabled); -cc.defineGetterSetter(_proto, "bright", _proto.isBright, _proto.setBright); -cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); -cc.defineGetterSetter(_proto, "actionTag", _proto.getActionTag, _proto.setActionTag); - -_proto = ccui.Layout.prototype; -cc.defineGetterSetter(_proto, "clippingEnabled", _proto.isClippingEnabled, _proto.setClippingEnabled); -cc.defineGetterSetter(_proto, "clippingType", _proto.setClippingType); -cc.defineGetterSetter(_proto, "layoutType", _proto.getLayoutType, _proto.setLayoutType); - -_proto = ccui.Button.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "titleText", _proto.getTitleText, _proto.setTitleText); -cc.defineGetterSetter(_proto, "titleFont", _proto._getTitleFont, _proto._setTitleFont); -cc.defineGetterSetter(_proto, "titleFontSize", _proto.getTitleFontSize, _proto.setTitleFontSize); -cc.defineGetterSetter(_proto, "titleFontName", _proto.getTitleFontName, _proto.setTitleFontName); -cc.defineGetterSetter(_proto, "titleFontColor", _proto.getTitleFontColor, _proto.setTitleFontColor); -cc.defineGetterSetter(_proto, "pressedActionEnabled", _proto.getPressedActionEnabled, _proto.setPressedActionEnabled); - -_proto = ccui.CheckBox.prototype; -cc.defineGetterSetter(_proto, "selected", _proto.getSelected, _proto.setSelected); - -_proto = ccui.Text.prototype; -cc.defineGetterSetter(_proto, "boundingWidth", _proto._getBoundingWidth, _proto._setBoundingWidth); -cc.defineGetterSetter(_proto, "boundingHeight", _proto._getBoundingHeight, _proto._setBoundingHeight); -cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); -cc.defineGetterSetter(_proto, "stringLength", _proto.getStringLength); -cc.defineGetterSetter(_proto, "font", _proto._getFont, _proto._setFont); -cc.defineGetterSetter(_proto, "fontName", _proto.getFontName, _proto.setFontName); -cc.defineGetterSetter(_proto, "fontSize", _proto.getFontSize, _proto.setFontSize); -cc.defineGetterSetter(_proto, "textAlign", _proto.getHorizontalAlignment, _proto.setTextHorizontalAlignment); -cc.defineGetterSetter(_proto, "verticalAlign", _proto.getVerticalAlignment, _proto.setTextVerticalAlignment); -cc.defineGetterSetter(_proto, "touchScaleEnabled", _proto.getTouchScaleEnabled, _proto.setTouchScaleEnabled); - -_proto = ccui.TextAtlas.prototype; -cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); - -_proto = ccui.TextBMFont.prototype; -cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); - -_proto = ccui.LoadingBar.prototype; -cc.defineGetterSetter(_proto, "direction", _proto.getDirection, _proto.setDirection); -cc.defineGetterSetter(_proto, "percent", _proto.getPercent, _proto.setPercent); - -_proto = ccui.Slider.prototype; -cc.defineGetterSetter(_proto, "percent", _proto.getPercent, _proto.setPercent); - -_proto = ccui.TextField.prototype; -cc.defineGetterSetter(_proto, "maxLengthEnabled", _proto.isMaxLengthEnabled, _proto.setMaxLengthEnabled); -cc.defineGetterSetter(_proto, "maxLength", _proto.getMaxLength, _proto.setMaxLength); -cc.defineGetterSetter(_proto, "passwordEnabled", _proto.isPasswordEnabled, _proto.setPasswordEnabled); -cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); -cc.defineGetterSetter(_proto, "font", _proto._getFont, _proto._setFont); -cc.defineGetterSetter(_proto, "fontSize", _proto.getFontSize, _proto.setFontSize); -cc.defineGetterSetter(_proto, "fontName", _proto.getFontName, _proto.setFontName); - -_proto = ccui.ScrollView.prototype; -cc.defineGetterSetter(_proto, "innerWidth", _proto._getInnerWidth, _proto._setInnerWidth); -cc.defineGetterSetter(_proto, "innerHeight", _proto._getInnerHeight, _proto._setInnerHeight); -cc.defineGetterSetter(_proto, "bounceEnabled", _proto.getBounceEnabled, _proto.setBounceEnabled); -cc.defineGetterSetter(_proto, "inertiaScrollEnabled", _proto.getInertiaScrollEnabled, _proto.setInertiaScrollEnabled); - -_proto = cc.EditBox.prototype; -cc.defineGetterSetter(_proto, "font", null, _proto._setFont); -cc.defineGetterSetter(_proto, "fontName", null, _proto.setFontName); -cc.defineGetterSetter(_proto, "fontSize", null, _proto.setFontSize); -cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString); -cc.defineGetterSetter(_proto, "maxLength", _proto.getMaxLength, _proto.setMaxLength); - -_proto = cc.Control.prototype; -cc.defineGetterSetter(_proto, "state", _proto.getState); -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "selected", _proto.isSelected, _proto.setSelected); -cc.defineGetterSetter(_proto, "highlighted", _proto.isHighlighted, _proto.setHighlighted); - -_proto = cc.ControlButton.prototype; -cc.defineGetterSetter(_proto, "adjustBackgroundImage", _proto.getAdjustBackgroundImage, _proto.setAdjustBackgroundImage); -cc.defineGetterSetter(_proto, "zoomOnTouchDown", _proto.getZoomOnTouchDown, _proto.setZoomOnTouchDown); -cc.defineGetterSetter(_proto, "preferredSize", _proto.getPreferredSize, _proto.setPreferredSize); -cc.defineGetterSetter(_proto, "labelAnchor", _proto.getLabelAnchorPoint, _proto.setLabelAnchorPoint); - -_proto = cc.ControlColourPicker.prototype; -cc.defineGetterSetter(_proto, "background", _proto.getBackground); - -_proto = cc.ControlHuePicker.prototype; -cc.defineGetterSetter(_proto, "hue", _proto.getHue, _proto.setHue); -cc.defineGetterSetter(_proto, "huePercent", _proto.getHuePercentage, _proto.setHuePercentage); -cc.defineGetterSetter(_proto, "background", _proto.getBackground); -cc.defineGetterSetter(_proto, "slider", _proto.getSlider); -cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); - -_proto = cc.ControlPotentiometer.prototype; -cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); -cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); -cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); -cc.defineGetterSetter(_proto, "progressTimer", _proto.getProgressTimer, _proto.setProgressTimer); -cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite, _proto.setThumbSprite); -cc.defineGetterSetter(_proto, "prevLocation", _proto.getPreviousLocation, _proto.setPreviousLocation); - -_proto = cc.ControlSaturationBrightnessPicker.prototype; -cc.defineGetterSetter(_proto, "saturation", _proto.getSaturation); -cc.defineGetterSetter(_proto, "brightness", _proto.getBrightness); -cc.defineGetterSetter(_proto, "background", _proto.getBackground); -cc.defineGetterSetter(_proto, "overlay", _proto.getOverlay); -cc.defineGetterSetter(_proto, "shadow", _proto.getShadow); -cc.defineGetterSetter(_proto, "slider", _proto.getSlider); -cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); - -_proto = cc.ControlSlider.prototype; -cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); -cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); -cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); -cc.defineGetterSetter(_proto, "minAllowedValue", _proto.getMinimumAllowedValue, _proto.setMinimumAllowedValue); -cc.defineGetterSetter(_proto, "maxAllowedValue", _proto.getMaximumAllowedValue, _proto.setMaximumAllowedValue); -cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite); -cc.defineGetterSetter(_proto, "progressSprite", _proto.getProgressSprite); -cc.defineGetterSetter(_proto, "backgroundSprite", _proto.getBackgroundSprite); - -_proto = cc.ControlStepper.prototype; -cc.defineGetterSetter(_proto, "wraps", _proto.getWraps, _proto.setWraps); -cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); -cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); -cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); -cc.defineGetterSetter(_proto, "stepValue", _proto.getStepValue, _proto.setStepValue); -cc.defineGetterSetter(_proto, "continuous", _proto.isContinuous); -cc.defineGetterSetter(_proto, "minusSprite", _proto.getMinusSprite, _proto.setMinusSprite); -cc.defineGetterSetter(_proto, "plusSprite", _proto.getPlusSprite, _proto.setPlusSprite); -cc.defineGetterSetter(_proto, "minusLabel", _proto.getMinusLabel, _proto.setMinusLabel); -cc.defineGetterSetter(_proto, "plusSLabel", _proto.getPlusSLabel, _proto.setPlusSLabel); - -_proto = cc.Scale9Sprite.prototype; -cc.defineGetterSetter(_proto, "preferredSize", _proto.getPreferredSize, _proto.setPreferredSize); -cc.defineGetterSetter(_proto, "capInsets", _proto.getCapInsets, _proto.setCapInsets); -cc.defineGetterSetter(_proto, "insetLeft", _proto.getInsetLeft, _proto.setInsetLeft); -cc.defineGetterSetter(_proto, "insetTop", _proto.getInsetTop, _proto.setInsetTop); -cc.defineGetterSetter(_proto, "insetRight", _proto.getInsetRight, _proto.setInsetRight); -cc.defineGetterSetter(_proto, "insetBottom", _proto.getInsetBottom, _proto.setInsetBottom); - -_proto = cc.ScrollView.prototype; -cc.defineGetterSetter(_proto, "direction", _proto.getDirection, _proto.setDirection); - -_proto = cc.TableViewCell.prototype; -cc.defineGetterSetter(_proto, "objectId", _proto.getObjectID, _proto.setObjectID); diff --git a/frameworks/js-bindings/bindings/script/jsb_property_impls.js b/frameworks/js-bindings/bindings/script/jsb_property_impls.js index 0a75eda9db..56b5dcfb6d 100644 --- a/frameworks/js-bindings/bindings/script/jsb_property_impls.js +++ b/frameworks/js-bindings/bindings/script/jsb_property_impls.js @@ -134,15 +134,6 @@ _safeExtend(cc.Sprite.prototype, { } }); -_safeExtend(cc.PhysicsSprite.prototype, { - setPositionX: function(x) { - this.setPosition( cc.p(x, this.getPositionY()) ); - }, - setPositionY: function(y) { - this.setPosition( cc.p(this.getPositionX(), y) ); - } -}); - _safeExtend(cc.LabelBMFont.prototype, { _getAlignment: _undefined._jsbUndefined, _getBoundingWidth: _undefined._jsbUndefined, @@ -219,136 +210,7 @@ _safeExtend(cc.TMXTiledMap.prototype, { } }); -// Override width and height getter setter -_forceExtend(ccui.Widget.prototype, { - _getXPercent: function() { - return this.getPositionPercent().x; - }, - _getYPercent: function() { - return this.getPositionPercent().y; - }, - - _setXPercent: function(x) { - var p = cc.p(x, this.getPositionPercent().y); - this.setPositionPercent(p); - }, - _setYPercent: function(y) { - var p = cc.p(this.getPositionPercent().x, y); - this.setPositionPercent(p); - }, - - _getWidth: function() { - return this.getContentSize().width; - }, - _getHeight: function() { - return this.getContentSize().height; - }, - _getWidthPercent: function() { - return this.getSizePercent().width; - }, - _getHeightPercent: function() { - return this.getSizePercent().height; - }, - - _setWidth: function(w) { - var size = cc.size(w, this.getContentSize().height); - this.setContentSize(size); - }, - _setHeight: function(h) { - var size = cc.size(this.getContentSize().width, h); - this.setContentSize(size); - }, - _setWidthPercent: function(w) { - var size = cc.size(w, this.getSizePercent().height); - this.setSizePercent(size); - }, - _setHeightPercent: function(h) { - var size = cc.size(this.getSizePercent().width, h); - this.setSizePercent(size); - } -}); - -_safeExtend(ccui.Button.prototype, { - _fontStyleRE: /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/, - - _getTitleFont: function() { - var size = this.getTitleFontSize(); - var name = this.getTitleFontName(); - return size + "px '" + name + "'"; - }, - - _setTitleFont: function(fontStyle) { - var res = this._fontStyleRE.exec(fontStyle); - if(res) { - this.setTitleFontSize(parseInt(res[1])); - this.setTitleFontName(res[2]); - } - } -}); - -_safeExtend(ccui.Text.prototype, { - _getBoundingWidth: function() { - return this.getTextAreaSize().width; - }, - _getBoundingHeight: function() { - return this.getTextAreaSize().height; - }, - - _setBoundingWidth: function(w) { - var size = cc.size(w, this.getTextAreaSize().height); - this.setTextAreaSize(size); - }, - _setBoundingHeight: function(h) { - var size = cc.size(this.getTextAreaSize().width, h); - this.setTextAreaSize(size); - } -}); - -_safeExtend(ccui.TextField.prototype, { - _fontStyleRE: /^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/, - - _getFont: function() { - var size = this.getFontSize(); - var name = this.getFontName(); - return size + "px '" + name + "'"; - }, - - _setFont: function(fontStyle) { - var res = this._fontStyleRE.exec(fontStyle); - if(res) { - this.setFontSize(parseInt(res[1])); - this.setFontName(res[2]); - } - } -}); - -_safeExtend(ccui.ScrollView.prototype, { - _getInnerWidth: function() { - return this.getInnerContentSize().width; - }, - _getInnerHeight: function() { - return this.getInnerContentSize().height; - }, - - _setInnerWidth: function(w) { - var size = cc.size(w, this.getInnerContentSize().height); - this.setInnerContentSize(size); - }, - _setInnerHeight: function(h) { - var size = cc.size(this.getInnerContentSize().width, h); - this.setInnerContentSize(size); - } -}); -// _safeExtend(ccui.EditBox.prototype, { -// _setFont: function(fontStyle) { -// var res = cc.LabelTTF.prototype._fontStyleRE.exec(fontStyle); -// if(res) { -// this.setFontSize(parseInt(res[1])); -// this.setFontName(res[2]); -// } -// } -// }); _safeExtend(cc.Texture2D.prototype, { _getWidth : function(){ diff --git a/frameworks/js-bindings/bindings/script/physicsSprite/jsb_physicsSprite.js b/frameworks/js-bindings/bindings/script/physicsSprite/jsb_physicsSprite.js new file mode 100644 index 0000000000..7e77808d4e --- /dev/null +++ b/frameworks/js-bindings/bindings/script/physicsSprite/jsb_physicsSprite.js @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * + * 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. + */ + +// move from extension +// start +//PhysicsDebugNode +cc.PhysicsDebugNode.create = function( space ) { + var s = space; + if( space.handle !== undefined ) + s = space.handle; + return cc.PhysicsDebugNode._create( s ); +}; + +cc.PhysicsDebugNode.prototype._ctor = function(space){ + this.init(); + var s = space; + if( space.handle !== undefined ) + s = space.handle; + this.setSpace(s); +}; + +cc.PhysicsDebugNode.prototype.setSpace = function( space ) { + var s = space; + if( space.handle !== undefined ) + s = space.handle; + return this._setSpace( s ); +}; + +// physicsSprite +cc.PhysicsSprite.prototype.setBody = function( body ) { + var b = body; + if( body.handle !== undefined ) + b = body.handle; + return this._setCPBody( b ); +}; + +cc.PhysicsSprite.prototype.getBody = function() { + return this.getCPBody(); +}; +// end + +// move from property_impls +// start +_safeExtend(cc.PhysicsSprite.prototype, { + setPositionX: function(x) { + this.setPosition( cc.p(x, this.getPositionY()) ); + }, + setPositionY: function(y) { + this.setPosition( cc.p(this.getPositionX(), y) ); + } +}); +// end + +// move from property_apis +// start +var _proto = cc.PhysicsSprite.prototype; +cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); +cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX); +cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY); +cc.defineGetterSetter(_proto, "rotation", _proto.getRotation, _proto.setRotation); +cc.defineGetterSetter(_proto, "dirty", _proto.isDirty, _proto.setDirty); +// end + +// move from create_apis +// start +/************************ PhysicsSprite *************************/ +var _p = cc.PhysicsSprite.prototype; +_p._ctor = function(fileName, rect){ + if (fileName === undefined) { + cc.PhysicsSprite.prototype.init.call(this); + }else if (typeof(fileName) === "string") { + if (fileName[0] === "#") { + //init with a sprite frame name + var frameName = fileName.substr(1, fileName.length - 1); + var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); + this.initWithSpriteFrame(spriteFrame); + } else { + //init with filename and rect + if(rect) + this.initWithFile(fileName, rect); + else + this.initWithFile(fileName); + } + }else if (typeof(fileName) === "object") { + if (fileName instanceof cc.Texture2D) { + //init with texture and rect + this.initWithTexture(fileName, rect); + } else if (fileName instanceof cc.SpriteFrame) { + //init with a sprite frame + this.initWithSpriteFrame(fileName); + } + } +}; + +cc.PhysicsSprite._create = cc.PhysicsSprite.create; +cc.PhysicsSprite.create = function (fileName, rect) { + var sprite; + + if (arguments.length == 0) { + sprite = cc.PhysicsSprite._create(); + return sprite; + } + + if (typeof(fileName) === "string") { + if (fileName[0] === "#") { + //init with a sprite frame name + var frameName = fileName.substr(1, fileName.length - 1); + var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName); + sprite = cc.PhysicsSprite.createWithSpriteFrame(spriteFrame); + } else { + // Create with filename and rect + sprite = rect ? cc.PhysicsSprite._create(fileName, rect) : cc.PhysicsSprite._create(fileName); + } + if (sprite) + return sprite; + else return null; + } + + if (typeof(fileName) === "object") { + if (fileName instanceof cc.Texture2D) { + //init with texture and rect + sprite = rect ? cc.PhysicsSprite.createWithTexture(fileName, rect) : cc.PhysicsSprite.createWithTexture(fileName); + } else if (fileName instanceof cc.SpriteFrame) { + //init with a sprite frame + sprite = cc.PhysicsSprite.createWithSpriteFrame(fileName) + } + if (sprite) + return sprite; + else return null; + } + + return null; +}; +// end + diff --git a/frameworks/js-bindings/bindings/script/jsb_cocos2d_studio.js b/frameworks/js-bindings/bindings/script/studio/jsb_cocos2d_studio.js similarity index 100% rename from frameworks/js-bindings/bindings/script/jsb_cocos2d_studio.js rename to frameworks/js-bindings/bindings/script/studio/jsb_cocos2d_studio.js diff --git a/frameworks/js-bindings/bindings/script/studio/jsb_studio_boot.js b/frameworks/js-bindings/bindings/script/studio/jsb_studio_boot.js new file mode 100644 index 0000000000..c159245ca6 --- /dev/null +++ b/frameworks/js-bindings/bindings/script/studio/jsb_studio_boot.js @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +//ccs.nodeReader = ccs.NodeReader.getInstance(); +ccs.actionTimelineCache = ccs.ActionTimelineCache.getInstance(); +ccs.actionTimelineCache.createAction = ccs.ActionTimelineCache.createAction; + +ccs.csLoader = ccs.CSLoader.getInstance(); +ccs.csLoader.createNode = ccs.CSLoader.createNode; +ccs.csLoader.createTimeline = ccs.CSLoader.createTimeline; + +// In extension +/** + * @type {Object} Base object for ccs.uiReader + * @name ccs.uiReader + */ +ccs.uiReader = null; +cc.defineGetterSetter(ccs, "uiReader", function() { + return ccs.GUIReader.getInstance(); +}); +ccs.GUIReader.prototype.clear = function() { + ccs.GUIReader.destroyInstance(); +}; +/** + * @type {Object} Format and manage armature configuration and armature animation + * @name ccs.armatureDataManager + */ +ccs.armatureDataManager = null; +cc.defineGetterSetter(ccs, "armatureDataManager", function() { + return ccs.ArmatureDataManager.getInstance(); +}); +ccs.ArmatureDataManager.prototype.clear = function() { + ccs.ArmatureDataManager.destroyInstance(); +}; +/** + * @type {Object} Base singleton object for ccs.sceneReader + * @name ccs.sceneReader + */ +ccs.sceneReader = null; +cc.defineGetterSetter(ccs, "sceneReader", function() { + return ccs.SceneReader.getInstance(); +}); +ccs.SceneReader.prototype.clear = function() { + ccs.SceneReader.destroyInstance(); +}; +ccs.SceneReader.prototype.version = function() { + return ccs.SceneReader.sceneReaderVersion(); +}; +/** + * @type {Object} Base singleton object for ccs.ActionManager + * @name ccs.actionManager + */ +ccs.actionManager = ccs.ActionManager.getInstance(); +ccs.ActionManager.prototype.clear = function() { + this.releaseActions(); +}; + +//ccs.spriteFrameCacheHelper = ccs.SpriteFrameCacheHelper.getInstance(); +//ccs.dataReaderHelper = ccs.DataReaderHelper.getInstance(); \ No newline at end of file diff --git a/frameworks/js-bindings/bindings/script/studio/jsb_studio_create_apis.js b/frameworks/js-bindings/bindings/script/studio/jsb_studio_create_apis.js new file mode 100644 index 0000000000..e4afbb78b4 --- /dev/null +++ b/frameworks/js-bindings/bindings/script/studio/jsb_studio_create_apis.js @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +/************************ Cocostudio *************************/ + +ccs.Armature.prototype._ctor = function(name, parentBone) { + // parentBone !== undefined && ccs.Armature.prototype.init.call(this, name, parentBone); + if(parentBone !== undefined) + ccs.Armature.prototype.init.call(this, name, parentBone); + else if(name !== undefined) + ccs.Armature.prototype.init.call(this, name); +}; + +ccs.Bone.prototype._ctor = function(name) { + name !== undefined && ccs.Bone.prototype.init.call(this, name); +}; + +ccs.ArmatureAnimation.prototype._ctor = function(armature) { + armature !== undefined && ccs.ArmatureAnimation.prototype.init.call(this, armature); +}; + +ccs.Tween.prototype._ctor = function(bone) { + bone !== undefined && ccs.Tween.prototype.init.call(this, bone); +}; + +ccs.BatchNode.prototype._ctor = function() { + ccs.BatchNode.prototype.init.call(this); +}; + +ccs.DecorativeDisplay.prototype._ctor = function() { + ccs.DecorativeDisplay.prototype.init.call(this); +}; + +ccs.DisplayManager.prototype._ctor = function(bone) { + bone !== undefined && ccs.DisplayManager.prototype.init.call(this, bone); +}; + +ccs.Skin.prototype._ctor = function(fileName, rect) { + if (fileName == null || fileName == "") { + ccs.Skin.prototype.init.call(this); + } else { + if(fileName[0] == "#"){ + ccs.Skin.prototype.initWithSpriteFrameName.call(this, fileName.substr(1)); + } else { + rect ? ccs.Skin.prototype.initWithFile.call(this, fileName) + : ccs.Skin.prototype.initWithFile.call(this, fileName, rect); + } + } +}; + +ccs.ColliderDetector.prototype._ctor = function(bone) { + bone !== undefined && ccs.ColliderDetector.prototype.init.call(this, bone); +}; + +ccs.TriggerObj.prototype._ctor = function() { + ccs.TriggerObj.prototype.init.call(this); +}; + +ccs.ComAttribute.prototype._ctor = function() { + ccs.ComAttribute.prototype.init.call(this); +}; + +ccs.ComAudio.prototype._ctor = function() { + ccs.ComAudio.prototype.init.call(this); +}; + +ccs.ComController.prototype._ctor = function() { + ccs.ComController.prototype.init.call(this); +}; + +ccs.ComRender.prototype._ctor = function() { + ccs.ComRender.prototype.init.call(this); +}; \ No newline at end of file diff --git a/frameworks/js-bindings/bindings/script/studio/jsb_studio_property_apis.js b/frameworks/js-bindings/bindings/script/studio/jsb_studio_property_apis.js new file mode 100644 index 0000000000..0c77272768 --- /dev/null +++ b/frameworks/js-bindings/bindings/script/studio/jsb_studio_property_apis.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014 Chukong Technologies Inc. + * + * 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. + */ + +var _proto = ccs.Bone.prototype; +cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); +cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); +cc.defineGetterSetter(_proto, "zIndex", _proto.getLocalZOrder, _proto.setLocalZOrder); +cc.defineGetterSetter(_proto, "boneData", _proto.getBoneData, _proto.setBoneData); +cc.defineGetterSetter(_proto, "armature", _proto.getArmature, _proto.setArmature); +cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone); +cc.defineGetterSetter(_proto, "childArmature", _proto.getChildArmature, _proto.setChildArmature); +cc.defineGetterSetter(_proto, "childrenBone", _proto.getChildrenBone); +cc.defineGetterSetter(_proto, "tween", _proto.getTween); +cc.defineGetterSetter(_proto, "tweenData", _proto.getTweenData); +cc.defineGetterSetter(_proto, "transformDirty", _proto.getTransformDirty, _proto.setTransformDirty); +cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter); +cc.defineGetterSetter(_proto, "displayManager", _proto.getDisplayManager, _proto.setDisplayManager); +cc.defineGetterSetter(_proto, "ignoreMovementBoneData", _proto.getIgnoreMovementBoneData, _proto.setIgnoreMovementBoneData); +cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); +cc.defineGetterSetter(_proto, "blendDirty", _proto.getBlendDirty, _proto.setBlendDirty); + +_proto = ccs.Armature.prototype; +cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone); +cc.defineGetterSetter(_proto, "animation", _proto.getAnimation, _proto.setAnimation); +cc.defineGetterSetter(_proto, "armatureData", _proto.getArmatureData, _proto.setArmatureData); +cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName); +cc.defineGetterSetter(_proto, "batchNode", _proto.getBatchNode, _proto.setBatchNode); +cc.defineGetterSetter(_proto, "version", _proto.getVersion, _proto.setVersion); +cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); +cc.defineGetterSetter(_proto, "colliderFilter", _proto.setColliderFilter); + +_proto = ccs.Skin.prototype; +cc.defineGetterSetter(_proto, "skinData", _proto.getSkinData, _proto.setSkinData); +cc.defineGetterSetter(_proto, "bone", _proto.getBone, _proto.setBone); +cc.defineGetterSetter(_proto, "displayName", _proto.getDisplayName); + +_proto = ccs.ColliderDetector.prototype; +cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter); +cc.defineGetterSetter(_proto, "active", _proto.getActive, _proto.setActive); +cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody); \ No newline at end of file diff --git a/frameworks/js-bindings/cocos2d-x b/frameworks/js-bindings/cocos2d-x index 08a16aa004..daa4a85447 160000 --- a/frameworks/js-bindings/cocos2d-x +++ b/frameworks/js-bindings/cocos2d-x @@ -1 +1 @@ -Subproject commit 08a16aa00400b64005b0ca5fdc315e15892789ac +Subproject commit daa4a85447b286aaed00c8f7cd8fe4cd7409f211 diff --git a/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi-v7a/libjs_static.a b/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi-v7a/libjs_static.a index b94f75ba85..8e5c119c57 100644 Binary files a/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi-v7a/libjs_static.a and b/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi-v7a/libjs_static.a differ diff --git a/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi/libjs_static.a b/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi/libjs_static.a index fac1d1bd20..800a3feac2 100644 Binary files a/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi/libjs_static.a and b/frameworks/js-bindings/external/spidermonkey/prebuilt/android/armeabi/libjs_static.a differ diff --git a/frameworks/js-bindings/external/spidermonkey/prebuilt/android/x86/libjs_static.a b/frameworks/js-bindings/external/spidermonkey/prebuilt/android/x86/libjs_static.a index 20c16e7f27..2b2d455474 100644 Binary files a/frameworks/js-bindings/external/spidermonkey/prebuilt/android/x86/libjs_static.a and b/frameworks/js-bindings/external/spidermonkey/prebuilt/android/x86/libjs_static.a differ diff --git a/samples/js-moonwarriors/CMakeLists.txt b/samples/js-moonwarriors/CMakeLists.txt index 911cd60f4f..0a37d6edd4 100644 --- a/samples/js-moonwarriors/CMakeLists.txt +++ b/samples/js-moonwarriors/CMakeLists.txt @@ -42,6 +42,9 @@ include_directories( ../../frameworks/js-bindings/bindings/auto ../../frameworks/js-bindings/bindings/manual ../../frameworks/js-bindings/cocos2d-x/cocos/base + ../../frameworks/js-bindings/cocos2d-x/cocos/audio/include + ../../frameworks/js-bindings/external/spidermonkey/include/${PLATFORM_FOLDER} + ../../frameworks/js-bindings/cocos2d-x/external/chipmunk/include/chipmunk ) # add the executable @@ -50,9 +53,8 @@ add_executable(${APP_NAME} ) target_link_libraries(${APP_NAME} - jsbindings + jsbindings cocos2d - js_static ) set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") diff --git a/samples/js-moonwarriors/LICENSE b/samples/js-moonwarriors/LICENSE new file mode 100644 index 0000000000..d5c21284ac --- /dev/null +++ b/samples/js-moonwarriors/LICENSE @@ -0,0 +1,23 @@ +cocos2d-html5 http://www.cocos2d-x.org + +Copyright (c) 2011-2012 Cocos2d-x community +Copyright (c) 2013-2014 Chukong Technologies Inc. +(see each file to see the different copyright owners) + +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. \ No newline at end of file diff --git a/samples/js-moonwarriors/main.js b/samples/js-moonwarriors/main.js index fb572801d9..5ec710f1cf 100755 --- a/samples/js-moonwarriors/main.js +++ b/samples/js-moonwarriors/main.js @@ -1,10 +1,10 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Cocos2d-html5 show case : Moon Warriors - http://www.cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,11 +18,16 @@ 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 + FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) ****************************************************************************/ /** diff --git a/samples/js-moonwarriors/project/Classes/AppDelegate.cpp b/samples/js-moonwarriors/project/Classes/AppDelegate.cpp index 1b15abe9df..08f7a7557d 100644 --- a/samples/js-moonwarriors/project/Classes/AppDelegate.cpp +++ b/samples/js-moonwarriors/project/Classes/AppDelegate.cpp @@ -4,18 +4,8 @@ #include "SimpleAudioEngine.h" #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" -#include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_builder_auto.hpp" -#include "extension/jsb_cocos2dx_extension_manual.h" #include "cocos2d_specifics.hpp" -#include "cocosbuilder/js_bindings_ccbreader.h" #include "localstorage/js_bindings_system_registration.h" -#include "chipmunk/js_bindings_chipmunk_registration.h" -#include "jsb_opengl_registration.h" -#include "jsb_cocos2dx_ui_auto.hpp" -#include "ui/jsb_cocos2dx_ui_manual.h" -#include "cocostudio/jsb_cocos2dx_studio_manual.h" -#include "jsb_cocos2dx_studio_auto.hpp" USING_NS_CC; using namespace CocosDenshion; @@ -26,7 +16,7 @@ AppDelegate::AppDelegate() AppDelegate::~AppDelegate() { - ScriptEngineManager::destroyInstance(); + ScriptEngineManager::destroyInstance(); } void AppDelegate::initGLContextAttrs() @@ -51,25 +41,16 @@ bool AppDelegate::applicationDidFinishLaunching() ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); - sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_cocos2dx_js_core); sc->addRegisterCallback(register_cocos2dx_js_extensions); - sc->addRegisterCallback(jsb_register_chipmunk); - sc->addRegisterCallback(register_all_cocos2dx_extension_manual); - sc->addRegisterCallback(register_all_cocos2dx_builder); - sc->addRegisterCallback(register_CCBuilderReader); sc->addRegisterCallback(jsb_register_system); - sc->addRegisterCallback(JSB_register_opengl); - sc->addRegisterCallback(register_all_cocos2dx_ui); - sc->addRegisterCallback(register_all_cocos2dx_ui_manual); - sc->addRegisterCallback(register_all_cocos2dx_studio); - sc->addRegisterCallback(register_all_cocos2dx_studio_manual); - + sc->start(); sc->runScript("script/jsb_boot.js"); #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) sc->enableDebugger(); #endif - + auto pEngine = ScriptingCore::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); @@ -85,7 +66,7 @@ void AppDelegate::applicationDidEnterBackground() director->stopAnimation(); director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); - SimpleAudioEngine::getInstance()->pauseAllEffects(); + SimpleAudioEngine::getInstance()->pauseAllEffects(); } // this function will be called when the app is active again diff --git a/samples/js-moonwarriors/project/proj.android/ant.properties b/samples/js-moonwarriors/project/proj.android/ant.properties index f8af38bfb4..6ce5d8b375 100644 --- a/samples/js-moonwarriors/project/proj.android/ant.properties +++ b/samples/js-moonwarriors/project/proj.android/ant.properties @@ -1 +1 @@ -aapt.ignore.assets="!*.pvr.gz:!*.gz:!.svn:!.git:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" +aapt.ignore.assets="!*.pvr.gz:!*.gz:!.svn:!.git:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" \ No newline at end of file diff --git a/samples/js-moonwarriors/project/proj.android/jni/Application.mk b/samples/js-moonwarriors/project/proj.android/jni/Application.mk index 9b48184d7a..706af60331 100644 --- a/samples/js-moonwarriors/project/proj.android/jni/Application.mk +++ b/samples/js-moonwarriors/project/proj.android/jni/Application.mk @@ -1,8 +1,7 @@ APP_STL := gnustl_static -#use clang by default, uncomment next line to use gcc4.8 -#NDK_TOOLCHAIN_VERSION=4.8 -NDK_TOOLCHAIN_VERSION=clang +# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices +#APP_ABI := armeabi-v7a APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic diff --git a/samples/js-moonwarriors/src/AboutLayer.js b/samples/js-moonwarriors/src/AboutLayer.js index bb07715847..4a6fa5703a 100755 --- a/samples/js-moonwarriors/src/AboutLayer.js +++ b/samples/js-moonwarriors/src/AboutLayer.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var AboutLayer = cc.Layer.extend({ ctor:function(){ this._super(); @@ -17,7 +49,7 @@ var AboutLayer = cc.Layer.extend({ this.addChild(title); // There is a bug in LabelTTF native. Apparently it fails with some unicode chars. - var about = new cc.LabelTTF(" This showcase utilizes many features from Cocos2d-html5 engine, including: Parallax background, tilemap, actions, ease, frame animation, schedule, Labels, keyboard Dispatcher, Scene Transition. \n Art and audio is copyrighted by Enigmata Genus Revenge, you may not use any copyrigted material without permission. This showcase is licensed under GPL. \n \n Programmer: \n Shengxiang Chen (陈升想) \n Dingping Lv (吕定平) \n Effects animation: Hao Wu(吴昊)\n Quality Assurance: Sean Lin(林顺)", "Arial", 21, cc.size(MW.WIDTH * 0.85, 0), cc.TEXT_ALIGNMENT_LEFT ); + var about = new cc.LabelTTF(" This showcase utilizes many features from Cocos2d-html5 engine, including: Parallax background, tilemap, actions, ease, frame animation, schedule, Labels, keyboard Dispatcher, Scene Transition. \n Art and audio is copyrighted by Enigmata Genus Revenge, you may not use any copyrigted material without permission. This showcase is licensed under MIT. \n \n Programmer: \n Shengxiang Chen (陈升想) \n Dingping Lv (吕定平) \n Effects animation: Hao Wu(吴昊)\n Quality Assurance: Sean Lin(林顺)", "Arial", 21, cc.size(MW.WIDTH * 0.85, 0), cc.TEXT_ALIGNMENT_LEFT ); about.attr({ x: winSize.width / 2, y: MW.HEIGHT / 2 + 30, diff --git a/samples/js-moonwarriors/src/Background.js b/samples/js-moonwarriors/src/Background.js index 765d0f2563..ef9dc8bed0 100644 --- a/samples/js-moonwarriors/src/Background.js +++ b/samples/js-moonwarriors/src/Background.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var BackSky = cc.Sprite.extend({ active:true, ctor:function () { diff --git a/samples/js-moonwarriors/src/Bullet.js b/samples/js-moonwarriors/src/Bullet.js index b5dbe74ee2..8f6ac127a5 100755 --- a/samples/js-moonwarriors/src/Bullet.js +++ b/samples/js-moonwarriors/src/Bullet.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + //bullet var Bullet = cc.Sprite.extend({ active:true, diff --git a/samples/js-moonwarriors/src/Effect.js b/samples/js-moonwarriors/src/Effect.js index a6ead8dd1e..a10c367281 100755 --- a/samples/js-moonwarriors/src/Effect.js +++ b/samples/js-moonwarriors/src/Effect.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var flareEffect = function (flare,target, callback) { flare.stopAllActions(); flare.setBlendFunc(cc.SRC_ALPHA, cc.ONE); diff --git a/samples/js-moonwarriors/src/Enemy.js b/samples/js-moonwarriors/src/Enemy.js index 6228bdf76c..71a22d84a6 100755 --- a/samples/js-moonwarriors/src/Enemy.js +++ b/samples/js-moonwarriors/src/Enemy.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var Enemy = cc.Sprite.extend({ eID:0, enemyType:1, diff --git a/samples/js-moonwarriors/src/Explosion.js b/samples/js-moonwarriors/src/Explosion.js index f8a2e3206a..9816a1af65 100755 --- a/samples/js-moonwarriors/src/Explosion.js +++ b/samples/js-moonwarriors/src/Explosion.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var Explosion = cc.Sprite.extend({ tmpWidth:0, tmpHeight:0, diff --git a/samples/js-moonwarriors/src/GameControlMenu.js b/samples/js-moonwarriors/src/GameControlMenu.js index 1c6ac6d435..47f2087383 100755 --- a/samples/js-moonwarriors/src/GameControlMenu.js +++ b/samples/js-moonwarriors/src/GameControlMenu.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var GameControlMenu = cc.Layer.extend({ ctor:function(){ this._super(); diff --git a/samples/js-moonwarriors/src/GameController.js b/samples/js-moonwarriors/src/GameController.js index 4824547bfb..4d134bc77f 100755 --- a/samples/js-moonwarriors/src/GameController.js +++ b/samples/js-moonwarriors/src/GameController.js @@ -1,20 +1,34 @@ -/** - * Cocos2d-html5 show case : Moon Warriors - * - * @Licensed: - * This showcase is licensed under GPL. - * - * @Authors: - * Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada - * Effects animation: Hao Wu (吴昊) - * Quality Assurance: Sean Lin (林顺) - * - * @Links: - * http://www.cocos2d-x.org - * http://bbs.html5china.com - * - */ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ MW.GameController = cc.Class.extend({ _curScene:null, diff --git a/samples/js-moonwarriors/src/GameLayer.js b/samples/js-moonwarriors/src/GameLayer.js index 3459a2e8fc..9f6f98fc7f 100755 --- a/samples/js-moonwarriors/src/GameLayer.js +++ b/samples/js-moonwarriors/src/GameLayer.js @@ -1,8 +1,34 @@ -// -// MoonWarriors -// -// Handles the Game Logic -// +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ STATE_PLAYING = 0; STATE_GAMEOVER = 1; diff --git a/samples/js-moonwarriors/src/GameOver.js b/samples/js-moonwarriors/src/GameOver.js index 376aeb3b8b..b57078ea27 100755 --- a/samples/js-moonwarriors/src/GameOver.js +++ b/samples/js-moonwarriors/src/GameOver.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var GameOver = cc.Layer.extend({ _ship:null, _lbScore:0, @@ -66,7 +98,7 @@ var GameOver = cc.Layer.extend({ if(MW.SOUND){ - cc.audioEngine.playMusic(res.mainMainMusic_mp3); + cc.audioEngine.playMusic(res.mainMainMusic_mp3, true); } return true; diff --git a/samples/js-moonwarriors/src/HitEffect.js b/samples/js-moonwarriors/src/HitEffect.js index c84136102a..3e5741cda2 100755 --- a/samples/js-moonwarriors/src/HitEffect.js +++ b/samples/js-moonwarriors/src/HitEffect.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var HitEffect = cc.Sprite.extend({ active:true, ctor:function () { diff --git a/samples/js-moonwarriors/src/LevelManager.js b/samples/js-moonwarriors/src/LevelManager.js index 2a5f770271..930d852dcf 100755 --- a/samples/js-moonwarriors/src/LevelManager.js +++ b/samples/js-moonwarriors/src/LevelManager.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var LevelManager = cc.Class.extend({ _currentLevel:null, _gameLayer:null, diff --git a/samples/js-moonwarriors/src/Resource.js b/samples/js-moonwarriors/src/Resource.js index f8ea4ea2de..d41ceb3734 100755 --- a/samples/js-moonwarriors/src/Resource.js +++ b/samples/js-moonwarriors/src/Resource.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var res = { bgMusic_mp3 : 'res/Music/bgMusic.mp3', bgMusic_ogg : 'res/Music/bgMusic.ogg', diff --git a/samples/js-moonwarriors/src/SettingsLayer.js b/samples/js-moonwarriors/src/SettingsLayer.js index 7694bbed42..9acd4d339a 100755 --- a/samples/js-moonwarriors/src/SettingsLayer.js +++ b/samples/js-moonwarriors/src/SettingsLayer.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var SettingsLayer = cc.Layer.extend({ ctor:function(){ this._super(); diff --git a/samples/js-moonwarriors/src/Ship.js b/samples/js-moonwarriors/src/Ship.js index c3704e90cc..76a7bbf078 100755 --- a/samples/js-moonwarriors/src/Ship.js +++ b/samples/js-moonwarriors/src/Ship.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var Ship = cc.Sprite.extend({ speed:220, bulletSpeed:MW.BULLET_SPEED.SHIP, diff --git a/samples/js-moonwarriors/src/SparkEffect.js b/samples/js-moonwarriors/src/SparkEffect.js index 0efe9ff34e..1bae9b77fe 100755 --- a/samples/js-moonwarriors/src/SparkEffect.js +++ b/samples/js-moonwarriors/src/SparkEffect.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var SparkEffect = cc.Class.extend({ active:true, spark1:null, diff --git a/samples/js-moonwarriors/src/SysMenu.js b/samples/js-moonwarriors/src/SysMenu.js index eb01cb2e3e..7d946dc4a3 100755 --- a/samples/js-moonwarriors/src/SysMenu.js +++ b/samples/js-moonwarriors/src/SysMenu.js @@ -1,3 +1,34 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ var SysMenu = cc.Layer.extend({ _ship:null, diff --git a/samples/js-moonwarriors/src/config/EnemyType.js b/samples/js-moonwarriors/src/config/EnemyType.js index c947d58903..914616ce99 100755 --- a/samples/js-moonwarriors/src/config/EnemyType.js +++ b/samples/js-moonwarriors/src/config/EnemyType.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var EnemyType = [ { type:0, diff --git a/samples/js-moonwarriors/src/config/GameConfig.js b/samples/js-moonwarriors/src/config/GameConfig.js index 9204f3f18f..3e9c609f7d 100755 --- a/samples/js-moonwarriors/src/config/GameConfig.js +++ b/samples/js-moonwarriors/src/config/GameConfig.js @@ -1,19 +1,34 @@ -/** - * Cocos2d-html5 show case : Moon Warriors - * - * @Licensed: - * This showcase is licensed under GPL. - * - * @Authors: - * Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada - * Effects animation: Hao Wu (吴昊) - * Quality Assurance: Sean Lin (林顺) - * - * @Links: - * http://www.cocos2d-x.org - * http://bbs.html5china.com - * - */ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ var MW = MW || {}; @@ -41,7 +56,7 @@ MW.LIFE = 4; MW.SCORE = 0; //sound -MW.SOUND = false; +MW.SOUND = true; //enemy move type MW.ENEMY_MOVE_TYPE = { diff --git a/samples/js-moonwarriors/src/config/Level.js b/samples/js-moonwarriors/src/config/Level.js index 1699398c1f..d036113deb 100755 --- a/samples/js-moonwarriors/src/config/Level.js +++ b/samples/js-moonwarriors/src/config/Level.js @@ -1,3 +1,35 @@ +/**************************************************************************** + Cocos2d-html5 show case : Moon Warriors + + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + 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 NON INFRINGEMENT. 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. + + @Authors: + Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada + Effects animation: Hao Wu (吴昊) + Quality Assurance: Sean Lin (林顺) + ****************************************************************************/ + var Level1 = { enemyMax:6, enemies:[ diff --git a/samples/js-tests/CMakeLists.txt b/samples/js-tests/CMakeLists.txt index 146a34d257..b0de0a997d 100644 --- a/samples/js-tests/CMakeLists.txt +++ b/samples/js-tests/CMakeLists.txt @@ -42,6 +42,10 @@ include_directories( ../../frameworks/js-bindings/bindings/auto ../../frameworks/js-bindings/bindings/manual ../../frameworks/js-bindings/cocos2d-x/cocos/base + ../../frameworks/js-bindings/cocos2d-x/cocos/editor-support + ../../frameworks/js-bindings/cocos2d-x/cocos/audio/include + ../../frameworks/js-bindings/external/spidermonkey/include/${PLATFORM_FOLDER} + ../../frameworks/js-bindings/cocos2d-x/external/chipmunk/include/chipmunk ) # add the executable @@ -52,7 +56,6 @@ add_executable(${APP_NAME} target_link_libraries(${APP_NAME} jsbindings cocos2d - js_static ) set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") diff --git a/samples/js-tests/lib/TestCase/testcase.js b/samples/js-tests/lib/TestCase/testcase.js index e3b516df8a..237283788d 100644 --- a/samples/js-tests/lib/TestCase/testcase.js +++ b/samples/js-tests/lib/TestCase/testcase.js @@ -227,6 +227,7 @@ ,null//extensions ,arrayOfEffectsTest ,arrayOfEffectsAdvancedTest + ,null//facebook ,null//FontTest ,null//UI ,[IntervalLayer]//Interval @@ -387,11 +388,16 @@ }); }, - changeTest: function() { - return sidebar._testNum; + changeTest: function(testChangeNum) { + if (sidebar._testNum == testChangeNum) + { + return testChangeNum; + } + sidebar.changeHover(testChangeNum, sidebar._sceneNum); + return testChangeNum; }, - changeTestScene: function(actualTestNum, actualSceneNum){ + changeHover:function (actualTestNum, actualSceneNum) { if(sidebar._sceneNum == actualSceneNum){ if(sidebar._testNum < actualTestNum){ @@ -415,6 +421,10 @@ sidebar._testNum = actualTestNum; this._hiddenOtherHover(actualTestNum, actualSceneNum); + }, + + changeTestScene: function(actualTestNum, actualSceneNum){ + sidebar.changeHover(actualTestNum, actualSceneNum); //The same scene cc.LoaderScene.preload(testNames[sidebar.diplayRecordArr[actualSceneNum]].resource || [], function () { diff --git a/samples/js-tests/main.js b/samples/js-tests/main.js index 3ca7742540..c12c74fde0 100644 --- a/samples/js-tests/main.js +++ b/samples/js-tests/main.js @@ -80,6 +80,10 @@ * */ +var scene3SearchPaths = cc.sys.localStorage.getItem("Scene3SearchPaths"); +if (scene3SearchPaths) + jsb.fileUtils.setSearchPaths(JSON.parse(scene3SearchPaths)); + cc.game.onStart = function(){ if (cc.sys.isNative) { diff --git a/samples/js-tests/project.json b/samples/js-tests/project.json index 36988c2b91..f5df6886dd 100644 --- a/samples/js-tests/project.json +++ b/samples/js-tests/project.json @@ -70,6 +70,7 @@ "src/EventTest/EventTest.js", "src/UnitTest/UnitTest.js", "src/SysTest/SysTest.js", + "src/SysTest/ScriptTestTempFile.js", "src/EffectsTest/EffectsTest.js", "src/EffectsAdvancedTest/EffectsAdvancedTest.js", "src/MotionStreakTest/MotionStreakTest.js", @@ -173,10 +174,6 @@ "src/ChipmunkTest/ChipmunkTest.js", "src/Presentation/Presentation.js", - "src/ReflectionTest/ReflectionTest.js", - - "src/CocosStudio2.0/main.js", - "src/CocosStudio2.0/UIFromCsb.js", - "src/CocosStudio2.0/TimeLineFromCsb.js" + "src/ReflectionTest/ReflectionTest.js" ] } diff --git a/samples/js-tests/project/Classes/AppDelegate.cpp b/samples/js-tests/project/Classes/AppDelegate.cpp index 50c928b916..09682b8dbf 100644 --- a/samples/js-tests/project/Classes/AppDelegate.cpp +++ b/samples/js-tests/project/Classes/AppDelegate.cpp @@ -69,12 +69,16 @@ bool AppDelegate::applicationDidFinishLaunching() ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); - sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_cocos2dx_js_core); sc->addRegisterCallback(register_cocos2dx_js_extensions); + sc->addRegisterCallback(jsb_register_system); + + sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(JSB_register_opengl); - sc->addRegisterCallback(jsb_register_system); + sc->addRegisterCallback(MinXmlHttpRequest::_js_register); sc->addRegisterCallback(register_jsb_websocket); sc->addRegisterCallback(register_jsb_socketio); diff --git a/samples/js-tests/project/proj.android/jni/Application.mk b/samples/js-tests/project/proj.android/jni/Application.mk index 9b48184d7a..706af60331 100644 --- a/samples/js-tests/project/proj.android/jni/Application.mk +++ b/samples/js-tests/project/proj.android/jni/Application.mk @@ -1,8 +1,7 @@ APP_STL := gnustl_static -#use clang by default, uncomment next line to use gcc4.8 -#NDK_TOOLCHAIN_VERSION=4.8 -NDK_TOOLCHAIN_VERSION=clang +# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices +#APP_ABI := armeabi-v7a APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic diff --git a/samples/js-tests/res/ActionTimeline/boy_1.csb b/samples/js-tests/res/ActionTimeline/boy_1.csb deleted file mode 100644 index d1c9d44e5c..0000000000 Binary files a/samples/js-tests/res/ActionTimeline/boy_1.csb and /dev/null differ diff --git a/samples/js-tests/res/Manifests/ScriptTest/project.manifest b/samples/js-tests/res/Manifests/ScriptTest/project.manifest new file mode 100644 index 0000000000..83fb2282ef --- /dev/null +++ b/samples/js-tests/res/Manifests/ScriptTest/project.manifest @@ -0,0 +1,13 @@ +{ + "packageUrl" : "http://tools.itharbors.com/assets_manager/ScriptTest/", + "remoteManifestUrl" : "http://tools.itharbors.com/assets_manager/ScriptTest/project_dev.manifest", + "remoteVersionUrl" : "http://tools.itharbors.com/assets_manager/ScriptTest/version_dev.manifest", + "version" : "1.0.0", + "engineVersion" : "3.0", + + "assets" : { + }, + + "searchPaths" : [ + ] +} \ No newline at end of file diff --git a/samples/js-tests/res/Shaders/example_Outline.fsh b/samples/js-tests/res/Shaders/example_Outline.fsh new file mode 100644 index 0000000000..0bac52235c --- /dev/null +++ b/samples/js-tests/res/Shaders/example_Outline.fsh @@ -0,0 +1,27 @@ +varying vec2 v_texCoord; +varying vec4 v_fragmentColor; + +uniform vec3 u_outlineColor; +uniform float u_threshold; +uniform float u_radius; + +void main() +{ + float radius = u_radius; + vec4 accum = vec4(0.0); + vec4 normal = vec4(0.0); + + normal = texture2D(CC_Texture0, vec2(v_texCoord.x, v_texCoord.y)); + + accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y - radius)); + accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y - radius)); + accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y + radius)); + accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y + radius)); + + accum *= u_threshold; + accum.rgb = u_outlineColor * accum.a; + + normal = ( accum * (1.0 - normal.a)) + (normal * normal.a); + + gl_FragColor = v_fragmentColor * normal; +} diff --git a/samples/js-tests/res/Shaders/example_Outline.vsh b/samples/js-tests/res/Shaders/example_Outline.vsh new file mode 100644 index 0000000000..8cda2a8438 --- /dev/null +++ b/samples/js-tests/res/Shaders/example_Outline.vsh @@ -0,0 +1,13 @@ +attribute vec4 a_position; +attribute vec2 a_texCoord; +attribute vec4 a_color; + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; + +void main() +{ + gl_Position = CC_PMatrix * CC_MVMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; +} \ No newline at end of file diff --git a/samples/js-tests/res/Shaders/example_Outline_noMVP.vsh b/samples/js-tests/res/Shaders/example_Outline_noMVP.vsh new file mode 100644 index 0000000000..0bcce55b80 --- /dev/null +++ b/samples/js-tests/res/Shaders/example_Outline_noMVP.vsh @@ -0,0 +1,13 @@ +attribute vec4 a_position; +attribute vec2 a_texCoord; +attribute vec4 a_color; + +varying vec4 v_fragmentColor; +varying vec2 v_texCoord; + +void main() +{ + gl_Position = CC_PMatrix * a_position; + v_fragmentColor = a_color; + v_texCoord = a_texCoord; +} \ No newline at end of file diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIButton_Editor/crossplatform_UIButton_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIButton_Editor/crossplatform_UIButton_Editor_1.csb deleted file mode 100644 index 7da0eb609f..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIButton_Editor/crossplatform_UIButton_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIButton_Editor/windows_UIButton_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIButton_Editor/windows_UIButton_Editor_1.csb deleted file mode 100644 index 37bc069f80..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIButton_Editor/windows_UIButton_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UICheckBox_Editor/windows_ui_checkbox_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UICheckBox_Editor/windows_ui_checkbox_editor_1.csb deleted file mode 100644 index ed9dc39438..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UICheckBox_Editor/windows_ui_checkbox_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIImageView_Editor/windows_ui_ImageView_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIImageView_Editor/windows_ui_ImageView_editor_1.csb deleted file mode 100644 index a9921efbb3..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIImageView_Editor/windows_ui_ImageView_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILabelAtlas_Editor/crossplatform_UILabelAtlas_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILabelAtlas_Editor/crossplatform_UILabelAtlas_Editor_1.csb deleted file mode 100644 index a0a268f4e0..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILabelAtlas_Editor/crossplatform_UILabelAtlas_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILabelAtlas_Editor/windows_ui_labelatlas_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILabelAtlas_Editor/windows_ui_labelatlas_editor_1.csb deleted file mode 100644 index cae1c2a5fc..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILabelAtlas_Editor/windows_ui_labelatlas_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILabelBMFont_Editor/crossplatform_UILabelBMFont_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILabelBMFont_Editor/crossplatform_UILabelBMFont_Editor_1.csb deleted file mode 100644 index 1b19f3b573..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILabelBMFont_Editor/crossplatform_UILabelBMFont_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILabelBMFont_Editor/windows_ui_labelbmfont_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILabelBMFont_Editor/windows_ui_labelbmfont_editor_1.csb deleted file mode 100644 index 6108849447..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILabelBMFont_Editor/windows_ui_labelbmfont_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILabel_Editor/crossplatform_UILabel_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILabel_Editor/crossplatform_UILabel_Editor_1.csb deleted file mode 100644 index 44dd061948..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILabel_Editor/crossplatform_UILabel_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILabel_Editor/windows_ui_label_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILabel_Editor/windows_ui_label_editor_1.csb deleted file mode 100644 index 0801345fa8..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILabel_Editor/windows_ui_label_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_BackgroundImage.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_BackgroundImage.csb deleted file mode 100644 index d9ecae737a..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_BackgroundImage.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_UILayout_BackgroundImage_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_UILayout_BackgroundImage_Editor_1.csb deleted file mode 100644 index ff4eca4548..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/crossplatform_UILayout_BackgroundImage_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_backgroundimage.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_backgroundimage.csb deleted file mode 100644 index 4e0b8d643b..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_backgroundimage.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_layout_backgroundimage_editor_1_0_0.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_layout_backgroundimage_editor_1_0_0.csb deleted file mode 100644 index 4e0b8d643b..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/windows_ui_layout_backgroundimage_editor_1_0_0.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_Color.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_Color.csb deleted file mode 100644 index 2e70826bb9..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_Color.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_UILayout_Color_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_UILayout_Color_Editor_1.csb deleted file mode 100644 index 3c08377e55..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/crossplatform_UILayout_Color_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_color.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_color.csb deleted file mode 100644 index 571639fa96..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_color.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_layout_color_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_layout_color_editor_1.csb deleted file mode 100644 index 571639fa96..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/windows_ui_layout_color_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/crossplatform_UILayout_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/crossplatform_UILayout_Editor_1.csb deleted file mode 100644 index 8cf2645485..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/crossplatform_UILayout_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/windows_ui_layout_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/windows_ui_layout_editor_1.csb deleted file mode 100644 index bc4c2beec4..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/windows_ui_layout_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_Gradient_Color.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_Gradient_Color.csb deleted file mode 100644 index ebef983638..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_Gradient_Color.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_UILayout_Gradient_Color_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_UILayout_Gradient_Color_Editor_1.csb deleted file mode 100644 index 0e47d6764c..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/crossplatform_UILayout_Gradient_Color_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_gradient_color.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_gradient_color.csb deleted file mode 100644 index 72713e79e4..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_gradient_color.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_layout_gradient_color_editor_1_0.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_layout_gradient_color_editor_1_0.csb deleted file mode 100644 index 72713e79e4..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/windows_ui_layout_gradient_color_editor_1_0.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_Linear_Horizontal_Layout.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_Linear_Horizontal_Layout.csb deleted file mode 100644 index 1d707a36d3..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_Linear_Horizontal_Layout.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_UILayout_Linear_Horizontal_Layout_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_UILayout_Linear_Horizontal_Layout_Editor_1.csb deleted file mode 100644 index 1d707a36d3..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/crossplatform_UILayout_Linear_Horizontal_Layout_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_layout_linear_horizontal_layout_editor.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_layout_linear_horizontal_layout_editor.csb deleted file mode 100644 index 39e04fc835..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_layout_linear_horizontal_layout_editor.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_linear_horizontal_layout.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_linear_horizontal_layout.csb deleted file mode 100644 index 39e04fc835..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/windows_ui_linear_horizontal_layout.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_Linear_Vertical_Layout.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_Linear_Vertical_Layout.csb deleted file mode 100644 index be97c9867e..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_Linear_Vertical_Layout.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_UILayout_Linear_Vertical_Layout_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_UILayout_Linear_Vertical_Layout_Editor_1.csb deleted file mode 100644 index be97c9867e..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/crossplatform_UILayout_Linear_Vertical_Layout_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_layout_linear_vertical_layout_editor.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_layout_linear_vertical_layout_editor.csb deleted file mode 100644 index cc41f9e1a0..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_layout_linear_vertical_layout_editor.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_linear_vertical_layout.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_linear_vertical_layout.csb deleted file mode 100644 index cc41f9e1a0..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/windows_ui_linear_vertical_layout.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_Relative_Align_Location.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_Relative_Align_Location.csb deleted file mode 100644 index 8e9d546ab0..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_Relative_Align_Location.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_UILayout_Relative_Align_Location_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_UILayout_Relative_Align_Location_Editor_1.csb deleted file mode 100644 index 8e9d546ab0..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/crossplatform_UILayout_Relative_Align_Location_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_layout_relative_align_location_editor.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_layout_relative_align_location_editor.csb deleted file mode 100644 index 664e83793a..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_layout_relative_align_location_editor.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_relative_align_location.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_relative_align_location.csb deleted file mode 100644 index 664e83793a..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/windows_ui_relative_align_location.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_Relative_Align_Parent.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_Relative_Align_Parent.csb deleted file mode 100644 index 8e187be034..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_Relative_Align_Parent.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_UILayout_Relative_Align_Parent_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_UILayout_Relative_Align_Parent_Editor_1.csb deleted file mode 100644 index 8e187be034..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/crossplatform_UILayout_Relative_Align_Parent_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_layout_relative_align_parent_editor.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_layout_relative_align_parent_editor.csb deleted file mode 100644 index 2111379486..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_layout_relative_align_parent_editor.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_relative_align_parent.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_relative_align_parent.csb deleted file mode 100644 index 2111379486..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/windows_ui_relative_align_parent.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_Scale9_BackgroundImage.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_Scale9_BackgroundImage.csb deleted file mode 100644 index 794251eebf..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_Scale9_BackgroundImage.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_UILayout_Scale9_BackgroundImage_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_UILayout_Scale9_BackgroundImage_Editor_1.csb deleted file mode 100644 index 7b4c731f87..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/crossplatform_UILayout_Scale9_BackgroundImage_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_layout_scale9_backgroundimage_editor.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_layout_scale9_backgroundimage_editor.csb deleted file mode 100644 index 1906836701..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_layout_scale9_backgroundimage_editor.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_scale9_backgroundimage.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_scale9_backgroundimage.csb deleted file mode 100644 index 1906836701..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/windows_ui_scale9_backgroundimage.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/crossplatform_UIListView_Horizontal_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/crossplatform_UIListView_Horizontal_Editor_1.csb deleted file mode 100644 index 6c0dc9f84a..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/crossplatform_UIListView_Horizontal_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/windows_ui_listview_horizontal_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/windows_ui_listview_horizontal_editor_1.csb deleted file mode 100644 index 8b8ee2e741..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/windows_ui_listview_horizontal_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/crossplatform_UIListView_Vertical_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/crossplatform_UIListView_Vertical_Editor_1.csb deleted file mode 100644 index 204c6db2a1..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/crossplatform_UIListView_Vertical_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/windows_ui_listview_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/windows_ui_listview_editor_1.csb deleted file mode 100644 index 72f7d71871..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/windows_ui_listview_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILoadingBar_Editor/crossplatform_UILoadingBar_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILoadingBar_Editor/crossplatform_UILoadingBar_Editor_1.csb deleted file mode 100644 index f235d1ccce..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILoadingBar_Editor/crossplatform_UILoadingBar_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UILoadingBar_Editor/windows_ui_loadingbar_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UILoadingBar_Editor/windows_ui_loadingbar_editor_1.csb deleted file mode 100644 index 4b28f3115a..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UILoadingBar_Editor/windows_ui_loadingbar_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIPageView_Editor/crossplatform_UIPageView_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIPageView_Editor/crossplatform_UIPageView_Editor_1.csb deleted file mode 100644 index ca07f3e952..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIPageView_Editor/crossplatform_UIPageView_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIPageView_Editor/windows_ui_pageview_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIPageView_Editor/windows_ui_pageview_editor_1.csb deleted file mode 100644 index aa08b21377..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIPageView_Editor/windows_ui_pageview_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/crossplatform_UIScrollView_Both_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/crossplatform_UIScrollView_Both_Editor_1.csb deleted file mode 100644 index f1ebe92f12..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/crossplatform_UIScrollView_Both_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/windows_ui_scrollview_both_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/windows_ui_scrollview_both_editor_1.csb deleted file mode 100644 index 532499318c..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/windows_ui_scrollview_both_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/crossplatform_UIScrollView_Horizontal_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/crossplatform_UIScrollView_Horizontal_Editor_1.csb deleted file mode 100644 index a1ce2b4948..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/crossplatform_UIScrollView_Horizontal_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/windows_ui_scrollview_horizontal_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/windows_ui_scrollview_horizontal_editor_1.csb deleted file mode 100644 index cc9b8fadd0..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/windows_ui_scrollview_horizontal_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/crossplatform_UIScrollView_Vertical_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/crossplatform_UIScrollView_Vertical_Editor_1.csb deleted file mode 100644 index cb1719cbfe..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/crossplatform_UIScrollView_Vertical_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/windows_ui_scrollview_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/windows_ui_scrollview_editor_1.csb deleted file mode 100644 index 995d36752c..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/windows_ui_scrollview_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UISlider_Editor/crossplatform_UISlider_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UISlider_Editor/crossplatform_UISlider_Editor_1.csb deleted file mode 100644 index b742438924..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UISlider_Editor/crossplatform_UISlider_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UISlider_Editor/windows_ui_slider_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UISlider_Editor/windows_ui_slider_editor_1.csb deleted file mode 100644 index 59320c755a..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UISlider_Editor/windows_ui_slider_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UITextField_Editor/crossplatform_UITextField_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UITextField_Editor/crossplatform_UITextField_Editor_1.csb deleted file mode 100644 index 86541c0110..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UITextField_Editor/crossplatform_UITextField_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UITextField_Editor/windows_ui_textfield_editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UITextField_Editor/windows_ui_textfield_editor_1.csb deleted file mode 100644 index da8408351d..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UITextField_Editor/windows_ui_textfield_editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIWidgetAddNode_Editor/crossplatform_UIWidgetAddNode_Editor_1.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIWidgetAddNode_Editor/crossplatform_UIWidgetAddNode_Editor_1.csb deleted file mode 100644 index 35ca215d84..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIWidgetAddNode_Editor/crossplatform_UIWidgetAddNode_Editor_1.csb and /dev/null differ diff --git a/samples/js-tests/res/cocosui/UIEditorTest/UIWidgetAddNode_Editor/windows_ui_widget_add_node_editor.csb b/samples/js-tests/res/cocosui/UIEditorTest/UIWidgetAddNode_Editor/windows_ui_widget_add_node_editor.csb deleted file mode 100644 index 5325ff06d6..0000000000 Binary files a/samples/js-tests/res/cocosui/UIEditorTest/UIWidgetAddNode_Editor/windows_ui_widget_add_node_editor.csb and /dev/null differ diff --git a/samples/js-tests/src/BakeLayerTest/BakeLayerTest.js b/samples/js-tests/src/BakeLayerTest/BakeLayerTest.js index dce4d44b49..bc3a202162 100644 --- a/samples/js-tests/src/BakeLayerTest/BakeLayerTest.js +++ b/samples/js-tests/src/BakeLayerTest/BakeLayerTest.js @@ -106,7 +106,7 @@ var BakeLayerTest1 = BakeLayerBaseTest.extend({ bakeLayer.addChild(sprite1); } this._bakeLayer = bakeLayer; - + bakeLayer.runAction(cc.sequence(cc.moveBy(2, cc.p(100,100)), cc.moveBy(2, cc.p(-100,-100)))); }, onBake: function(){ @@ -170,6 +170,7 @@ var BakeLayerColorTest = BakeLayerBaseTest.extend({ this._bakeLayer = bakeLayer; bakeLayer.bake(); + bakeLayer.runAction(cc.sequence(cc.moveBy(2, cc.p(100,100)), cc.moveBy(2, cc.p(-100,-100)))); }, onBake: function(){ diff --git a/samples/js-tests/src/BaseTestLayer/BaseTestLayer.js b/samples/js-tests/src/BaseTestLayer/BaseTestLayer.js index 408976d7d5..d06dd54850 100644 --- a/samples/js-tests/src/BaseTestLayer/BaseTestLayer.js +++ b/samples/js-tests/src/BaseTestLayer/BaseTestLayer.js @@ -217,7 +217,7 @@ var BaseTestLayerProps = { runNextTest:function() { if( this.numberOfPendingTests() <= 0 ) { - var scene = cc.Scene.create(); + var scene = new cc.Scene(); var layer = new TestController(); scene.addChild(layer); director.runScene(scene); diff --git a/samples/js-tests/src/ChipmunkTest/ChipmunkTest.js b/samples/js-tests/src/ChipmunkTest/ChipmunkTest.js index f9052a1d00..f94c23d330 100644 --- a/samples/js-tests/src/ChipmunkTest/ChipmunkTest.js +++ b/samples/js-tests/src/ChipmunkTest/ChipmunkTest.js @@ -243,6 +243,101 @@ var ChipmunkSpriteBatchTest = ChipmunkSprite.extend( { } }); + //------------------------------------------------------------------ + // + // Chipmunk Collision Test + // Using setDefaultCollisionHandler + // The default collision handler is invoked for each colliding pair of shapes that isn't explicitly handled by a specific collision handler. + // + //------------------------------------------------------------------ +var ChipmunkCollisionTest_no_specific_type = ChipmunkBaseLayer.extend({ + ctor : function () { + this._super(); + + this._title = 'Chipmunk Collision test'; + this._subtitle = 'Using setDefaultCollisionHandler'; + }, + + // init physics + initPhysics : function() { + var staticBody = this.space.staticBody; + + // Walls + var walls = [ new cp.SegmentShape( staticBody, cp.v(0,0), cp.v(winSize.width,0), 0 ), // bottom + // new cp.SegmentShape( staticBody, cp.v(0,winSize.height), cp.v(winSize.width,winSize.height), 0), // top + // new cp.SegmentShape( staticBody, cp.v(0,0), cp.v(0,winSize.height), 0), // left + // new cp.SegmentShape( staticBody, cp.v(winSize.width,0), cp.v(winSize.width,winSize.height), 0) // right + ]; + for( var i=0; i < walls.length; i++ ) { + var wall = walls[i]; + wall.setElasticity(1); + wall.setFriction(1); + this.space.addStaticShape( wall ); + } + + // Gravity: + // testing properties + this.space.gravity = cp.v(0,-100); + this.space.iterations = 15; + }, + + createPhysicsSprite : function( pos, file ) { + var body = new cp.Body(1, cp.momentForBox(1, 48, 108) ); + body.setPos(pos); + this.space.addBody(body); + var shape = new cp.BoxShape( body, 48, 108); + shape.setElasticity( 0.5 ); + shape.setFriction( 0.5 ); + this.space.addShape( shape ); + + var sprite = new cc.PhysicsSprite(file); + sprite.setBody( body ); + return sprite; + }, + + onEnter : function () { + ChipmunkBaseLayer.prototype.onEnter.call(this); + + this.initPhysics(); + this.scheduleUpdate(); + + var sprite1 = this.createPhysicsSprite( cc.p(winSize.width/2, winSize.height-20), s_pathGrossini); + this.addChild( sprite1 ); + + this.space.setDefaultCollisionHandler( + this.collisionBegin.bind(this), + this.collisionPre.bind(this), + this.collisionPost.bind(this), + this.collisionSeparate.bind(this) + ); + }, + + onExit : function() { + ChipmunkBaseLayer.prototype.onExit.call(this); + }, + + update : function( delta ) { + this.space.step( delta ); + }, + + collisionBegin : function ( arbiter, space ) { + cc.log('collision begin'); + return true; + }, + + collisionPre : function ( arbiter, space ) { + cc.log('collision pre'); + return true; + }, + + collisionPost : function ( arbiter, space ) { + cc.log('collision post'); + }, + + collisionSeparate : function ( arbiter, space ) { + cc.log('collision separate'); + } +}); //------------------------------------------------------------------ // // Chipmunk Collision Test @@ -343,11 +438,22 @@ var ChipmunkCollisionTest = ChipmunkBaseLayer.extend( { var collTypeB = shapes[1].collision_type; cc.log( 'Collision Type A:' + collTypeA ); cc.log( 'Collision Type B:' + collTypeB ); + + //test addPostStepCallback + space.addPostStepCallback(function(){ + cc.log("post step callback 1"); + }); + space.addPostStepCallback(function(){ + cc.log("post step callback 2"); + }); return true; }, collisionPre : function ( arbiter, space ) { cc.log('collision pre'); + cc.log("arbiter e : " + arbiter.e); + cc.log("arbiter u : " +arbiter.u); + cc.log("arbiter surface_vr : " + arbiter.surface_vr.x + "," + arbiter.surface_vr.y); return true; }, @@ -1015,7 +1121,11 @@ var Joints = ChipmunkDemo.extend({ body1 = addBall(posA); body2 = addBall(posB); body2.setAngle(Math.PI); - space.addConstraint(new cp.PinJoint(body1, body2, v(15,0), v(15,0))); + var pinJoint = new cp.PinJoint(body1, body2, v(15,0), v(15,0)); + space.addConstraint(pinJoint); + cc.log("pin joint anchr1 : " + pinJoint.anchr1.x + "," + pinJoint.anchr1.y); + cc.log("pin joint anchr2 : " + pinJoint.anchr2.x + "," + pinJoint.anchr2.y); + cc.log("pin joint dist : " + pinJoint.dist); // Slide Joints - Like pin joints but with a min/max distance. // Can be used for a cheap approximation of a rope. @@ -1024,7 +1134,12 @@ var Joints = ChipmunkDemo.extend({ body1 = addBall(posA); body2 = addBall(posB); body2.setAngle(Math.PI); - space.addConstraint(new cp.SlideJoint(body1, body2, v(15,0), v(15,0), 20, 40)); + var slideJoint = new cp.SlideJoint(body1, body2, v(15,0), v(15,0), 20, 40); + space.addConstraint(slideJoint); + cc.log("slide joint anchr1 : " + slideJoint.anchr1.x + "," + slideJoint.anchr1.y); + cc.log("slide joint anchr2 : " + slideJoint.anchr2.x + "," + slideJoint.anchr2.y); + cc.log("slide joint min : " + slideJoint.min); + cc.log("slide joint max : " + slideJoint.max); // Pivot Joints - Holds the two anchor points together. Like a swivel. boxOffset = v(320, 0); @@ -1034,14 +1149,21 @@ var Joints = ChipmunkDemo.extend({ body2.setAngle(Math.PI); // cp.PivotJoint(a, b, v) takes it's anchor parameter in world coordinates. The anchors are calculated from that // Alternately, specify two anchor points using cp.PivotJoint(a, b, anch1, anch2) - space.addConstraint(new cp.PivotJoint(body1, body2, cp.v.add(boxOffset, v(80,60)))); + var pivotJoint = new cp.PivotJoint(body1, body2, cp.v.add(boxOffset, v(80,60))); + space.addConstraint(pivotJoint); + cc.log("pivot joint anchr1 : " + pivotJoint.anchr1.x + "," + pivotJoint.anchr1.y); + cc.log("pivot joint anchr2 : " + pivotJoint.anchr2.x + "," + pivotJoint.anchr2.y); // Groove Joints - Like a pivot joint, but one of the anchors is a line segment that the pivot can slide in boxOffset = v(480, 0); label('Groove Joint'); body1 = addBall(posA); body2 = addBall(posB); - space.addConstraint(new cp.GrooveJoint(body1, body2, v(30,30), v(30,-30), v(-30,0))); + var grooveJoint = new cp.GrooveJoint(body1, body2, v(30,30), v(30,-30), v(-30,0)); + space.addConstraint(grooveJoint); + cc.log("groove joint anchr2 : " + grooveJoint.anchr2.x + "," + grooveJoint.anchr2.y); + cc.log("groove joint grv_a : " +grooveJoint.grv_a.x + "," + grooveJoint.grv_a.y); + cc.log("groove joint grv_b : " +grooveJoint.grv_b.x + "," + grooveJoint.grv_b.y); // Damped Springs boxOffset = v(0, 120); @@ -1049,7 +1171,13 @@ var Joints = ChipmunkDemo.extend({ body1 = addBall(posA); body2 = addBall(posB); body2.setAngle(Math.PI); - space.addConstraint(new cp.DampedSpring(body1, body2, v(15,0), v(15,0), 20, 5, 0.3)); + var dampedSpring = new cp.DampedSpring(body1, body2, v(15,0), v(15,0), 20, 5, 0.3); + space.addConstraint(dampedSpring); + cc.log("damped spring anchr1 : " + dampedSpring.anchr1.x + "," + dampedSpring.anchr1.y); + cc.log("damped spring anchr2 : " + dampedSpring.anchr2.x + "," + dampedSpring.anchr2.y); + cc.log("damped spring damping : " + dampedSpring.damping); + cc.log("damped spring restLength : " + dampedSpring.restLength); + cc.log("damped spring stiffness : " + dampedSpring.stiffness); // Damped Rotary Springs boxOffset = v(160, 120); @@ -1059,7 +1187,11 @@ var Joints = ChipmunkDemo.extend({ // Add some pin joints to hold the circles in place. space.addConstraint(new cp.PivotJoint(body1, staticBody, POS_A())); space.addConstraint(new cp.PivotJoint(body2, staticBody, POS_B())); - space.addConstraint(new cp.DampedRotarySpring(body1, body2, 0, 3000, 60)); + var dampedRotarySpring = new cp.DampedRotarySpring(body1, body2, 0, 3000, 60); + space.addConstraint(dampedRotarySpring); + cc.log("damped rotary spring restAngle : " + dampedRotarySpring.restAngle); + cc.log("damped rotary spring stiffness : " + dampedRotarySpring.stiffness); + cc.log("damped rotary spring damping : " + dampedRotarySpring.damping); // Rotary Limit Joint boxOffset = v(320, 120); @@ -1070,7 +1202,10 @@ var Joints = ChipmunkDemo.extend({ space.addConstraint(new cp.PivotJoint(body1, staticBody, POS_A())); space.addConstraint(new cp.PivotJoint(body2, staticBody, POS_B())); // Hold their rotation within 90 degrees of each other. - space.addConstraint(new cp.RotaryLimitJoint(body1, body2, -Math.PI/2, Math.PI/2)); + var rotaryLimitJoint = new cp.RotaryLimitJoint(body1, body2, -Math.PI/2, Math.PI/2); + space.addConstraint(rotaryLimitJoint); + cc.log("rotary limit joint min : " + rotaryLimitJoint.min); + cc.log("rotary limit joint max : " + rotaryLimitJoint.max); // Ratchet Joint - A rotary ratchet, like a socket wrench boxOffset = v(480, 120); @@ -1081,7 +1216,11 @@ var Joints = ChipmunkDemo.extend({ space.addConstraint(new cp.PivotJoint(body1, staticBody, POS_A())); space.addConstraint(new cp.PivotJoint(body2, staticBody, POS_B())); // Ratchet every 90 degrees - space.addConstraint(new cp.RatchetJoint(body1, body2, 0, Math.PI/2)); + var ratchet = new cp.RatchetJoint(body1, body2, 0, Math.PI/2); + space.addConstraint(ratchet); + cc.log("ratchet phase : " + ratchet.phase); + cc.log("ratchet ratchet : " + ratchet.ratchet); + cc.log("ratchet angle : " + ratchet.angle); // Gear Joint - Maintain a specific angular velocity ratio boxOffset = v(0, 240); @@ -1092,7 +1231,10 @@ var Joints = ChipmunkDemo.extend({ space.addConstraint(new cp.PivotJoint(body1, staticBody, POS_A())); space.addConstraint(new cp.PivotJoint(body2, staticBody, POS_B())); // Force one to sping 2x as fast as the other - space.addConstraint(new cp.GearJoint(body1, body2, 0, 2)); + var gearJoint = new cp.GearJoint(body1, body2, 0, 2); + space.addConstraint(gearJoint); + cc.log("gear joint phase : " + gearJoint.phase); + cc.log("gear jonit ratio : " + gearJoint.ratio); // Simple Motor - Maintain a specific angular relative velocity boxOffset = v(160, 240); @@ -1103,7 +1245,9 @@ var Joints = ChipmunkDemo.extend({ space.addConstraint(new cp.PivotJoint(body1, staticBody, POS_A())); space.addConstraint(new cp.PivotJoint(body2, staticBody, POS_B())); // Make them spin at 1/2 revolution per second in relation to each other. - space.addConstraint(new cp.SimpleMotor(body1, body2, Math.PI)); + var simpleMotor = new cp.SimpleMotor(body1, body2, Math.PI); + space.addConstraint(simpleMotor); + cc.log("simple motor rate : " + simpleMotor.rate); // Make a car with some nice soft suspension boxOffset = v(320, 240); @@ -1584,6 +1728,7 @@ var Query = ChipmunkDemo.extend({ var end = touch.getLocation(); drawNode.drawSegment(start, end, 1, cc.color(0, 255, 0, 255)); + //segmntQueryFirst var info = target.space.segmentQueryFirst(start, end, cp.ALL_LAYERS, cp.NO_GROUP); if(info) { var point = info.hitPoint(start, end); @@ -1595,6 +1740,12 @@ var Query = ChipmunkDemo.extend({ drawNode.drawSegment(point, cp.v.add(point, cp.v.mult(info.n, 16)), 1, cc.color(0, 255, 255, 255)); } + //segmentQuery + target.space.segmentQuery(start, end, cp.ALL_LAYERS, cp.NO_GROUP, function(shape, t, n){ + cc.log("segmentQuery" + shape); + }); + + //nearestPointQueryNearest var nearestInfo = target.space.nearestPointQueryNearest(end, 100, cp.ALL_LAYERS, cp.NO_GROUP); if (nearestInfo) { drawNode.drawSegment(end, nearestInfo.p, 1, cc.color(255, 255, 0, 255)); @@ -1602,9 +1753,167 @@ var Query = ChipmunkDemo.extend({ // Draw a red bounding box around the shape under the mouse. if(nearestInfo.d < 0) target.drawBB(nearestInfo.shape.getBB(), null, cc.color(255, 0, 0, 255)); } + + //pointQuery + target.space.pointQuery(end, cp.ALL_LAYERS, cp.NO_GROUP, function(shape){ + cc.log("pointQuery" + shape); + }); + + //nearestPointQuery + target.space.nearestPointQuery(end, 100, cp.ALL_LAYERS, cp.NO_GROUP, function(shape, distance, point){ + cc.log("nearestPointQuery" + shape); + cc.log("distance:" + distance); + cc.log("nearest point:" + point.x + "," + point.y); + }); + + //bbQuery + target.space.bbQuery(cp.bb(end.x-50, end.y-50, end.x+50, end.y+50), cp.ALL_LAYERS, cp.NO_GROUP, function(shape){ + cc.log("bbQuery" + shape); + }); } }); + //------------------------------------------------------------------ + // + // LogoSmash + // + //------------------------------------------------------------------ + +var LogoSmash = (function(){ + + var image_width = 188; + var image_height = 35; + var image_row_length = 24; + + var image_bitmap = [ + 15,-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-64,15,63,-32,-2,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,31,-64,15,127,-125,-1,-128,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,127,-64,15,127,15,-1,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,-64,15,-2, + 31,-1,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,-64,0,-4,63,-1,-32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,1,-1,-64,15,-8,127,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,-1,-64,0,-8,-15,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-31,-1,-64,15,-8,-32, + -1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-15,-1,-64,9,-15,-32,-1,-32,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,31,-15,-1,-64,0,-15,-32,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,63,-7,-1,-64,9,-29,-32,127,-61,-16,63,15,-61,-1,-8,31,-16,15,-8,126,7,-31, + -8,31,-65,-7,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, + -4,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, + -2,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -2,63,-33,-1,-1,-32,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -1,63,-33,-1,-1,-16,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -1,63,-49,-1,-1,-8,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-65,-49,-1,-1,-4,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-65,-57,-1,-1,-2,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-1,-57,-1,-1,-1,9,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-61,-1,-1,-1,-119,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-61,-1,-1,-1,-55,-49,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-63,-1,-1,-1,-23,-49,-32,127,-57,-1,-1,-97,-25,-1,-1,63,-1,-1,-4,-1,15,-13, + -1,-1,-63,-1,-1,-1,-16,-49,-32,-1,-25,-1,-1,-97,-25,-1,-1,63,-33,-5,-4,-1,15, + -13,-1,-1,-64,-1,-9,-1,-7,-49,-32,-1,-25,-8,127,-97,-25,-1,-1,63,-33,-5,-4,-1, + 15,-13,-1,-1,-64,-1,-13,-1,-32,-49,-32,-1,-25,-8,127,-97,-25,-1,-2,63,-49,-13, + -4,-1,15,-13,-1,-1,-64,127,-7,-1,-119,-17,-15,-1,-25,-8,127,-97,-25,-1,-2,63, + -49,-13,-4,-1,15,-13,-3,-1,-64,127,-8,-2,15,-17,-1,-1,-25,-8,127,-97,-25,-1, + -8,63,-49,-13,-4,-1,15,-13,-3,-1,-64,63,-4,120,0,-17,-1,-1,-25,-8,127,-97,-25, + -8,0,63,-57,-29,-4,-1,15,-13,-4,-1,-64,63,-4,0,15,-17,-1,-1,-25,-8,127,-97, + -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,-1,-64,31,-2,0,0,103,-1,-1,-57,-8,127,-97, + -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,127,-64,31,-2,0,15,103,-1,-1,-57,-8,127, + -97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,127,-64,15,-8,0,0,55,-1,-1,-121,-8, + 127,-97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,63,-64,15,-32,0,0,23,-1,-2,3,-16, + 63,15,-61,-16,0,31,-127,-127,-8,31,-1,-127,-8,31,-128,7,-128,0,0 + ]; + + var get_pixel = function(x, y) + { + return (image_bitmap[(x>>3) + y*image_row_length]>>(~x&0x7)) & 1; + }; + + var make_ball = function(x, y) + { + var body = new cp.Body(1, Infinity); + body.setPos(cp.v(x, y)); + + var shape = new cp.CircleShape(body, 0.95, cp.vzero); + shape.setElasticity(0); + shape.setFriction(0); + + return shape; + }; + + return ChipmunkBaseLayer.extend({ + ctor:function(){ + this._super(); + this._title = "LogoSmash"; + this._subtitle = "Chipmunk Demo"; + + var space = this.space; + space.setIterations(1); + + // The space will contain a very large number of similary sized objects. + // This is the perfect candidate for using the spatial hash. + // Generally you will never need to do this. + // + // (... Except the spatial hash isn't implemented in JS) + // but it is implemented in JSB :) + if(cc.sys.isNative) + space.useSpatialHash(2.0, 10000); + + var batch = new cc.SpriteBatchNode(s_hole_stencil_png); + this.addChild(batch); + + var body; + var shape; + var sprite; + + for(var y=0; y' for portability (not for '#include ' + set(OPENAL_DEFINITIONS "-DOPENAL_PLAIN_INCLUDES") + endif() +endif(LINUX OR MACOSX OR WINDOWS) + +# Freetype required on all platforms +cocos_find_package(Freetype FREETYPE REQUIRED) + +# WebP required if used +if(USE_WEBP) + cocos_find_package(WebP WEBP REQUIRED) +endif(USE_WEBP) + +# Chipmunk +if(USE_CHIPMUNK) + cocos_find_package(Chipmunk CHIPMUNK REQUIRED) + add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1) + if(IOS OR MACOSX) + # without this chipmunk will try to use apple defined geometry types, that conflicts with cocos + add_definitions(-DCP_USE_CGPOINTS=0) + endif() +else(USE_CHIPMUNK) + add_definitions(-DCC_USE_PHYSICS=0) +endif(USE_CHIPMUNK) + +# Box2d (not prebuilded, exists as source) +if(USE_BOX2D) + if(USE_PREBUILT_LIBS) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/Box2D) + set(Box2D_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/box2d/include) + set(Box2D_LIBRARIES box2d) + else() + find_package(Box2D REQUIRED CONFIG) + # actually Box2D in next line is not a library, it is target exported from Box2DConfig.cmake + set(Box2D_LIBRARIES Box2D) + endif() + message(STATUS "Box2D include dirs: ${Box2D_INCLUDE_DIRS}") + add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=1) +else() + add_definitions(-DCC_ENABLE_BOX2D_INTEGRATION=0) +endif(USE_BOX2D) + +# Tinyxml2 (not prebuilded, exists as source) +if(USE_PREBUILT_LIBS) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/tinyxml2) + set(TinyXML2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/tinyxml2) + set(TinyXML2_LIBRARIES tinyxml2) +else() + cocos_find_package(TinyXML2 TinyXML2 REQUIRED) +endif() +message(STATUS "TinyXML2 include dirs: ${TinyXML2_INCLUDE_DIRS}") + +# libjpeg +cocos_find_package(JPEG JPEG REQUIRED) +cocos_find_package(ZLIB ZLIB REQUIRED) + +# minizip (we try to migrate to minizip from https://github.com/nmoinvaz/minizip) +# only msys2 currently provides package for this variant, all other +# dists have packages from zlib, thats very old for us. +# moreover our embedded version modified to quick provide +# functionality needed by cocos. +if(USE_PREBUILT_LIBS OR NOT MINGW) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/unzip) + set(MINIZIP_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/unzip) + set(MINIZIP_LIBRARIES unzip) + message(STATUS "MINIZIP include dirs: ${MINIZIP_INCLUDE_DIRS}") +else() + cocos_find_package(MINIZIP MINIZIP REQUIRED) + # double check that we have needed functions + include(CheckLibraryExists) + check_library_exists(${MINIZIP_LIBRARIES} "unzGoToFirstFile2" "" MINIZIP_HAS_GOTOFIRSTFILE2) + if(NOT MINIZIP_HAS_GOTOFIRSTFILE2) + message(FATAL_ERROR "Minizip library on you system very old. Please use recent version from https://github.com/nmoinvaz/minizip or enable USE_PREBUILT_LIBS") + endif() + add_definitions(-DMINIZIP_FROM_SYSTEM) +endif() + +cocos_find_package(PNG PNG REQUIRED) +cocos_find_package(TIFF TIFF REQUIRED) +cocos_find_package(WEBSOCKETS WEBSOCKETS REQUIRED) +cocos_find_package(CURL CURL REQUIRED) + +# protobuf-lite (not prebuilded, exists as source) +# TODO: for now we can't use upstream protobuf because these files: +# cocos/editor-support/cocostudio/CSParseBinary.pb.h +# cocos/editor-support/cocostudio/CSParseBinary.pb.cc +# was generated by concrete version of protobuf compiler +# and source file not provided. So these files can be +# compiled only with our in-source version of protobuf-lite +## if(USE_PREBUILT_LIBS) + add_subdirectory(frameworks/js-bindings/cocos2d-x/external/protobuf-lite) + set(PROTOBUF_LITE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/js-bindings/cocos2d-x/external/protobuf-lite/src) + set(PROTOBUF_LITE_LIBRARIES protobuf) +## else() +## cocos_find_package(Protobuf REQUIRED PROTOBUF_LITE_LIBRARIES) +## set(PROTOBUF_LITE_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS}) +## endif() +message(STATUS "Protobuf lite libs: ${PROTOBUF_LITE_LIBRARIES}") +message(STATUS "Protobuf include dirs: ${PROTOBUF_LITE_INCLUDE_DIRS}") + # build for 3rd party libraries if(LINUX OR APPLE) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/Box2D) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/unzip) add_subdirectory(frameworks/js-bindings/cocos2d-x/external/xxhash) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/tinyxml2) -add_subdirectory(frameworks/js-bindings/cocos2d-x/external/protobuf-lite) endif() -# cocos2d -add_subdirectory(${COCOS2D_ROOT}/cocos) +set(GAME_SRC + frameworks/runtime-src/proj.linux/main.cpp + frameworks/runtime-src/Classes/AppDelegate.cpp +) + +# cocos2d +add_subdirectory(frameworks/js-bindings/cocos2d-x/cocos) #jsbindings library add_subdirectory(frameworks/js-bindings/bindings) @@ -134,17 +288,10 @@ add_executable(${APP_NAME} ${GAME_SRC} ) -if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) -set(FMOD_LIB "fmodex64") -else() -set(FMOD_LIB "fmodex") -endif() - target_link_libraries(${APP_NAME} jsbindings cocos2d - js_static - ) +) set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin") diff --git a/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index 3050d0e3cc..0cef7170b2 100644 --- a/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -59,27 +59,41 @@ bool AppDelegate::applicationDidFinishLaunching() ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); - sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_cocos2dx_js_core); sc->addRegisterCallback(register_cocos2dx_js_extensions); + sc->addRegisterCallback(jsb_register_system); + + // extension can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + + // chipmunk can be commented out to reduce the package sc->addRegisterCallback(jsb_register_chipmunk); - sc->addRegisterCallback(jsb_register_system); + // opengl can be commented out to reduce the package sc->addRegisterCallback(JSB_register_opengl); + // builder can be commented out to reduce the package sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); - sc->addRegisterCallback(register_all_cocos2dx_ui); - sc->addRegisterCallback(register_all_cocos2dx_ui_manual); - sc->addRegisterCallback(register_all_cocos2dx_studio); - sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + // ui can be commented out to reduce the package, attension studio need ui module + sc->addRegisterCallback(register_all_cocos2dx_ui); + sc->addRegisterCallback(register_all_cocos2dx_ui_manual); + + // studio can be commented out to reduce the package, + sc->addRegisterCallback(register_all_cocos2dx_studio); + sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + // spine can be commented out to reduce the package sc->addRegisterCallback(register_all_cocos2dx_spine); sc->addRegisterCallback(register_all_cocos2dx_spine_manual); + // XmlHttpRequest can be commented out to reduce the package sc->addRegisterCallback(MinXmlHttpRequest::_js_register); + // websocket can be commented out to reduce the package sc->addRegisterCallback(register_jsb_websocket); - sc->addRegisterCallback(register_jsb_socketio); + // sokcet io can be commented out to reduce the package + sc->addRegisterCallback(register_jsb_socketio); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) sc->addRegisterCallback(JavascriptJavaBridge::_js_register); diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android/build_native.py b/templates/js-template-default/frameworks/runtime-src/proj.android/build_native.py index 370b2918a6..31c3ef4513 100755 --- a/templates/js-template-default/frameworks/runtime-src/proj.android/build_native.py +++ b/templates/js-template-default/frameworks/runtime-src/proj.android/build_native.py @@ -39,19 +39,54 @@ def check_environment_variables(): return NDK_ROOT -def select_toolchain_version(): - pass +def select_toolchain_version(ndk_root): + ret_version = "4.8" + + version_file_path = os.path.join(ndk_root, "RELEASE.TXT") + try: + versionFile = open(version_file_path) + lines = versionFile.readlines() + versionFile.close() + + version_num = None + version_char = None + pattern = r'^[a-zA-Z]+(\d+)(\w)' + for line in lines: + str_line = line.lstrip() + match = re.match(pattern, str_line) + if match: + version_num = int(match.group(1)) + version_char = match.group(2) + break + + if version_num is None: + print("Parse NDK version from file %s failed." % version_file_path) + else: + version_char = version_char.lower() + if version_num > 10 or (version_num == 10 and cmp(version_char, 'c') >= 0): + ret_version = "4.9" + + except: + print("Parse NDK version from file %s failed." % version_file_path) + + print("NDK_TOOLCHAIN_VERSION: %s" % ret_version) + if ret_version == "4.8": + print( + "Your application may crash when using c++ 11 regular expression with NDK_TOOLCHAIN_VERSION %s" % ret_version) + + return ret_version def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,build_mode): ndk_path = os.path.join(ndk_root, "ndk-build") + ndk_toolchain_version = select_toolchain_version(ndk_root) # windows should use ";" to seperate module paths platform = sys.platform if platform == 'win32': - ndk_module_path = 'NDK_MODULE_PATH=%s/..;%s;%s/external;%s/cocos' % (cocos_root, cocos_root, cocos_root, cocos_root) + ndk_module_path = 'NDK_MODULE_PATH=%s/..;%s;%s/external;%s/cocos NDK_TOOLCHAIN_VERSION=%s' % (cocos_root, cocos_root, cocos_root, cocos_root, ndk_toolchain_version) else: - ndk_module_path = 'NDK_MODULE_PATH=%s/..:%s:%s/external:%s/cocos' % (cocos_root, cocos_root, cocos_root, cocos_root) + ndk_module_path = 'NDK_MODULE_PATH=%s/..:%s:%s/external:%s/cocos NDK_TOOLCHAIN_VERSION=%s' % (cocos_root, cocos_root, cocos_root, cocos_root, ndk_toolchain_version) num_of_cpu = get_num_of_cpu() if ndk_build_param == None: @@ -108,7 +143,6 @@ def build(targets,ndk_build_param,build_mode): ndk_root = check_environment_variables() sdk_root = None - select_toolchain_version() project_root = os.path.dirname(os.path.realpath(__file__)) cocos_root = os.path.join(project_root, "..", "..", "..", "frameworks/js-bindings/cocos2d-x") diff --git a/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk b/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk index 9b48184d7a..706af60331 100644 --- a/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk +++ b/templates/js-template-default/frameworks/runtime-src/proj.android/jni/Application.mk @@ -1,8 +1,7 @@ APP_STL := gnustl_static -#use clang by default, uncomment next line to use gcc4.8 -#NDK_TOOLCHAIN_VERSION=4.8 -NDK_TOOLCHAIN_VERSION=clang +# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices +#APP_ABI := armeabi-v7a APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp b/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp index 37f4a521e6..75e27bef3e 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -25,6 +25,7 @@ #include "platform/ios/JavaScriptObjCBridge.h" #endif +#include "CodeIDESupport.h" #include "Runtime.h" #include "ConfigParser.h" @@ -33,15 +34,17 @@ using namespace CocosDenshion; AppDelegate::AppDelegate() { -#if (COCOS2D_DEBUG > 0) - // NOTE:Please don't remove this call if you want to debug with Cocos Code IDE - initRuntime(); -#endif } AppDelegate::~AppDelegate() { ScriptEngineManager::destroyInstance(); +#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0) + // NOTE:Please don't remove this call if you want to debug with Cocos Code IDE + endRuntime(); +#endif + + ConfigParser::purge(); } void AppDelegate::initGLContextAttrs() @@ -53,13 +56,17 @@ void AppDelegate::initGLContextAttrs() bool AppDelegate::applicationDidFinishLaunching() { +#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0) + // NOTE:Please don't remove this call if you want to debug with Cocos Code IDE + initRuntime(); +#endif // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { Size viewSize = ConfigParser::getInstance()->getInitViewSize(); string title = ConfigParser::getInstance()->getInitViewName(); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0) extern void createSimulator(const char* viewName, float width, float height,bool isLandscape = true, float frameZoomFactor = 1.0f); bool isLanscape = ConfigParser::getInstance()->isLanscape(); createSimulator(title.c_str(), viewSize.width,viewSize.height, isLanscape); @@ -74,27 +81,41 @@ bool AppDelegate::applicationDidFinishLaunching() ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); - sc->addRegisterCallback(register_all_cocos2dx_extension); + sc->addRegisterCallback(register_cocos2dx_js_core); sc->addRegisterCallback(register_cocos2dx_js_extensions); + sc->addRegisterCallback(jsb_register_system); + + // extension can be commented out to reduce the package + sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); + + // chipmunk can be commented out to reduce the package sc->addRegisterCallback(jsb_register_chipmunk); - sc->addRegisterCallback(jsb_register_system); + // opengl can be commented out to reduce the package sc->addRegisterCallback(JSB_register_opengl); + // builder can be commented out to reduce the package sc->addRegisterCallback(register_all_cocos2dx_builder); sc->addRegisterCallback(register_CCBuilderReader); + // ui can be commented out to reduce the package, attension studio need ui module sc->addRegisterCallback(register_all_cocos2dx_ui); sc->addRegisterCallback(register_all_cocos2dx_ui_manual); + + // studio can be commented out to reduce the package, sc->addRegisterCallback(register_all_cocos2dx_studio); sc->addRegisterCallback(register_all_cocos2dx_studio_manual); + // spine can be commented out to reduce the package sc->addRegisterCallback(register_all_cocos2dx_spine); sc->addRegisterCallback(register_all_cocos2dx_spine_manual); + // XmlHttpRequest can be commented out to reduce the package sc->addRegisterCallback(MinXmlHttpRequest::_js_register); + // websocket can be commented out to reduce the package sc->addRegisterCallback(register_jsb_websocket); - sc->addRegisterCallback(register_jsb_socketio); + // sokcet io can be commented out to reduce the package + sc->addRegisterCallback(register_jsb_socketio); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) sc->addRegisterCallback(JavascriptJavaBridge::_js_register); @@ -102,7 +123,7 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(JavaScriptObjCBridge::_js_register); #endif -#if (COCOS2D_DEBUG > 0) +#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0) // NOTE:Please don't remove this call if you want to debug with Cocos Code IDE startRuntime(); #else diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/CodeIDESupport.h b/templates/js-template-runtime/frameworks/runtime-src/Classes/CodeIDESupport.h new file mode 100644 index 0000000000..3607d3c7b3 --- /dev/null +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/CodeIDESupport.h @@ -0,0 +1,7 @@ +#ifndef __CODE_IDE_SUPPORT_H__ +#define __CODE_IDE_SUPPORT_H__ + +// define 1 to open Cocos Code IDE support, 0 to disable +#define CC_CODE_IDE_DEBUG_SUPPORT 1 + +#endif /* __CODE_IDE_SUPPORT_H__ */ diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp b/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp index c7c4129346..7aa8af57a5 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.cpp @@ -4,6 +4,7 @@ #include "json/stringbuffer.h" #include "json/writer.h" #include "ConfigParser.h" +#include "FileServer.h" #define CONFIG_FILE "config.json" #define CONSOLE_PORT 6050 @@ -13,21 +14,40 @@ #define WIN_HEIGHT 640 // ConfigParser -ConfigParser *ConfigParser::s_sharedInstance = NULL; +ConfigParser *ConfigParser::s_sharedConfigParserInstance = NULL; ConfigParser *ConfigParser::getInstance(void) { - if (!s_sharedInstance) + if (!s_sharedConfigParserInstance) { - s_sharedInstance = new ConfigParser(); - s_sharedInstance->readConfig(); + s_sharedConfigParserInstance = new ConfigParser(); + s_sharedConfigParserInstance->readConfig(); } - return s_sharedInstance; + return s_sharedConfigParserInstance; +} + +void ConfigParser::purge() +{ + CC_SAFE_DELETE(s_sharedConfigParserInstance); } void ConfigParser::readConfig() { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // add writable path to search path temporarily for reading config file + vector searchPathArray = FileUtils::getInstance()->getSearchPaths(); + searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath()); + FileUtils::getInstance()->setSearchPaths(searchPathArray); +#endif + + // read config file string fullPathFile = FileUtils::getInstance()->fullPathForFilename(CONFIG_FILE); string fileContent = FileUtils::getInstance()->getStringFromFile(fullPathFile); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // revert search path + searchPathArray.erase(searchPathArray.end() - 1); + FileUtils::getInstance()->setSearchPaths(searchPathArray); +#endif if(fileContent.empty()) return; @@ -37,7 +57,6 @@ void ConfigParser::readConfig() return; } - _docRootjson.Parse<0>(fileContent.c_str()); if (_docRootjson.HasMember("init_cfg")) { if(_docRootjson["init_cfg"].IsObject()) @@ -49,9 +68,9 @@ void ConfigParser::readConfig() _initViewSize.height = objectInitView["height"].GetUint(); if (_initViewSize.height>_initViewSize.width) { - float tmpvalue =_initViewSize.height; + float tmpvalue = _initViewSize.height; _initViewSize.height = _initViewSize.width; - _initViewSize.width = tmpvalue; + _initViewSize.width = tmpvalue; } } @@ -70,7 +89,7 @@ void ConfigParser::readConfig() if (objectInitView.HasMember("consolePort")) { _consolePort = objectInitView["consolePort"].GetUint(); - if(_consolePort<=0) + if(_consolePort <= 0) _consolePort = CONSOLE_PORT; } if (objectInitView.HasMember("debugPort")) @@ -82,7 +101,7 @@ void ConfigParser::readConfig() if (objectInitView.HasMember("uploadPort")) { _uploadPort = objectInitView["uploadPort"].GetUint(); - if(_uploadPort<=0) + if(_uploadPort <= 0) _uploadPort = UPLOAD_PORT; } if (objectInitView.HasMember("isWindowTop") && objectInitView["isWindowTop"].IsBool()) @@ -148,12 +167,10 @@ bool ConfigParser::isWindowTop() { return _isWindowTop; } - int ConfigParser::getConsolePort() { return _consolePort; } - int ConfigParser::getUploadPort() { return _uploadPort; diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h b/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h index 1c822d3d71..44fb8f52ab 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/ConfigParser.h @@ -27,6 +27,7 @@ class ConfigParser { public: static ConfigParser *getInstance(void); + static void purge(); // predefined screen size int getScreenSizeCount(void); @@ -44,7 +45,7 @@ class ConfigParser private: void readConfig(); ConfigParser(void); - static ConfigParser *s_sharedInstance; + static ConfigParser *s_sharedConfigParserInstance; ScreenSizeArray _screenSizeArray; cocos2d::Size _initViewSize; string _viewName; diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConnectWaitLayer.cpp b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConnectWaitLayer.cpp new file mode 100644 index 0000000000..8c4ef38657 --- /dev/null +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConnectWaitLayer.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +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 "ConnectWaitLayer.h" +#include "Runtime.h" +#include "FileServer.h" +#include "ConfigParser.h" +#include "VisibleRect.h" +#include "ResData.h" + +using namespace cocos2d; + +ConnectWaitLayer::ConnectWaitLayer() +{ + int designWidth = 1280; + int designHeight = 800; + _imagebg = new Image(); + + if (ConfigParser::getInstance()->isLanscape()) + { + _imagebg->initWithImageData(__landscapePngData, sizeof(__landscapePngData)); + Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designWidth, designHeight, ResolutionPolicy::EXACT_FIT); + } else + { + _imagebg->initWithImageData(__portraitPngData, sizeof(__portraitPngData)); + Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designHeight, designWidth, ResolutionPolicy::FIXED_HEIGHT); + } + Texture2D* texturebg = Director::getInstance()->getTextureCache()->addImage(_imagebg, "play_background"); + auto background = Sprite::createWithTexture(texturebg); + background->setAnchorPoint(Vec2(0.5, 0.5)); + background->setPosition(VisibleRect::center()); + addChild(background, 9000); + + // variable of below is"play" button position. + int portraitX = 400; + int portraitY = 500; + int lanscaptX = 902; + int lanscaptY = 400; + _imageplay = new Image(); + _imageplay->initWithImageData(__playEnablePngData, sizeof(__playEnablePngData)); + Texture2D* textureplay = Director::getInstance()->getTextureCache()->addImage(_imageplay, "play_enable"); + auto playSprite = Sprite::createWithTexture(textureplay); + addChild(playSprite, 9999); + + _imageShine = new Image(); + _imageShine->initWithImageData(__shinePngData, sizeof(__shinePngData)); + Texture2D* textureShine = Director::getInstance()->getTextureCache()->addImage(_imageShine, "shine"); + auto shineSprite = Sprite::createWithTexture(textureShine); + shineSprite->setOpacity(0); + Vector arrayOfActions; + arrayOfActions.pushBack(DelayTime::create(0.4f)); + arrayOfActions.pushBack(FadeTo::create(0.8f, 200)); + arrayOfActions.pushBack(FadeTo::create(0.8f, 255)); + arrayOfActions.pushBack(FadeTo::create(0.8f, 200)); + arrayOfActions.pushBack(FadeTo::create(0.8f, 0)); + arrayOfActions.pushBack(DelayTime::create(0.4f)); + shineSprite->runAction(RepeatForever::create(Sequence::create(arrayOfActions))); + addChild(shineSprite, 9998); + + std::string strip = getIPAddress(); + char szIPAddress[64] = {0}; + sprintf(szIPAddress, "IP: %s", strip.c_str()); + auto IPlabel = Label::createWithSystemFont(szIPAddress, "", 72); + IPlabel->setAnchorPoint(Vec2(0, 0)); + int spaceSizex = 72; + int spaceSizey = 200; + IPlabel->setPosition(Point(VisibleRect::leftTop().x + spaceSizex, VisibleRect::top().y - spaceSizey)); + addChild(IPlabel, 9001); + + std::string transferTip = "waiting for file transfer ..."; + if (CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM || CC_PLATFORM_MAC == CC_TARGET_PLATFORM) + { + transferTip = "waiting for debugger to connect ..."; + } + + char szVersion[256] = {0}; + sprintf(szVersion, "runtimeVersion:%s \nengineVersion:%s", getRuntimeVersion(), ENGINE_VERSION); + Label* verLable = Label::createWithSystemFont(szVersion, "", 24); + verLable->setAnchorPoint(Vec2(0, 0)); + int width = verLable->getBoundingBox().size.width; + verLable->setPosition(Point(VisibleRect::right().x - width, VisibleRect::rightBottom().y)); + verLable->setAlignment(TextHAlignment::LEFT); + addChild(verLable, 9002); + _labelUploadFile = Label::createWithSystemFont(transferTip, "", 36); + _labelUploadFile->setAnchorPoint(Vec2(0, 0)); + _labelUploadFile->setPosition(Point(VisibleRect::leftTop().x + spaceSizex, IPlabel->getPositionY()- spaceSizex)); + _labelUploadFile->setAlignment(TextHAlignment::LEFT); + addChild(_labelUploadFile, 9003); + + if (ConfigParser::getInstance()->isLanscape()) + { + playSprite->setPosition(lanscaptX, lanscaptY); + shineSprite->setPosition(lanscaptX, lanscaptY); + } + else + { + playSprite->setPosition(portraitX, portraitY); + shineSprite->setPosition(portraitX, portraitY); + } + + auto listener = EventListenerTouchOneByOne::create(); + listener->onTouchBegan = [](Touch* touch, Event *event)->bool{ + auto target = static_cast(event->getCurrentTarget()); + Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); + auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height); + if (!rect.containsPoint(point)) return false; + target->stopAllActions(); + target->runAction(Sequence::createWithTwoActions(ScaleBy::create(0.05f, 0.9f), ScaleTo::create(0.125f, 1))); + return true; + }; + listener->onTouchEnded = [](Touch* touch, Event *event){ + auto target = static_cast(event->getCurrentTarget()); + Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); + auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height); + if (!rect.containsPoint(point)) return; + startScript(); + }; + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, playSprite); + + this->scheduleUpdate(); +} + +ConnectWaitLayer::~ConnectWaitLayer() +{ + CC_SAFE_DELETE(_imagebg); + CC_SAFE_DELETE(_imageplay); + CC_SAFE_DELETE(_imageShine); +} + +// clean up: ignore stdin, stdout and stderr +void ConnectWaitLayer::update(float fDelta) +{ + std::string transferTip = FileServer::getShareInstance()->getTransingFileName(); + if (transferTip.empty()){ + return; + } + _labelUploadFile->setString(transferTip); +} diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConnectWaitLayer.h b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConnectWaitLayer.h new file mode 100644 index 0000000000..6d96921e9e --- /dev/null +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConnectWaitLayer.h @@ -0,0 +1,46 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +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 _CONNECT_WAIT_LAYER__H_ +#define _CONNECT_WAIT_LAYER__H_ + +#include "cocos2d.h" + +class ConnectWaitLayer: public cocos2d::Layer +{ +public: + ConnectWaitLayer(); + ~ConnectWaitLayer(); + void update(float fDelta); + +private: + cocos2d::Image* _imagebg; + cocos2d::Image* _imageplay; + cocos2d::Image* _imageShine; + + cocos2d::Label* _labelUploadFile; +}; + +#endif // _CONNECT_WAIT_LAYER__H_ + diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConsoleCommand.cpp b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConsoleCommand.cpp new file mode 100644 index 0000000000..7e9954e6b9 --- /dev/null +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConsoleCommand.cpp @@ -0,0 +1,305 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +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 "Runtime.h" +#include "ConfigParser.h" +#include "ConsoleCommand.h" +#include "json/document.h" +#include "json/filestream.h" +#include "json/stringbuffer.h" + +#include "cocos2d_specifics.hpp" + +#include "cocos2d.h" +using namespace cocos2d; + +bool reloadScript(const string& file) +{ + auto director = Director::getInstance(); + FontFNT::purgeCachedData(); + if (director->getOpenGLView()) + { + SpriteFrameCache::getInstance()->removeSpriteFrames(); + director->getTextureCache()->removeAllTextures(); + } + FileUtils::getInstance()->purgeCachedEntries(); + + //director->getScheduler()->unscheduleAll(); + //director->getScheduler()->scheduleUpdate(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false); + + string modulefile = file; + if (modulefile.empty()) + { + modulefile = ConfigParser::getInstance()->getEntryFile().c_str(); + } + + return ScriptingCore::getInstance()->runScript(modulefile.c_str()); +} + +ConsoleCommand* ConsoleCommand::s_sharedConsoleCommand = nullptr; +ConsoleCommand* ConsoleCommand::getShareInstance() +{ + if (s_sharedConsoleCommand == nullptr) + { + s_sharedConsoleCommand = new ConsoleCommand(); + } + return s_sharedConsoleCommand; +} + +void ConsoleCommand::purge() +{ + if (s_sharedConsoleCommand != nullptr) + { + delete s_sharedConsoleCommand; + } +} + +void ConsoleCommand::init() +{ + cocos2d::Console *_console = Director::getInstance()->getConsole(); + static struct Console::Command commands[] = + { + {"sendrequest","send command to runtime.Args[json format]",std::bind(&ConsoleCommand::onSendCommand, this, std::placeholders::_1, std::placeholders::_2)}, + }; + for (int i = 0;i< sizeof(commands) / sizeof(Console::Command);i++) + { + _console->addCommand(commands[i]); + } +#if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM) + _console->listenOnTCP(ConfigParser::getInstance()->getConsolePort()); +#else + _console->listenOnTCP(6050); +#endif + + _fileserver = FileServer::getShareInstance(); +#if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM) + _fileserver->listenOnTCP(ConfigParser::getInstance()->getUploadPort()); +#else + _fileserver->listenOnTCP(6060); +#endif + _fileserver->readResFileFinfo(); +} + +void ConsoleCommand::onSendCommand(int fd, const std::string &args) +{ + Director::getInstance()->getScheduler()->performFunctionInCocosThread([=](){ + rapidjson::Document dArgParse; + dArgParse.Parse<0>(args.c_str()); + if (dArgParse.HasMember("cmd")) + { + string strcmd = dArgParse["cmd"].GetString(); + + rapidjson::Document dReplyParse; + dReplyParse.SetObject(); + dReplyParse.AddMember("cmd",strcmd.c_str(),dReplyParse.GetAllocator()); + if (dArgParse.HasMember("seq")) + { + dReplyParse.AddMember("seq",dArgParse["seq"],dReplyParse.GetAllocator()); + } + + if (strcmp(strcmd.c_str(), "start-logic") == 0) + { + if (startScript()) + { + dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); + }else + { + dReplyParse.AddMember("code",1,dReplyParse.GetAllocator()); + } + + } else if (strcmp(strcmd.c_str(),"clearcompile")==0) + { + if (dArgParse.HasMember("modulefiles") && dArgParse["modulefiles"].Size() != 0) + { + const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; + for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) + { + ScriptingCore::getInstance()->cleanScript(objectfiles[i].GetString()); + } + } else + { + std::unordered_map filenameScript = ScriptingCore::getInstance()->getFileScript(); + filenameScript.clear(); + } + + dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); + } else if(strcmp(strcmd.c_str(),"precompile")==0) + { + const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; + for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) + { + ScriptingCore::getInstance()->compileScript(objectfiles[i].GetString()); + } + + dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); + } else if(strcmp(strcmd.c_str(),"reload")==0) + { + if (dArgParse.HasMember("modulefiles")){ + rapidjson::Value bodyvalue(rapidjson::kObjectType); + const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; + for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++){ + if (!reloadScript(objectfiles[i].GetString())) { + bodyvalue.AddMember(objectfiles[i].GetString(),1,dReplyParse.GetAllocator()); + } + } + if (0 == objectfiles.Size()) + { + reloadScript(""); + } + dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); + }else + { + reloadScript(""); + } + dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); + } else if(strcmp(strcmd.c_str(), "getversion") == 0) + { + rapidjson::Value bodyvalue(rapidjson::kObjectType); + bodyvalue.AddMember("version", getRuntimeVersion(), dReplyParse.GetAllocator()); + dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); + dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); + } else if(strcmp(strcmd.c_str(), "getfileinfo") == 0) + { + rapidjson::Value bodyvalue(rapidjson::kObjectType); + rapidjson::Document* filecfgjson = _fileserver->getFileCfgJson(); + for (auto it = filecfgjson->MemberonBegin(); it != filecfgjson->MemberonEnd(); ++it) + { + bodyvalue.AddMember(it->name.GetString(), it->value.GetString(), dReplyParse.GetAllocator()); + } + dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); + dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); + + } else if (strcmp(strcmd.c_str(), "getEntryfile") == 0) + { + rapidjson::Value bodyvalue(rapidjson::kObjectType); + rapidjson::Value entryFileValue(rapidjson::kStringType); + entryFileValue.SetString(ConfigParser::getInstance()->getEntryFile().c_str(), dReplyParse.GetAllocator()); + bodyvalue.AddMember("entryfile", entryFileValue, dReplyParse.GetAllocator()); + dReplyParse.AddMember("body", bodyvalue,dReplyParse.GetAllocator()); + dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); + } else if(strcmp(strcmd.c_str(), "getIP") == 0) + { + rapidjson::Value bodyvalue(rapidjson::kObjectType); + rapidjson::Value IPValue(rapidjson::kStringType); + IPValue.SetString(getIPAddress().c_str(), dReplyParse.GetAllocator()); + bodyvalue.AddMember("IP", IPValue,dReplyParse.GetAllocator()); + dReplyParse.AddMember("body", bodyvalue,dReplyParse.GetAllocator()); + dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); + + } else if(strcmp(strcmd.c_str(), "remove") == 0) + { + if (dArgParse.HasMember("files")) + { + rapidjson::Value bodyvalue(rapidjson::kObjectType); + const rapidjson::Value& objectfiles = dArgParse["files"]; + const char* filename = NULL; + for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) + { + filename = objectfiles[i].GetString(); + + // remove js compiled script + ScriptingCore::getInstance()->cleanScript(filename); + + // remove file from disk + string filepath(_fileserver->getWritePath() + "/" + filename); + if (FileUtils::getInstance()->isFileExist(filepath)) + { + if(remove(filepath.c_str()) != 0) + { + // remove failed + bodyvalue.AddMember(filename, 2, dReplyParse.GetAllocator()); + } + } else + { + // file not exist + bodyvalue.AddMember(filename, 1, dReplyParse.GetAllocator()); + } + + // file remove success, remove it from record + if (! FileUtils::getInstance()->isFileExist(filepath)) + _fileserver->removeResFileInfo(filename); + } + + dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); + } + + dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); + } else if(strcmp(strcmd.c_str(), "shutdownapp") == 0) + { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + extern void shutDownApp(); + shutDownApp(); +#else + exit(0); +#endif + } else if(strcmp(strcmd.c_str(), "getplatform") == 0) + { + string platform="UNKNOW"; +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + platform = "WIN32"; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + platform = "MAC"; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + platform = "IOS"; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + platform = "ANDROID"; +#endif + rapidjson::Value bodyvalue(rapidjson::kObjectType); + rapidjson::Value platformValue(rapidjson::kStringType); + platformValue.SetString(platform.c_str(), dReplyParse.GetAllocator()); + bodyvalue.AddMember("platform", platformValue, dReplyParse.GetAllocator()); + dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); + dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); + } else if(strcmp(strcmd.c_str(), "usewritablepath") == 0) + { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // only iOS and Android need to open using write path by Code IDE + FileServer::getShareInstance()->setIsUsingWritePath(true); + + std::vector searchPathArray = FileUtils::getInstance()->getSearchPaths(); + searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath()); + FileUtils::getInstance()->setSearchPaths(searchPathArray); +#endif + + dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); + } + + rapidjson::StringBuffer buffer; + rapidjson::Writer< rapidjson::StringBuffer > writer(buffer); + dReplyParse.Accept(writer); + string msgContent = buffer.GetString(); + char msgLength[64] = {0x1, 0}; + sprintf(msgLength + 1, "%d:", msgContent.size()); + + string msg(msgLength + msgContent); + + sendBuf(fd, msg.c_str(), msg.size()); + } + }); +} + +ConsoleCommand::~ConsoleCommand() +{ + Director::getInstance()->getConsole()->stop(); +} diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConsoleCommand.h b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConsoleCommand.h new file mode 100644 index 0000000000..0bda4f82b7 --- /dev/null +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/ConsoleCommand.h @@ -0,0 +1,46 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +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 _CONSOLE_COMMAND__H_ +#define _CONSOLE_COMMAND__H_ + +#include "FileServer.h" + +class ConsoleCommand +{ + static ConsoleCommand *s_sharedConsoleCommand; + +public: + static ConsoleCommand* getShareInstance(); + static void purge(); + + void init(); + void onSendCommand(int fd, const std::string &args); +private: + ~ConsoleCommand(); + FileServer* _fileserver; +}; + +#endif // _CONSOLE_COMMAND__H_ + diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/FileServer.cpp b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/FileServer.cpp new file mode 100644 index 0000000000..ba4217e3db --- /dev/null +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/FileServer.cpp @@ -0,0 +1,545 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +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 "FileServer.h" +#include "Runtime.h" +#include "zlib.h" + +// header files for directory operation +#ifdef _WIN32 +#include +#else +#include +#endif + +USING_NS_CC; + +//1M size +#define MAXPROTOLENGTH 1048576 + +#define PROTO_START "RuntimeSend:" + +FileServer* FileServer::s_sharedFileServer = nullptr; +FileServer* FileServer::getShareInstance() +{ + if (s_sharedFileServer == nullptr) + { + s_sharedFileServer = new FileServer; + } + return s_sharedFileServer; +} + +void FileServer::purge() +{ + CC_SAFE_DELETE(s_sharedFileServer); +} + +void FileServer::readResFileFinfo() +{ + std::string filecfg = _writePath + "/fileinfo_debug.json"; + FILE * pFile = fopen (filecfg.c_str() , "r"); + if(pFile) + { + rapidjson::FileStream inputStream(pFile); + _filecfgjson.ParseStream<0>(inputStream); + fclose(pFile); + } + if(! _filecfgjson.IsObject()){ + _filecfgjson.SetObject(); + } + + //save file info to disk every five second + Director::getInstance()->getScheduler()->schedule([&](float){ + rapidjson::StringBuffer buffer; + rapidjson::Writer< rapidjson::StringBuffer > writer(buffer); + _filecfgjson.Accept(writer); + const char* str = buffer.GetString(); + std::string filecfg = _writePath + "/fileinfo_debug.json"; + FILE * pFile = fopen(filecfg.c_str(), "w"); + if (!pFile) return ; + fwrite(str, sizeof(char), strlen(str), pFile); + fclose(pFile); + },this, 5.0f, false, "fileinfo"); +} + +void FileServer::addResFileInfo(const char* filename, uint64_t u64) +{ + if(_filecfgjson.HasMember(filename)){ + _filecfgjson.RemoveMember(filename); + } + char filetime[512]= {0}; + sprintf(filetime, "%llu", u64); + rapidjson::Value filetimeValue(rapidjson::kStringType); + filetimeValue.SetString(filetime, _filecfgjson.GetAllocator()); + rapidjson::Value filenameValue(rapidjson::kStringType); + filenameValue.SetString(filename,_filecfgjson.GetAllocator()); + _filecfgjson.AddMember(filenameValue.GetString(), filetimeValue, _filecfgjson.GetAllocator()); +} + +void FileServer::removeResFileInfo(const char *filename) +{ + if (_filecfgjson.HasMember(filename)) { + _filecfgjson.RemoveMember(filename); + } +} + +std::string FileServer::getTransingFileName() +{ + _fileNameMutex.lock(); + std::string filename = _strFileName; + _fileNameMutex.unlock(); + return filename; +} + +void FileServer::setTransingFileName(const std::string &filename) +{ + _fileNameMutex.lock(); + _strFileName = filename; + _fileNameMutex.unlock(); +} + +bool FileServer::listenOnTCP(int port) +{ + int listenfd, n; + const int on = 1; + struct addrinfo hints, *res, *ressave; + char serv[30]; + + snprintf(serv, sizeof(serv)-1, "%d", port ); + serv[sizeof(serv)-1]=0; + + bzero(&hints, sizeof(struct addrinfo)); + hints.ai_flags = AI_PASSIVE; + hints.ai_family = AF_INET; // AF_UNSPEC: Do we need IPv6 ? + hints.ai_socktype = SOCK_STREAM; + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + WSADATA wsaData; + n = WSAStartup(MAKEWORD(2, 2),&wsaData); +#endif + + if ( (n = getaddrinfo(NULL, serv, &hints, &res)) != 0) { + fprintf(stderr,"net_listen error for %s: %s", serv, gai_strerror(n)); + return false; + } + + ressave = res; + do { + listenfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + if (listenfd < 0) + continue; /* error, try next one */ + + setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)); + //setsockopt(listenfd, IPPROTO_TCP, TCP_NODELAY, (const char*)&on, sizeof(on)); + if (::bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) + break; /* success */ + + /* bind error, close and try next one */ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + closesocket(listenfd); +#else + close(listenfd); +#endif + } while ((res = res->ai_next) != NULL); + + if (res == NULL) + { + perror("net_listen:"); + freeaddrinfo(ressave); + return false; + } + + listen(listenfd, 1); + + if (res->ai_family == AF_INET) + { + char buf[INET_ADDRSTRLEN] = ""; + struct sockaddr_in *sin = (struct sockaddr_in*) res->ai_addr; + if( inet_ntop(res->ai_family, &sin->sin_addr, buf, sizeof(buf)) != NULL ) + cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin_port)); + else + perror("inet_ntop"); + } else if (res->ai_family == AF_INET6) + { + char buf[INET6_ADDRSTRLEN] = ""; + struct sockaddr_in6 *sin = (struct sockaddr_in6*) res->ai_addr; + if( inet_ntop(res->ai_family, &sin->sin6_addr, buf, sizeof(buf)) != NULL ) + cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port)); + else + perror("inet_ntop"); + } + freeaddrinfo(ressave); + _listenfd = listenfd; + _receiveThread = std::thread(std::bind( &FileServer::loopReceiveFile, this)); + _writeThread = std::thread(std::bind(&FileServer::loopWriteFile, this)); + _responseThread = std::thread(std::bind(&FileServer::loopResponse, this)); + return true; +} + +void FileServer::stop() +{ + _receiveEndThread = true; + _writeEndThread = true; + _responseEndThread = true; + + if(_receiveRunning) + { + _receiveThread.join(); + } + + if (_writeRunning) + { + _writeThread.join(); + } + + if (_responseRunning) + { + _responseThread.join(); + } +} + +FileServer::FileServer() : +_listenfd(-1), +_receiveRunning(false), +_receiveEndThread(false), +_writeRunning(false), +_writeEndThread(false), +_responseRunning(false), +_responseEndThread(false) +{ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + // need to be opened by Code IDE + _isUsingWritePath = false; +#else + _isUsingWritePath = true; +#endif + + _writePath = FileUtils::getInstance()->getWritablePath(); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + std::string getCurAppName(void); + _writePath += getCurAppName(); + _writePath += "/"; +#endif + + _writePath += "debugruntime/"; + + _writePath = replaceAll(_writePath, "\\", "/"); + if (_writePath.at(_writePath.length() - 1) != '/'){ + _writePath.append("/"); + } +} + +FileServer::~FileServer() +{ + stop(); +} + +void FileServer::loopReceiveFile() +{ + struct sockaddr client; + socklen_t client_len; + + /* new client */ + client_len = sizeof(client); + int fd = accept(_listenfd, (struct sockaddr *)&client, &client_len ); + char *protoBuf = new char[MAXPROTOLENGTH]; + + while(!_receiveEndThread) { + + // recv start flag + char startflag[13] = {0}; + recvBuf(fd, startflag, sizeof(startflag) - 1); + if (strcmp(startflag, PROTO_START) != 0) + { + continue; + } + + // recv proto num + union + { + char char_type[3]; + unsigned short uint16_type; + }protonum; + recvBuf(fd, protonum.char_type, sizeof(protonum.char_type) - 1); + //recv protobuf length + union + { + char char_type[3]; + unsigned short uint16_type; + }protolength; + recvBuf(fd, protolength.char_type, sizeof(protolength.char_type) - 1); + + //recv variable length + memset(protoBuf, 0, MAXPROTOLENGTH); + recvBuf(fd, protoBuf, protolength.uint16_type); + + RecvBufStruct recvDataBuf; + recvDataBuf.fd = fd; + recvDataBuf.fileProto.ParseFromString(protoBuf); + if (1 == recvDataBuf.fileProto.package_seq()) + { + _recvErrorFile = ""; + } else + { + // recv error + if (_recvErrorFile == recvDataBuf.fileProto.file_name()) + { + continue; + } + } + unsigned long contentSize = recvDataBuf.fileProto.content_size(); + if (contentSize == 0) + { + recvDataBuf.contentBuf=""; + _recvBufListMutex.lock(); + _recvBufList.push_back(recvDataBuf); + _recvBufListMutex.unlock(); + }else if(contentSize > 0) + { + //recv body data + Bytef *contentbuf = new Bytef[contentSize+1]; + memset(contentbuf, 0, contentSize+1); + unsigned long recvTotalLen = contentSize; + while (recvTotalLen != 0){ + unsigned long recvLen = MAXPROTOLENGTH; + if(recvTotalLen < MAXPROTOLENGTH) + recvLen = recvTotalLen; + memset(protoBuf, 0, MAXPROTOLENGTH); + unsigned long result = recv(fd, protoBuf, recvLen,0); + if (result <= 0) + { + usleep(1); + continue; + } + memcpy(contentbuf + contentSize - recvTotalLen, protoBuf, result); + recvTotalLen -= result; + } + + if (recvDataBuf.fileProto.compress_type() == runtime::FileSendProtos_CompressType::FileSendProtos_CompressType_ZIP){ + unsigned long uncompressSize = recvDataBuf.fileProto.uncompress_size(); + Bytef *buff = new Bytef[uncompressSize * sizeof(Bytef)]; + memset(buff, 0, uncompressSize * sizeof(Bytef)); + int err = ::uncompress(buff, &uncompressSize,contentbuf, contentSize * sizeof(Bytef)); + if (err != Z_OK){ + CC_SAFE_DELETE_ARRAY(buff); + CC_SAFE_DELETE_ARRAY(contentbuf); + addResponse(recvDataBuf.fd, recvDataBuf.fileProto.file_name(), runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_UNCOMPRESS_ERROR, err); + continue; + } + CC_SAFE_DELETE_ARRAY(contentbuf); + contentbuf = buff; + contentSize = uncompressSize; + } + recvDataBuf.contentBuf.assign((const char*)contentbuf, contentSize); + CC_SAFE_DELETE_ARRAY(contentbuf); + + _recvBufListMutex.lock(); + _recvBufList.push_back(recvDataBuf); + _recvBufListMutex.unlock(); + } + } + + _receiveRunning = false; + + CC_SAFE_DELETE_ARRAY(protoBuf); +} + +void FileServer::loopWriteFile() +{ + _writeRunning = true; + while(!_writeEndThread) + { + _recvBufListMutex.lock(); + size_t recvSize = _recvBufList.size(); + _recvBufListMutex.unlock(); + if(0 == recvSize) + { + usleep(500); + continue; + } + + _recvBufListMutex.lock(); + RecvBufStruct recvDataBuf = _recvBufList.front(); + _recvBufList.pop_front(); + _recvBufListMutex.unlock(); + std::string filename = recvDataBuf.fileProto.file_name(); + std::string fullfilename = _writePath; + fullfilename += filename; + _fileNameMutex.lock(); + _strFileName = filename; + _fileNameMutex.unlock(); + //cocos2d::log("WriteFile:: fullfilename = %s",filename.c_str()); + createDir(fullfilename.substr(0, fullfilename.find_last_of("/")).c_str()); + + FILE *fp= nullptr; + if (1 == recvDataBuf.fileProto.package_seq()) + { + _writeErrorFile =""; + fp = fopen(fullfilename.c_str(), "wb"); + } else + { + if (_writeErrorFile == filename) + { + continue; + } + fp=fopen(fullfilename.c_str(), "ab"); + } + if (nullptr == fp) + { + addResponse(recvDataBuf.fd, filename, runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FOPEN_ERROR, errno); + continue; + } + if (fp) + { + if (recvDataBuf.contentBuf.size() > 0 && 0 == fwrite(recvDataBuf.contentBuf.c_str(), sizeof(char), recvDataBuf.contentBuf.size(), fp)) + { + addResponse(recvDataBuf.fd, filename, runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FWRITE_ERROR, errno); + fclose(fp); + continue; + } + fclose(fp); + } + + if (1 == recvDataBuf.fileProto.package_seq()) + { + //record new file modify + addResFileInfo(filename.c_str(), recvDataBuf.fileProto.modified_time()); + addResponse(recvDataBuf.fd, filename, runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_SUCCESS, 0); + } + } + + _writeRunning = false; +} + +void FileServer::addResponse(int fd, std::string filename, int errortype, int errornum) +{ + switch (errortype) + { + case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_UNCOMPRESS_ERROR: + case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_RECV_ERROR: + _recvErrorFile = filename; + break; + case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FOPEN_ERROR: + case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FWRITE_ERROR: + _writeErrorFile = filename; + break; + default: + break; + } + + ResponseStruct responseBuf; + responseBuf.fd = fd; + responseBuf.fileResponseProto.set_file_name(filename.c_str()); + responseBuf.fileResponseProto.set_result((::runtime::FileSendComplete_RESULTTYPE)errortype); + responseBuf.fileResponseProto.set_error_num(errornum); + + // push Response struct + _responseBufListMutex.lock(); + _responseBufList.push_back(responseBuf); + _responseBufListMutex.unlock(); +} + +void FileServer::loopResponse() +{ + _responseRunning = true; + while(!_responseEndThread) { + _responseBufListMutex.lock(); + size_t responseSize = _responseBufList.size(); + _responseBufListMutex.unlock(); + if(0 == responseSize) + { + usleep(500); + /* error */ + continue; + } + + _responseBufListMutex.lock(); + ResponseStruct responseBuf = _responseBufList.front(); + _responseBufList.pop_front(); + _responseBufListMutex.unlock(); + //send response + std::string responseString; + runtime::FileSendComplete fileSendProtoComplete; + fileSendProtoComplete.set_file_name(responseBuf.fileResponseProto.file_name()); + fileSendProtoComplete.set_result(responseBuf.fileResponseProto.result()); + fileSendProtoComplete.set_error_num(responseBuf.fileResponseProto.error_num()); + fileSendProtoComplete.SerializeToString(&responseString); + char dataBuf[1024] = {0}; + struct ResponseHeaderStruct + { + char startFlag[12]; + unsigned short protoNum; + unsigned short protoBufLen; + }; + ResponseHeaderStruct responseHeader; + strcpy(responseHeader.startFlag, PROTO_START); + responseHeader.protoNum = PROTONUM::FILESENDCOMPLETE; + responseHeader.protoBufLen = (unsigned short) responseString.size(); + memcpy(dataBuf, &responseHeader, sizeof(responseHeader)); + memcpy(dataBuf + sizeof(responseHeader), responseString.c_str(), responseString.size()); + + sendBuf(responseBuf.fd, dataBuf, sizeof(responseHeader) + responseString.size()); + cocos2d::log("responseFile:%s,result:%d", fileSendProtoComplete.file_name().c_str(), fileSendProtoComplete.result()); + } + + _responseRunning = false; +} + +bool createDir(const char *sPathName) +{ + char DirName[256]={0}; + strcpy(DirName, sPathName); + size_t i, len = strlen(DirName); + if(DirName[len - 1] != '/') + { + strcat(DirName, "/"); + } + + len = strlen(DirName); + for(i = 1; i < len; i++) + { + if(DirName[i] == '/') + { + DirName[i] = 0; +#ifdef _WIN32 + if(_access(DirName, 0) != 0) + { + if(_mkdir(DirName/*, 0755*/) == -1) +#else + if (access(DirName, 0) != 0) + { + if(mkdir(DirName, 0755) == -1) +#endif + { + perror("mkdir error"); + return false; + } + } + DirName[i] = '/'; + } + } + + return true; +} diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/FileServer.h b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/FileServer.h new file mode 100644 index 0000000000..026c068f8f --- /dev/null +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/FileServer.h @@ -0,0 +1,136 @@ +/**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +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 _FILE_SERVER__H_ +#define _FILE_SERVER__H_ + +#include "cocos2d.h" +#include "json/document.h" +#include "json/filestream.h" +#include "json/stringbuffer.h" +#include "json/writer.h" +#include "Protos.pb.h" +#include + +// header files for socket +#ifdef _WIN32 +#include +#include + +#define bzero(a, b) memset(a, 0, b); + +#else +#include +#include +#include +#include +#endif + +#ifdef _WIN32 +#define usleep(t) Sleep(t) +#else +#include +#endif + +class FileServer +{ + static FileServer *s_sharedFileServer; +public: + static FileServer* getShareInstance(); + static void purge(); + + bool listenOnTCP(int port); + void stop(); + + void readResFileFinfo(); + void addResFileInfo(const char* filename,uint64_t u64); + void removeResFileInfo(const char *filename); + rapidjson::Document* getFileCfgJson() { return &_filecfgjson; } + bool getIsUsingWritePath() { return _isUsingWritePath; } + void setIsUsingWritePath(bool use) { _isUsingWritePath = use; } + std::string getWritePath() { return _writePath; } + std::string getTransingFileName(); + void setTransingFileName(const std::string& filename); +protected: + FileServer(); + ~FileServer(); +private: + void loopReceiveFile(); + void loopWriteFile(); + void loopResponse(); + void addResponse(int fd, std::string filename,int errortype,int errornum); + enum PROTONUM + { + FILEPROTO = 1, + FILESENDCOMPLETE = 2, + DIRPROTO = 3, + DIRSENDCOMPLETE = 4 + }; + + struct RecvBufStruct + { + runtime::FileSendProtos fileProto; + std::string contentBuf; + int fd; + }; + + struct ResponseStruct + { + runtime::FileSendComplete fileResponseProto; + int fd; + }; + + // file descriptor: socket, console, etc. + int _listenfd; + std::thread _responseThread; + std::thread _receiveThread; + std::thread _writeThread; + bool _receiveRunning; + bool _receiveEndThread; + bool _writeRunning; + bool _writeEndThread; + bool _responseRunning; + bool _responseEndThread; + + std::list _recvBufList; + std::list _responseBufList; + std::mutex _recvBufListMutex; + std::mutex _responseBufListMutex; + + rapidjson::Document _filecfgjson; + + std::string _strFileName; + std::mutex _fileNameMutex; + + std::string _recvErrorFile; + std::string _writeErrorFile; + + bool _isUsingWritePath; + std::string _writePath; +}; + +bool createDir(const char *sPathName); + +#endif // _FILE_SERVER__H_ + diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp index 9060e8ce21..22ea6b1bbb 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp @@ -23,386 +23,19 @@ THE SOFTWARE. ****************************************************************************/ #include "Runtime.h" +#include "FileServer.h" +#include "ConnectWaitLayer.h" +#include "ConsoleCommand.h" -#include "SimpleAudioEngine.h" -#include "jsb_cocos2dx_auto.hpp" -#include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_builder_auto.hpp" -#include "extension/jsb_cocos2dx_extension_manual.h" -#include "cocosbuilder/js_bindings_ccbreader.h" -#include "localstorage/js_bindings_system_registration.h" -#include "chipmunk/js_bindings_chipmunk_registration.h" -#include "jsb_opengl_registration.h" +#include "cocos2d_specifics.hpp" #include "cocos2d.h" -#include "json/document.h" -#include "json/filestream.h" -#include "json/stringbuffer.h" -#include "json/writer.h" -#include "VisibleRect.h" #include "ConfigParser.h" -#include "Protos.pb.h" -#include "zlib.h" - -// header files for directory operation -#ifdef _WIN32 -#include -#else -#include -#endif #include -#include - -using namespace std; -using namespace cocos2d; -std::string g_resourcePath; static std::string g_projectPath; -//1M size -#define MAXPROTOLENGTH 1048576 - -#define PROTO_START "RuntimeSend:" - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) -#define usleep(t) Sleep(t) -#else -#include -#endif - -extern string getIPAddress(); - -const char* getRuntimeVersion() -{ - return "1.5"; -} - -static string& replaceAll(string& str, const string& old_value, const string& new_value) -{ - size_t start = 0; - while(true) - { - size_t pos = 0; - if((pos = str.find(old_value, start)) != string::npos) { - str.replace(pos, old_value.length(), new_value); - start = pos + new_value.length(); - } - else break; - } - return str; -} -static bool startScript() -{ - ScriptingCore::getInstance()->runScript("script/jsb_boot.js"); - ScriptEngineProtocol *engine = ScriptingCore::getInstance(); - ScriptEngineManager::getInstance()->setScriptEngine(engine); - return ScriptingCore::getInstance()->runScript(ConfigParser::getInstance()->getEntryFile().c_str()); -} - -bool reloadScript(const string& file) -{ - auto director = Director::getInstance(); - FontFNT::purgeCachedData(); - if (director->getOpenGLView()) - { - SpriteFrameCache::getInstance()->removeSpriteFrames(); - director->getTextureCache()->removeAllTextures(); - } - FileUtils::getInstance()->purgeCachedEntries(); - - //director->getScheduler()->unscheduleAll(); - //director->getScheduler()->scheduleUpdate(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false); - - string modulefile = file; - if (modulefile.empty()) - { - modulefile = ConfigParser::getInstance()->getEntryFile().c_str(); - } - - return ScriptingCore::getInstance()->runScript(modulefile.c_str()); -} - -// header files for socket -#ifdef _WIN32 -#include -#include - -#define bzero(a, b) memset(a, 0, b); - -#else -#include -#include -#include -#include -#endif - -class FileServer -{ - static FileServer *s_sharedFileServer; -public: - static FileServer* getShareInstance() - { - if (s_sharedFileServer == nullptr) - { - s_sharedFileServer = new FileServer(); - } - return s_sharedFileServer; - } - bool listenOnTCP(int port); - void stop(); - - void readResFileFinfo(); - void addResFileInfo(const char* filename,uint64_t u64); - void removeResFileInfo(const char *filename); - rapidjson::Document* getFileCfgJson() - { - return &_filecfgjson; - }; - string getTransingFileName() - { - _fileNameMutex.lock(); - string filename = _strFileName; - _fileNameMutex.unlock(); - return filename; - } -protected: - FileServer() - { - _listenfd = -1; - _running = false; - _endThread = false; - _protoBuf =nullptr; - } - ~FileServer() - { - CC_SAFE_DELETE_ARRAY(_protoBuf); - } -private: - void loopReceiveFile(); - void loopWriteFile(); - void loopResponse(); - void addResponse(int fd, string filename,int errortype,int errornum); - enum PROTONUM - { - FILEPROTO = 1, - FILESENDCOMPLETE = 2, - DIRPROTO = 3, - DIRSENDCOMPLETE = 4 - }; - - struct RecvBufStruct - { - runtime::FileSendProtos fileProto; - std::string contentBuf; - int fd; - }; - - struct ResponseStruct - { - runtime::FileSendComplete fileResponseProto; - int fd; - }; - - // file descriptor: socket, console, etc. - int _listenfd; - int _maxfd; - std::vector _fds; - std::thread _responseThread; - std::thread _receiveThread; - std::thread _writeThread; - fd_set _read_set; - bool _running; - bool _endThread; - char *_protoBuf; - - std::list _recvBufList; - std::list _responseBufList; - std::mutex _recvBufListMutex; - std::mutex _responseBufListMutex; - - rapidjson::Document _filecfgjson; - - string _strFileName; - std::mutex _fileNameMutex; - - string _recvErrorFile; - string _writeErrorFile; -}; - -FileServer* FileServer::s_sharedFileServer =nullptr; -void FileServer::readResFileFinfo() -{ - string filecfg = g_resourcePath; - filecfg.append("/"); - filecfg.append("fileinfo_debug.json"); - FILE * pFile = fopen (filecfg.c_str() , "r"); - if(pFile) - { - rapidjson::FileStream inputStream(pFile); - _filecfgjson.ParseStream<0>(inputStream); - fclose(pFile); - } - if(! _filecfgjson.IsObject()){ - _filecfgjson.SetObject(); - } - - //save file info to disk every five second - Director::getInstance()->getScheduler()->schedule([&](float){ - rapidjson::StringBuffer buffer; - rapidjson::Writer< rapidjson::StringBuffer > writer(buffer); - _filecfgjson.Accept(writer); - const char* str = buffer.GetString(); - string filecfg = g_resourcePath; - filecfg.append("/"); - filecfg.append("fileinfo_debug.json"); - FILE * pFile = fopen(filecfg.c_str(), "w"); - if (!pFile) return ; - fwrite(str,sizeof(char), strlen(str), pFile); - fclose(pFile); - },this, 5.0f, false, "fileinfo"); -} - -void FileServer::addResFileInfo(const char* filename,uint64_t u64) -{ - if(_filecfgjson.HasMember(filename)){ - _filecfgjson.RemoveMember(filename); - } - char filetime[512]= {0}; - sprintf(filetime, "%llu", u64); - rapidjson::Value filetimeValue(rapidjson::kStringType); - filetimeValue.SetString(filetime, _filecfgjson.GetAllocator()); - rapidjson::Value filenameValue(rapidjson::kStringType); - filenameValue.SetString(filename,_filecfgjson.GetAllocator()); - _filecfgjson.AddMember(filenameValue.GetString(), filetimeValue, _filecfgjson.GetAllocator()); -} - -void FileServer::removeResFileInfo(const char *filename) -{ - if (_filecfgjson.HasMember(filename)) { - _filecfgjson.RemoveMember(filename); - } -} - -bool FileServer::listenOnTCP(int port) -{ - int listenfd, n; - const int on = 1; - struct addrinfo hints, *res, *ressave; - char serv[30]; - - snprintf(serv, sizeof(serv)-1, "%d", port ); - serv[sizeof(serv)-1]=0; - - bzero(&hints, sizeof(struct addrinfo)); - hints.ai_flags = AI_PASSIVE; - hints.ai_family = AF_INET; // AF_UNSPEC: Do we need IPv6 ? - hints.ai_socktype = SOCK_STREAM; - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - WSADATA wsaData; - n = WSAStartup(MAKEWORD(2, 2),&wsaData); -#endif - - if ( (n = getaddrinfo(NULL, serv, &hints, &res)) != 0) { - fprintf(stderr,"net_listen error for %s: %s", serv, gai_strerror(n)); - return false; - } - - ressave = res; - do { - listenfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (listenfd < 0) - continue; /* error, try next one */ - - setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)); - //setsockopt(listenfd, IPPROTO_TCP, TCP_NODELAY, (const char*)&on, sizeof(on)); - if (::bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) - break; /* success */ - - close(listenfd); /* bind error, close and try next one */ - } while ((res = res->ai_next) != NULL); - - if (res == NULL) - { - perror("net_listen:"); - freeaddrinfo(ressave); - return false; - } - - listen(listenfd, 1); - - if (res->ai_family == AF_INET) - { - char buf[INET_ADDRSTRLEN] = ""; - struct sockaddr_in *sin = (struct sockaddr_in*) res->ai_addr; - if( inet_ntop(res->ai_family, &sin->sin_addr, buf, sizeof(buf)) != NULL ) - cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin_port)); - else - perror("inet_ntop"); - } else if (res->ai_family == AF_INET6) - { - char buf[INET6_ADDRSTRLEN] = ""; - struct sockaddr_in6 *sin = (struct sockaddr_in6*) res->ai_addr; - if( inet_ntop(res->ai_family, &sin->sin6_addr, buf, sizeof(buf)) != NULL ) - cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port)); - else - perror("inet_ntop"); - } - freeaddrinfo(ressave); - _listenfd = listenfd; - _receiveThread = std::thread( std::bind( &FileServer::loopReceiveFile, this) ); - _writeThread = std::thread(std::bind(&FileServer::loopWriteFile, this)); - _responseThread = std::thread(std::bind(&FileServer::loopResponse, this)); - return true; -} - -void FileServer::stop() -{ - if(_running) - { - _endThread = true; - _receiveThread.join(); - _writeThread.join(); - _responseThread.join(); - } -} - -static bool CreateDir(const char *sPathName) -{ - char DirName[256]={0}; - strcpy(DirName, sPathName); - size_t i, len = strlen(DirName); - if(DirName[len-1] != '/') - { - strcat(DirName, "/"); - } - - len = strlen(DirName); - for(i = 1; i < len; i++) - { - if(DirName[i] == '/') - { - DirName[i] = 0; - if(access(DirName, NULL) != 0) - { -#ifdef _WIN32 - if(_mkdir(DirName/*, 0755*/) == -1) -#else - if(mkdir(DirName, 0755) == -1) -#endif - { - perror("mkdir error"); - return false; - } - } - DirName[i] = '/'; - } - } - - return true; -} - -static void recvBuf(int fd, char *pbuf, unsigned long bufsize) +void recvBuf(int fd, char *pbuf, unsigned long bufsize) { unsigned long leftLength = bufsize; while (leftLength != 0) @@ -417,7 +50,7 @@ static void recvBuf(int fd, char *pbuf, unsigned long bufsize) } } -static void sendBuf(int fd, const char *pbuf, unsigned long bufsize) +void sendBuf(int fd, const char *pbuf, unsigned long bufsize) { unsigned long leftLength = bufsize; while (leftLength != 0) @@ -432,609 +65,34 @@ static void sendBuf(int fd, const char *pbuf, unsigned long bufsize) } } -void FileServer::loopReceiveFile() +std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value) { - struct sockaddr client; - socklen_t client_len; - - /* new client */ - client_len = sizeof(client); - int fd = accept(_listenfd, (struct sockaddr *)&client, &client_len ); - if (_protoBuf == nullptr) + size_t start = 0; + while(true) { - _protoBuf = new char[MAXPROTOLENGTH]; - } - - while(!_endThread) { - - // recv start flag - char startflag[13] = {0}; - recvBuf(fd, startflag, sizeof(startflag) - 1); - if (strcmp(startflag, PROTO_START) != 0) - { - continue; - } - - // recv proto num - union - { - char char_type[3]; - unsigned short uint16_type; - }protonum; - recvBuf(fd, protonum.char_type, sizeof(protonum.char_type) - 1); - //recv protobuf length - union - { - char char_type[3]; - unsigned short uint16_type; - }protolength; - recvBuf(fd, protolength.char_type, sizeof(protolength.char_type) - 1); - - //recv variable length - memset(_protoBuf, 0, MAXPROTOLENGTH); - recvBuf(fd, _protoBuf, protolength.uint16_type); - - RecvBufStruct recvDataBuf; - recvDataBuf.fd = fd; - recvDataBuf.fileProto.ParseFromString(_protoBuf); - if (1 == recvDataBuf.fileProto.package_seq()) - { - _recvErrorFile = ""; - } else - { - // recv error - if (_recvErrorFile == recvDataBuf.fileProto.file_name()) - { - continue; - } - } - unsigned long contentSize = recvDataBuf.fileProto.content_size(); - if (contentSize == 0) - { - recvDataBuf.contentBuf=""; - _recvBufListMutex.lock(); - _recvBufList.push_back(recvDataBuf); - _recvBufListMutex.unlock(); - }else if(contentSize > 0) - { - //recv body data - Bytef *contentbuf = new Bytef[contentSize+1]; - memset(contentbuf, 0, contentSize+1); - unsigned long recvTotalLen = contentSize; - while (recvTotalLen != 0){ - unsigned long recvLen = MAXPROTOLENGTH; - if(recvTotalLen < MAXPROTOLENGTH) - recvLen = recvTotalLen; - memset(_protoBuf, 0, MAXPROTOLENGTH); - unsigned long result = recv(fd, _protoBuf, recvLen,0); - if (result <= 0) - { - usleep(1); - continue; - } - memcpy(contentbuf + contentSize - recvTotalLen, _protoBuf, result); - recvTotalLen -= result; - } - - if (recvDataBuf.fileProto.compress_type() == runtime::FileSendProtos_CompressType::FileSendProtos_CompressType_ZIP){ - unsigned long uncompressSize = recvDataBuf.fileProto.uncompress_size(); - Bytef *buff = new Bytef[uncompressSize * sizeof(Bytef)]; - memset(buff, 0, uncompressSize * sizeof(Bytef)); - int err = ::uncompress(buff, &uncompressSize,contentbuf, contentSize * sizeof(Bytef)); - if (err != Z_OK){ - CC_SAFE_DELETE_ARRAY(buff); - CC_SAFE_DELETE_ARRAY(contentbuf); - addResponse(recvDataBuf.fd, recvDataBuf.fileProto.file_name(), runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_UNCOMPRESS_ERROR, err); - continue; - } - CC_SAFE_DELETE_ARRAY(contentbuf); - contentbuf = buff; - contentSize = uncompressSize; - } - recvDataBuf.contentBuf.assign((const char*)contentbuf, contentSize); - CC_SAFE_DELETE_ARRAY(contentbuf); - - _recvBufListMutex.lock(); - _recvBufList.push_back(recvDataBuf); - _recvBufListMutex.unlock(); + size_t pos = 0; + if((pos = str.find(old_value, start)) != std::string::npos) { + str.replace(pos, old_value.length(), new_value); + start = pos + new_value.length(); } + else break; } -} - -void FileServer::loopWriteFile() -{ - while(!_endThread) - { - _recvBufListMutex.lock(); - size_t recvSize = _recvBufList.size(); - _recvBufListMutex.unlock(); - if(0 == recvSize) - { - usleep(500); - continue; - } - - _recvBufListMutex.lock(); - RecvBufStruct recvDataBuf = _recvBufList.front(); - _recvBufList.pop_front(); - _recvBufListMutex.unlock(); - string filename = recvDataBuf.fileProto.file_name(); - string fullfilename = g_resourcePath; - fullfilename += filename; - _fileNameMutex.lock(); - _strFileName = filename; - _fileNameMutex.unlock(); - //cocos2d::log("WriteFile:: fullfilename = %s",filename.c_str()); - CreateDir(fullfilename.substr(0, fullfilename.find_last_of("/")).c_str()); - - FILE *fp= nullptr; - if (1 == recvDataBuf.fileProto.package_seq()) - { - _writeErrorFile =""; - fp = fopen(fullfilename.c_str(), "wb"); - } else - { - if (_writeErrorFile == filename) - { - continue; - } - fp=fopen(fullfilename.c_str(), "ab"); - } - if (nullptr == fp) - { - addResponse(recvDataBuf.fd, filename, runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FOPEN_ERROR, errno); - continue; - } - if (fp) - { - if (recvDataBuf.contentBuf.size() > 0 && 0 == fwrite(recvDataBuf.contentBuf.c_str(), sizeof(char), recvDataBuf.contentBuf.size(), fp)) - { - addResponse(recvDataBuf.fd, filename, runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FWRITE_ERROR, errno); - fclose(fp); - continue; - } - fclose(fp); - } - - if (1 == recvDataBuf.fileProto.package_seq()) - { - //record new file modify - addResFileInfo(filename.c_str(), recvDataBuf.fileProto.modified_time()); - addResponse(recvDataBuf.fd, filename, runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_SUCCESS, 0); - } - } + return str; } -void FileServer::addResponse(int fd, string filename, int errortype, int errornum) +const char* getRuntimeVersion() { - switch (errortype) - { - case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_UNCOMPRESS_ERROR: - case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_RECV_ERROR: - _recvErrorFile = filename; - break; - case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FOPEN_ERROR: - case runtime::FileSendComplete::RESULTTYPE::FileSendComplete_RESULTTYPE_FWRITE_ERROR: - _writeErrorFile = filename; - break; - default: - break; - } - - ResponseStruct responseBuf; - responseBuf.fd = fd; - responseBuf.fileResponseProto.set_file_name(filename.c_str()); - responseBuf.fileResponseProto.set_result((::runtime::FileSendComplete_RESULTTYPE)errortype); - responseBuf.fileResponseProto.set_error_num(errornum); - - // push Response struct - _responseBufListMutex.lock(); - _responseBufList.push_back(responseBuf); - _responseBufListMutex.unlock(); + return "1.6"; } -void FileServer::loopResponse() +bool startScript() { - while(!_endThread) { - _responseBufListMutex.lock(); - size_t responseSize = _responseBufList.size(); - _responseBufListMutex.unlock(); - if(0 == responseSize) - { - usleep(500); - /* error */ - continue; - } - - _responseBufListMutex.lock(); - ResponseStruct responseBuf = _responseBufList.front(); - _responseBufList.pop_front(); - _responseBufListMutex.unlock(); - //send response - string responseString; - runtime::FileSendComplete fileSendProtoComplete; - fileSendProtoComplete.set_file_name(responseBuf.fileResponseProto.file_name()); - fileSendProtoComplete.set_result(responseBuf.fileResponseProto.result()); - fileSendProtoComplete.set_error_num(responseBuf.fileResponseProto.error_num()); - fileSendProtoComplete.SerializeToString(&responseString); - char dataBuf[1024] = {0}; - struct ResponseHeaderStruct - { - char startFlag[12]; - unsigned short protoNum; - unsigned short protoBufLen; - }; - ResponseHeaderStruct responseHeader; - strcpy(responseHeader.startFlag, PROTO_START); - responseHeader.protoNum = PROTONUM::FILESENDCOMPLETE; - responseHeader.protoBufLen = (unsigned short) responseString.size(); - memcpy(dataBuf, &responseHeader, sizeof(responseHeader)); - memcpy(dataBuf + sizeof(responseHeader), responseString.c_str(), responseString.size()); - - sendBuf(responseBuf.fd, dataBuf, sizeof(responseHeader) + responseString.size()); - cocos2d::log("responseFile:%s,result:%d", fileSendProtoComplete.file_name().c_str(), fileSendProtoComplete.result()); - } + ScriptingCore::getInstance()->runScript("script/jsb_boot.js"); + ScriptEngineProtocol *engine = ScriptingCore::getInstance(); + ScriptEngineManager::getInstance()->setScriptEngine(engine); + return ScriptingCore::getInstance()->runScript(ConfigParser::getInstance()->getEntryFile().c_str()); } -class ConnectWaitLayer: public Layer -{ -private: - Label* _labelUploadFile; -public: - ConnectWaitLayer() - { -#include "ResData.h" - int designWidth = 1280; - int designHeight = 800; - Image* imagebg = new Image(); - - if (ConfigParser::getInstance()->isLanscape()) - { - imagebg->initWithImageData(__landscapePngData, sizeof(__landscapePngData)); - Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designWidth, designHeight, ResolutionPolicy::EXACT_FIT); - } else - { - imagebg->initWithImageData(__portraitPngData, sizeof(__portraitPngData)); - Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designHeight, designWidth, ResolutionPolicy::FIXED_HEIGHT); - - } - Texture2D* texturebg = Director::getInstance()->getTextureCache()->addImage(imagebg, "play_background"); - auto background = Sprite::createWithTexture(texturebg); - background->setAnchorPoint(Vec2(0,0)); - addChild(background, 9000); - - // variable of below is"play" button position. - int portraitX = 400; - int portraitY = 500; - int lanscaptX = 902; - int lanscaptY = 400; - Image* imageplay = new Image(); - imageplay->initWithImageData(__playEnablePngData, sizeof(__playEnablePngData)); - Texture2D* textureplay = Director::getInstance()->getTextureCache()->addImage(imageplay, "play_enable"); - auto playSprite = Sprite::createWithTexture(textureplay); - addChild(playSprite, 9999); - - Image* imageShine = new Image(); - imageShine->initWithImageData(__shinePngData, sizeof(__shinePngData)); - Texture2D* textureShine = Director::getInstance()->getTextureCache()->addImage(imageShine, "shine"); - auto shineSprite = Sprite::createWithTexture(textureShine); - shineSprite->setOpacity(0); - Vector arrayOfActions; - arrayOfActions.pushBack(DelayTime::create(0.4f)); - arrayOfActions.pushBack(FadeTo::create(0.8f, 200)); - arrayOfActions.pushBack(FadeTo::create(0.8f, 255)); - arrayOfActions.pushBack(FadeTo::create(0.8f, 200)); - arrayOfActions.pushBack(FadeTo::create(0.8f, 0)); - arrayOfActions.pushBack(DelayTime::create(0.4f)); - shineSprite->runAction(RepeatForever::create(Sequence::create(arrayOfActions))); - addChild(shineSprite, 9998); - - string strip = getIPAddress(); - char szIPAddress[64] ={ 0}; - sprintf(szIPAddress, "IP: %s", strip.c_str()); - auto IPlabel = Label::createWithSystemFont(szIPAddress, "", 72); - IPlabel->setAnchorPoint(Vec2(0, 0)); - int spaceSizex = 72; - int spaceSizey = 200; - IPlabel->setPosition(Point(VisibleRect::leftTop().x + spaceSizex, VisibleRect::top().y - spaceSizey)); - addChild(IPlabel, 9001); - - string transferTip = "waiting for file transfer ..."; - if (CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM || CC_PLATFORM_MAC == CC_TARGET_PLATFORM) - { - transferTip = "waiting for debugger to connect ..."; - } - - char szVersion[256] = {0}; - sprintf(szVersion, "runtimeVersion:%s \nengineVersion:%s", getRuntimeVersion(), ENGINE_VERSION); - Label* verLable = Label::createWithSystemFont(szVersion, "", 24); - verLable->setAnchorPoint(Vec2(0, 0)); - int width = verLable->getBoundingBox().size.width; - verLable->setPosition(Point(VisibleRect::right().x - width, VisibleRect::rightBottom().y)); - verLable->setAlignment(TextHAlignment::LEFT); - addChild(verLable, 9002); - _labelUploadFile = Label::createWithSystemFont(transferTip, "", 36); - _labelUploadFile->setAnchorPoint(Vec2(0, 0)); - _labelUploadFile->setPosition(Point(VisibleRect::leftTop().x + spaceSizex, IPlabel->getPositionY()- spaceSizex)); - _labelUploadFile->setAlignment(TextHAlignment::LEFT); - addChild(_labelUploadFile, 9003); - - if (ConfigParser::getInstance()->isLanscape()) - { - playSprite->setPosition(lanscaptX, lanscaptY); - shineSprite->setPosition(lanscaptX, lanscaptY); - } - else - { - playSprite->setPosition(portraitX, portraitY); - shineSprite->setPosition(portraitX, portraitY); - - } - - auto listener = EventListenerTouchOneByOne::create(); - listener->onTouchBegan = [](Touch* touch, Event *event)->bool{ - auto target = static_cast(event->getCurrentTarget()); - Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); - auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height); - if (!rect.containsPoint(point)) return false; - target->stopAllActions(); - target->runAction(Sequence::createWithTwoActions(ScaleBy::create(0.05f, 0.9f), ScaleTo::create(0.125f, 1))); - return true; - }; - listener->onTouchEnded = [](Touch* touch, Event *event){ - auto target = static_cast(event->getCurrentTarget()); - Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); - auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height); - if (!rect.containsPoint(point)) return; - startScript(); - }; - _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, playSprite); - - this->scheduleUpdate(); - } - - // clean up: ignore stdin, stdout and stderr - void update(float fDelta) - { - string transferTip = FileServer::getShareInstance()->getTransingFileName(); - if (transferTip.empty()){ - return; - } - _labelUploadFile->setString(transferTip); - } -}; - -class ConsoleCustomCommand -{ -public: - void init() - { - cocos2d::Console *_console = Director::getInstance()->getConsole(); - static struct Console::Command commands[] = - { - {"sendrequest","send command to runtime.Args[json format]",std::bind(&ConsoleCustomCommand::onSendCommand, this, std::placeholders::_1, std::placeholders::_2)}, - }; - for (int i=0;i< sizeof(commands)/sizeof(Console::Command);i++) - { - _console->addCommand(commands[i]); - } -#if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM) - _console->listenOnTCP(ConfigParser::getInstance()->getConsolePort()); -#else - _console->listenOnTCP(6050); -#endif - - _fileserver = nullptr; - _fileserver= FileServer::getShareInstance(); -#if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM) - _fileserver->listenOnTCP(ConfigParser::getInstance()->getUploadPort()); -#else - _fileserver->listenOnTCP(6060); -#endif - _fileserver->readResFileFinfo(); - } - - ~ConsoleCustomCommand() - { - Director::getInstance()->getConsole()->stop(); - if(_fileserver) - _fileserver->stop(); - } - - void onSendCommand(int fd, const std::string &args) - { - Director::getInstance()->getScheduler()->performFunctionInCocosThread([=](){ - rapidjson::Document dArgParse; - dArgParse.Parse<0>(args.c_str()); - if (dArgParse.HasMember("cmd")) - { - string strcmd = dArgParse["cmd"].GetString(); - - rapidjson::Document dReplyParse; - dReplyParse.SetObject(); - dReplyParse.AddMember("cmd",strcmd.c_str(),dReplyParse.GetAllocator()); - if (dArgParse.HasMember("seq")) - { - dReplyParse.AddMember("seq",dArgParse["seq"],dReplyParse.GetAllocator()); - } - - if (strcmp(strcmd.c_str(), "start-logic") == 0) - { - if (startScript()) - { - dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); - }else - { - dReplyParse.AddMember("code",1,dReplyParse.GetAllocator()); - } - - } else if (strcmp(strcmd.c_str(),"clearcompile")==0) - { - if (dArgParse.HasMember("modulefiles") && dArgParse["modulefiles"].Size() != 0) - { - const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; - for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) - { - ScriptingCore::getInstance()->cleanScript(objectfiles[i].GetString()); - } - } else - { - std::unordered_map filenameScript = ScriptingCore::getInstance()->getFileScript(); - filenameScript.clear(); - } - - dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); - } else if(strcmp(strcmd.c_str(),"precompile")==0) - { - const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; - for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) - { - ScriptingCore::getInstance()->compileScript(objectfiles[i].GetString()); - } - - dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); - } else if(strcmp(strcmd.c_str(),"reload")==0) - { - if (dArgParse.HasMember("modulefiles")){ - rapidjson::Value bodyvalue(rapidjson::kObjectType); - const rapidjson::Value& objectfiles = dArgParse["modulefiles"]; - for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++){ - if (!reloadScript(objectfiles[i].GetString())) { - bodyvalue.AddMember(objectfiles[i].GetString(),1,dReplyParse.GetAllocator()); - } - } - if (0 == objectfiles.Size()) - { - reloadScript(""); - } - dReplyParse.AddMember("body",bodyvalue,dReplyParse.GetAllocator()); - }else - { - reloadScript(""); - } - dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); - } else if(strcmp(strcmd.c_str(), "getversion") == 0) - { - rapidjson::Value bodyvalue(rapidjson::kObjectType); - bodyvalue.AddMember("version", getRuntimeVersion(), dReplyParse.GetAllocator()); - dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); - dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); - } else if(strcmp(strcmd.c_str(), "getfileinfo") == 0) - { - rapidjson::Value bodyvalue(rapidjson::kObjectType); - if(_fileserver){ - rapidjson::Document* filecfgjson = _fileserver->getFileCfgJson(); - for (auto it=filecfgjson->MemberonBegin(); it != filecfgjson->MemberonEnd(); ++it) - { - bodyvalue.AddMember(it->name.GetString(), it->value.GetString(), dReplyParse.GetAllocator()); - } - } - dReplyParse.AddMember("body",bodyvalue,dReplyParse.GetAllocator()); - dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); - - } else if (strcmp(strcmd.c_str(), "getEntryfile") == 0) - { - rapidjson::Value bodyvalue(rapidjson::kObjectType); - rapidjson::Value entryFileValue(rapidjson::kStringType); - entryFileValue.SetString(ConfigParser::getInstance()->getEntryFile().c_str(), dReplyParse.GetAllocator()); - bodyvalue.AddMember("entryfile", entryFileValue, dReplyParse.GetAllocator()); - dReplyParse.AddMember("body", bodyvalue,dReplyParse.GetAllocator()); - dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); - } else if(strcmp(strcmd.c_str(), "getIP") == 0) - { - rapidjson::Value bodyvalue(rapidjson::kObjectType); - rapidjson::Value IPValue(rapidjson::kStringType); - IPValue.SetString(getIPAddress().c_str(), dReplyParse.GetAllocator()); - bodyvalue.AddMember("IP", IPValue,dReplyParse.GetAllocator()); - dReplyParse.AddMember("body", bodyvalue,dReplyParse.GetAllocator()); - dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); - - } else if(strcmp(strcmd.c_str(), "remove") == 0) - { - if (dArgParse.HasMember("files")) - { - rapidjson::Value bodyvalue(rapidjson::kObjectType); - const rapidjson::Value& objectfiles = dArgParse["files"]; - const char* filename = NULL; - for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++) - { - filename = objectfiles[i].GetString(); - - // remove js compiled script - ScriptingCore::getInstance()->cleanScript(filename); - - // remove file from disk - string filepath(g_resourcePath + "/" + filename); - if (FileUtils::getInstance()->isFileExist(filepath)) - { - if(remove(filepath.c_str()) != 0) - { - // remove failed - bodyvalue.AddMember(filename, 2, dReplyParse.GetAllocator()); - } - } else - { - // file not exist - bodyvalue.AddMember(filename, 1, dReplyParse.GetAllocator()); - } - - if (_fileserver) - { - // file remove success, remove it from record - if (! FileUtils::getInstance()->isFileExist(filepath)) - _fileserver->removeResFileInfo(filename); - } - } - - dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); - } - - dReplyParse.AddMember("code",0,dReplyParse.GetAllocator()); - }else if(strcmp(strcmd.c_str(),"shutdownapp")==0) - { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - extern void shutDownApp(); - shutDownApp(); -#else - exit(0); -#endif - } else if(strcmp(strcmd.c_str(),"getplatform") == 0) - { - string platform="UNKNOW"; -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - platform = "WIN32"; -#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - platform = "MAC"; -#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - platform = "IOS"; -#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - platform = "ANDROID"; -#endif - rapidjson::Value bodyvalue(rapidjson::kObjectType); - rapidjson::Value platformValue(rapidjson::kStringType); - platformValue.SetString(platform.c_str(), dReplyParse.GetAllocator()); - bodyvalue.AddMember("platform", platformValue, dReplyParse.GetAllocator()); - dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator()); - dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator()); - } - - rapidjson::StringBuffer buffer; - rapidjson::Writer< rapidjson::StringBuffer > writer(buffer); - dReplyParse.Accept(writer); - string msgContent = buffer.GetString(); - char msgLength[64] = {0x1, 0}; - sprintf(msgLength + 1, "%d:", msgContent.size()); - - string msg(msgLength + msgContent); - - sendBuf(fd, msg.c_str(), msg.size()); - } - }); - } -private: - FileServer* _fileserver; -}; - bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -1043,22 +101,35 @@ bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp) js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object"); - if (argc == 1) { + if (argc == 1 || argc == 2) { std::string arg0; + bool arg1 = false; + ok &= jsval_to_std_string(cx, argv[0], &arg0); JSB_PRECONDITION2(ok, cx, false, "cocos2dx_FileUtils_addSearchPath : Error processing arguments"); - std::string originPath = arg0; - if (!FileUtils::getInstance()->isAbsolutePath(originPath)) - arg0 = g_resourcePath + originPath; - cobj->addSearchPath(arg0); - if (!FileUtils::getInstance()->isAbsolutePath(originPath)) + if (argc == 2) + { + arg1 = JS::ToBoolean(JS::RootedValue(cx, argv[1])); + } + + if (! FileUtils::getInstance()->isAbsolutePath(arg0)) + { + // add write path to search path + if (FileServer::getShareInstance()->getIsUsingWritePath()) + { + cobj->addSearchPath(FileServer::getShareInstance()->getWritePath() + arg0, arg1); + } else + { + cobj->addSearchPath(arg0, arg1); + } + #if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - cobj->addSearchPath(g_projectPath + originPath); -#endif -#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - cobj->addSearchPath(originPath); + // add project path to search path + cobj->addSearchPath(g_projectPath + arg0, arg1); #endif + } + JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } @@ -1076,29 +147,35 @@ bool runtime_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Invalid Native Object"); if (argc == 1) { - std::vector arg0; - ok &= jsval_to_std_vector_string(cx, argv[0], &arg0); + std::vector vecPaths, writePaths; + ok &= jsval_to_std_vector_string(cx, argv[0], &vecPaths); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Error processing arguments"); std::vector originPath; // for IOS platform. std::vector projPath; // for Desktop platform. - for (int i = 0; i < arg0.size(); i++) + for (int i = 0; i < vecPaths.size(); i++) { - if (!FileUtils::getInstance()->isAbsolutePath(arg0[i])) + if (!FileUtils::getInstance()->isAbsolutePath(vecPaths[i])) { - originPath.push_back(arg0[i]); // for IOS platform. - projPath.push_back(g_projectPath+arg0[i]); //for Desktop platform. - arg0[i] = g_resourcePath + arg0[i]; + originPath.push_back(vecPaths[i]); // for IOS platform. + projPath.push_back(g_projectPath+vecPaths[i]); //for Desktop platform. + writePaths.push_back(FileServer::getShareInstance()->getWritePath() + vecPaths[i]); } } + #if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - arg0.insert(arg0.end(),projPath.begin(),projPath.end()); + vecPaths.insert(vecPaths.end(), projPath.begin(), projPath.end()); #endif + if (FileServer::getShareInstance()->getIsUsingWritePath()) + { + vecPaths.insert(vecPaths.end(), writePaths.begin(), writePaths.end()); + } else + { + vecPaths.insert(vecPaths.end(), originPath.begin(), originPath.end()); + } + + cobj->setSearchPaths(vecPaths); -#if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - arg0.insert(arg0.end(),originPath.begin(),originPath.end()); -#endif - cobj->setSearchPaths(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } @@ -1125,46 +202,29 @@ void register_FileUtils(JSContext *cx, JSObject *global) { void initRuntime() { - vector searchPathArray = FileUtils::getInstance()->getSearchPaths(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - // add peoject's root directory to search path - if (g_projectPath.empty()) - { - extern std::string getCurAppPath(); - string appPath = getCurAppPath(); + vector searchPathArray = FileUtils::getInstance()->getSearchPaths(); + + extern std::string getCurAppPath(); + std::string appPath = getCurAppPath(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - appPath.append("/../../"); + appPath.append("/../../"); #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - appPath.append("/../../../"); + appPath.append("/../../../"); #endif - appPath = replaceAll(appPath, "\\", "/"); - g_projectPath = appPath; - } + appPath = replaceAll(appPath, "\\", "/"); + g_projectPath = appPath; + + // add project's root directory to search path searchPathArray.insert(searchPathArray.begin(), g_projectPath); -#endif // add writable path to search path - g_resourcePath = FileUtils::getInstance()->getWritablePath(); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - std::string getCurAppName(void); - g_resourcePath += getCurAppName(); - g_resourcePath += "/"; -#endif - - g_resourcePath += "debugruntime/"; - - g_resourcePath = replaceAll(g_resourcePath, "\\", "/"); - if (g_resourcePath.at(g_resourcePath.length() - 1) != '/'){ - g_resourcePath.append("/"); - } - - searchPathArray.insert(searchPathArray.begin(), g_resourcePath); + searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath()); FileUtils::getInstance()->setSearchPaths(searchPathArray); +#endif - static ConsoleCustomCommand *g_customCommand; - g_customCommand = new ConsoleCustomCommand(); - g_customCommand->init(); + + ConsoleCommand::getShareInstance()->init(); } void startRuntime() @@ -1174,7 +234,7 @@ void startRuntime() int debugPort = 5086; #if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM) - debugPort =ConfigParser::getInstance()->getDebugPort(); + debugPort = ConfigParser::getInstance()->getDebugPort(); #endif ScriptingCore::getInstance()->enableDebugger(debugPort); ScriptEngineProtocol *engine = ScriptingCore::getInstance(); @@ -1187,3 +247,10 @@ void startRuntime() scene->addChild(connectLayer); director->runWithScene(scene); } + +void endRuntime() +{ + ConsoleCommand::purge(); + FileServer::getShareInstance()->stop(); + //FileServer::purge(); +} diff --git a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.h b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.h index c1d4100698..8d61e6bb62 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.h +++ b/templates/js-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.h @@ -25,9 +25,26 @@ THE SOFTWARE. #ifndef _RUNTIME__H_ #define _RUNTIME__H_ +#include +#include "ScriptingCore.h" + +void recvBuf(int fd, char *pbuf, unsigned long bufsize); + +void sendBuf(int fd, const char *pbuf, unsigned long bufsize); + +std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value); + +std::string getIPAddress(); + +const char* getRuntimeVersion(); + +bool startScript(); + void initRuntime(); void startRuntime(); +void endRuntime(); + #endif // _RUNTIME__H_ diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk index 00b5a0d613..7003447c74 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk @@ -19,13 +19,16 @@ LOCAL_SRC_FILES := \ ../../Classes/protobuf-lite/google/protobuf/io/zero_copy_stream.cc \ ../../Classes/protobuf-lite/google/protobuf/io/zero_copy_stream_impl_lite.cc \ ../../Classes/protobuf-lite/google/protobuf/stubs/stringprintf.cc \ +../../Classes/runtime/ConnectWaitLayer.cpp \ +../../Classes/runtime/ConsoleCommand.cpp \ +../../Classes/runtime/FileServer.cpp \ ../../Classes/runtime/Landscape_png.cpp \ ../../Classes/runtime/PlayDisable_png.cpp \ ../../Classes/runtime/PlayEnable_png.cpp \ ../../Classes/runtime/Portrait_png.cpp \ -../../Classes/runtime/Shine_png.cpp \ -../../Classes/runtime/Runtime.cpp \ ../../Classes/runtime/Protos.pb.cc \ +../../Classes/runtime/Runtime.cpp \ +../../Classes/runtime/Shine_png.cpp \ ../../Classes/VisibleRect.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/ConfigParser.cpp \ @@ -33,8 +36,8 @@ hellojavascript/Runtime_android.cpp \ hellojavascript/main.cpp LOCAL_C_INCLUDES := \ -$(LOCAL_PATH)/../../Classes/runtime \ $(LOCAL_PATH)/../../Classes/protobuf-lite \ +$(LOCAL_PATH)/../../Classes/runtime \ $(LOCAL_PATH)/../../Classes diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk index 9b48184d7a..706af60331 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.android/jni/Application.mk @@ -1,8 +1,7 @@ APP_STL := gnustl_static -#use clang by default, uncomment next line to use gcc4.8 -#NDK_TOOLCHAIN_VERSION=4.8 -NDK_TOOLCHAIN_VERSION=clang +# Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices +#APP_ABI := armeabi-v7a APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char APP_LDFLAGS := -latomic diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index 786b573fd8..7f2b1b8cd2 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -84,6 +84,12 @@ A922754E1517C094001B78AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; BA4E718719EB6E7900932425 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA4E718619EB6E7900932425 /* MediaPlayer.framework */; }; + AB9079D419E931D80033128B /* ConsoleCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB9079D219E931D80033128B /* ConsoleCommand.cpp */; }; + AB9079D519E931D80033128B /* ConsoleCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB9079D219E931D80033128B /* ConsoleCommand.cpp */; }; + ABCA93C719E65B1C007FB844 /* FileServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABCA93C519E65B1C007FB844 /* FileServer.cpp */; }; + ABCA93C819E65B1C007FB844 /* FileServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABCA93C519E65B1C007FB844 /* FileServer.cpp */; }; + ABCA93CF19E6712A007FB844 /* ConnectWaitLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABCA93CD19E6712A007FB844 /* ConnectWaitLayer.cpp */; }; + ABCA93D019E6712A007FB844 /* ConnectWaitLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ABCA93CD19E6712A007FB844 /* ConnectWaitLayer.cpp */; }; C00FD4B21938628E00C6382D /* Landscape_png.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C00FD4AA1938628E00C6382D /* Landscape_png.cpp */; }; C00FD4B31938628E00C6382D /* Landscape_png.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C00FD4AA1938628E00C6382D /* Landscape_png.cpp */; }; C00FD4B41938628E00C6382D /* PlayDisable_png.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C00FD4AB1938628E00C6382D /* PlayDisable_png.cpp */; }; @@ -362,6 +368,13 @@ A922754D1517C094001B78AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; A922754F1517C094001B78AA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; BA4E718619EB6E7900932425 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; + AB9079CD19E917450033128B /* CodeIDESupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeIDESupport.h; sourceTree = ""; }; + AB9079D219E931D80033128B /* ConsoleCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleCommand.cpp; sourceTree = ""; }; + AB9079D319E931D80033128B /* ConsoleCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleCommand.h; sourceTree = ""; }; + ABCA93C519E65B1C007FB844 /* FileServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileServer.cpp; sourceTree = ""; }; + ABCA93C619E65B1C007FB844 /* FileServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileServer.h; sourceTree = ""; }; + ABCA93CD19E6712A007FB844 /* ConnectWaitLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConnectWaitLayer.cpp; sourceTree = ""; }; + ABCA93CE19E6712A007FB844 /* ConnectWaitLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConnectWaitLayer.h; sourceTree = ""; }; C00FD4AA1938628E00C6382D /* Landscape_png.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Landscape_png.cpp; sourceTree = ""; }; C00FD4AB1938628E00C6382D /* PlayDisable_png.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlayDisable_png.cpp; sourceTree = ""; }; C00FD4AC1938628E00C6382D /* PlayEnable_png.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlayEnable_png.cpp; sourceTree = ""; }; @@ -627,6 +640,12 @@ C00FD4A91938628E00C6382D /* runtime */ = { isa = PBXGroup; children = ( + ABCA93CD19E6712A007FB844 /* ConnectWaitLayer.cpp */, + ABCA93CE19E6712A007FB844 /* ConnectWaitLayer.h */, + AB9079D219E931D80033128B /* ConsoleCommand.cpp */, + AB9079D319E931D80033128B /* ConsoleCommand.h */, + ABCA93C519E65B1C007FB844 /* FileServer.cpp */, + ABCA93C619E65B1C007FB844 /* FileServer.h */, 3E12D1AB1957FB18002FF0FD /* protobuf-lite */, 3E12D1A71957FB0E002FF0FD /* Protos.pb.cc */, 3E12D1A81957FB0E002FF0FD /* Protos.pb.h */, @@ -637,6 +656,7 @@ C00FD4AE1938628E00C6382D /* ResData.h */, C00FD4AF1938628E00C6382D /* Runtime.cpp */, C00FD4B01938628E00C6382D /* Runtime.h */, + C026DCC818928A2400B3EDE8 /* Runtime_ios-mac.mm */, C00FD4B11938628E00C6382D /* Shine_png.cpp */, ); path = runtime; @@ -680,12 +700,12 @@ D4545214156E28EF00887EB5 /* Classes */ = { isa = PBXGroup; children = ( + AB9079CD19E917450033128B /* CodeIDESupport.h */, C00FD4A91938628E00C6382D /* runtime */, C033B522191B36AE00D06937 /* VisibleRect.cpp */, C033B523191B36AE00D06937 /* VisibleRect.h */, C06C37861918E81100617BED /* ConfigParser.cpp */, C06C37871918E81100617BED /* ConfigParser.h */, - C026DCC818928A2400B3EDE8 /* Runtime_ios-mac.mm */, D4545215156E28EF00887EB5 /* AppDelegate.cpp */, D4545216156E28EF00887EB5 /* AppDelegate.h */, ); @@ -942,6 +962,7 @@ 3E12D1E01957FB18002FF0FD /* message_lite.cc in Sources */, 3E12D1D61957FB18002FF0FD /* extension_set.cc in Sources */, C00FD4B51938628E00C6382D /* PlayDisable_png.cpp in Sources */, + AB9079D519E931D80033128B /* ConsoleCommand.cpp in Sources */, 3E12D1EA1957FB18002FF0FD /* stringprintf.cc in Sources */, C06C37891918E81100617BED /* ConfigParser.cpp in Sources */, 509D4A8117EBB24E00697056 /* AppDelegate.cpp in Sources */, @@ -951,10 +972,12 @@ C0C2F37418AA0C66003976DA /* SimulatorApp.mm in Sources */, C026DCCA18928A2400B3EDE8 /* Runtime_ios-mac.mm in Sources */, 3E12D1DC1957FB18002FF0FD /* zero_copy_stream.cc in Sources */, + ABCA93C819E65B1C007FB844 /* FileServer.cpp in Sources */, 3E12D1E41957FB18002FF0FD /* atomicops_internals_x86_msvc.cc in Sources */, 3E12D1DE1957FB18002FF0FD /* zero_copy_stream_impl_lite.cc in Sources */, 3E12D1AA1957FB0E002FF0FD /* Protos.pb.cc in Sources */, C033B525191B36AE00D06937 /* VisibleRect.cpp in Sources */, + ABCA93D019E6712A007FB844 /* ConnectWaitLayer.cpp in Sources */, 3E12D1E21957FB18002FF0FD /* repeated_field.cc in Sources */, 3E12D1D81957FB18002FF0FD /* generated_message_util.cc in Sources */, C00FD4BB1938628E00C6382D /* Runtime.cpp in Sources */, @@ -975,6 +998,7 @@ C00FD4B21938628E00C6382D /* Landscape_png.cpp in Sources */, D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */, C00FD4BA1938628E00C6382D /* Runtime.cpp in Sources */, + ABCA93C719E65B1C007FB844 /* FileServer.cpp in Sources */, 3E12D1DF1957FB18002FF0FD /* message_lite.cc in Sources */, C06C37881918E81100617BED /* ConfigParser.cpp in Sources */, 3E12D1DD1957FB18002FF0FD /* zero_copy_stream_impl_lite.cc in Sources */, @@ -983,6 +1007,7 @@ 3E12D1E31957FB18002FF0FD /* atomicops_internals_x86_msvc.cc in Sources */, 3E12D1E11957FB18002FF0FD /* repeated_field.cc in Sources */, C00FD4B41938628E00C6382D /* PlayDisable_png.cpp in Sources */, + ABCA93CF19E6712A007FB844 /* ConnectWaitLayer.cpp in Sources */, C00FD4BC1938628E00C6382D /* Shine_png.cpp in Sources */, 3E12D1EB1957FB18002FF0FD /* wire_format_lite.cc in Sources */, 3E12D1D51957FB18002FF0FD /* extension_set.cc in Sources */, @@ -995,6 +1020,7 @@ 3E12D1D91957FB18002FF0FD /* coded_stream.cc in Sources */, 509D4ABC17EBB2AB00697056 /* AppController.mm in Sources */, C026DCC918928A2400B3EDE8 /* Runtime_ios-mac.mm in Sources */, + AB9079D419E931D80033128B /* ConsoleCommand.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm index 79116ee40f..81f19ebcdd 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm @@ -43,7 +43,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( { // Override point for customization after application launch. - + // Add the view controller's view to the window and display. window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds] diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm index 00b342ddcd..6eec66b421 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm @@ -34,19 +34,18 @@ of this software and associated documentation files (the "Software"), to deal #include "AppDelegate.h" #include "glfw3.h" #include "glfw3native.h" -#include "Runtime.h" #include "ConfigParser.h" #include "cocos2d.h" using namespace cocos2d; -bool g_landscape=false; +bool g_landscape = false; bool g_windTop = false; cocos2d::Size g_screenSize; GLViewImpl* g_eglView = nullptr; -static AppController* g_nsAppDelegate=nullptr; +static AppController* g_nsAppDelegate = nullptr; using namespace std; using namespace cocos2d; @@ -58,6 +57,7 @@ @implementation AppController { return [[[NSBundle mainBundle] bundlePath] UTF8String]; } + std::string getCurAppName(void) { string appName = [[[NSProcessInfo processInfo] processName] UTF8String]; @@ -80,14 +80,9 @@ - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { NSArray *args = [[NSProcessInfo processInfo] arguments]; - if (args!=nullptr && [args count]>=2) { - extern std::string g_resourcePath; - g_resourcePath = [[args objectAtIndex:1]UTF8String]; - if (g_resourcePath.at(0) != '/') { - g_resourcePath=""; - } + if (args != nullptr && [args count] >= 2) { } - g_nsAppDelegate =self; + g_nsAppDelegate = self; AppDelegate app; Application::getInstance()->run(); @@ -108,7 +103,7 @@ - (void) createSimulator:(NSString*)viewName viewWidth:(float)width viewHeight:( if(!g_landscape) { - float tmpvalue =width; + float tmpvalue = width; width = height; height = tmpvalue; } @@ -122,7 +117,6 @@ - (void) createSimulator:(NSString*)viewName viewWidth:(float)width viewHeight:( [self createViewMenu]; [self updateMenu]; - [window center]; [window becomeFirstResponder]; [window makeKeyAndOrderFront:self]; diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj index d2d629b1ad..8059344222 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj @@ -202,6 +202,9 @@ xcopy "$(ProjectDir)..\..\..\res" "$(OutDir)\Resource\res" /e /Y + + + @@ -240,6 +243,9 @@ xcopy "$(ProjectDir)..\..\..\res" "$(OutDir)\Resource\res" /e /Y + + + diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj.filters b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj.filters index c674c0d1ae..9fb279cb39 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj.filters +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/HelloJavascript.vcxproj.filters @@ -1,204 +1,222 @@ - - - - - {ca9c9e15-d942-43a1-aa7a-5f0b74ca1afd} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;png;manifest - - - {ccb2323b-1cfa-41ea-bcf4-ba5f07309396} - - - {e93a77e1-af1e-4400-87d3-504b62ebdbb0} - - - {e10ac93f-7947-473c-a7c0-e3b5faf5d234} - - - {ed8064b7-5a41-45ea-b836-1d26386322de} - - - - - win32 - - - Classes - - - win32 - - - win32 - - - Classes - - - Classes - - - Classes\runtime - - - Classes\runtime - - - Classes\runtime - - - Classes\runtime - - - Classes\runtime - - - Classes\runtime - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime - - - - - Classes - - - win32 - - - - win32 - - - Classes - - - Classes - - - Classes\runtime - - - Classes\runtime - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime\protobuf-lite - - - Classes\runtime - - - - - resource - - - - - resource - - + + + + + {ca9c9e15-d942-43a1-aa7a-5f0b74ca1afd} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;png;manifest + + + {ccb2323b-1cfa-41ea-bcf4-ba5f07309396} + + + {e93a77e1-af1e-4400-87d3-504b62ebdbb0} + + + {e10ac93f-7947-473c-a7c0-e3b5faf5d234} + + + {ed8064b7-5a41-45ea-b836-1d26386322de} + + + + + win32 + + + Classes + + + win32 + + + win32 + + + Classes + + + Classes + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + + + Classes + + + win32 + + + + win32 + + + Classes + + + Classes + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime\protobuf-lite + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + Classes\runtime + + + + + resource + + + + + resource + + \ No newline at end of file diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp index 26987067d7..8b6ffb025e 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/SimulatorWindow.cpp @@ -25,7 +25,6 @@ THE SOFTWARE. #include "SimulatorWindow.h" #include "cocos2d.h" -#include "glfw3native.h" #include "resource.h" #include "runtime/Runtime.h" #include "ConfigParser.h" @@ -40,13 +39,13 @@ WNDPROC g_oldProc=NULL; bool g_landscape=false; bool g_windTop = false; CCSize g_screenSize; -GLViewImpl* g_eglView=NULL; +GLView* g_eglView=NULL; INT_PTR CALLBACK AboutDialogCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); void createViewMenu() { - HMENU hSysMenu = GetSystemMenu(glfwGetWin32Window(g_eglView->getWindow()), FALSE); + HMENU hSysMenu = GetSystemMenu(g_eglView->getWin32Window(), FALSE); HMENU viewMenu = GetSubMenu(hSysMenu, 8); for (int i = ConfigParser::getInstance()->getScreenSizeCount() - 1; i >= 0; --i) { @@ -69,7 +68,7 @@ void createViewMenu() void updateMenu() { - HMENU hSysMenu = GetSystemMenu(glfwGetWin32Window(g_eglView->getWindow()), FALSE); + HMENU hSysMenu = GetSystemMenu(g_eglView->getWin32Window(), FALSE); HMENU viewMenu = GetSubMenu(hSysMenu, 8); HMENU viewControl = GetSubMenu(hSysMenu, 9); @@ -86,11 +85,12 @@ void updateMenu() if (g_windTop) { - ::SetWindowPos(glfwGetWin32Window(g_eglView->getWindow()),HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + ::SetWindowPos(g_eglView->getWin32Window(),HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); CheckMenuItem(viewControl, ID_CONTROL_TOP, MF_BYCOMMAND | MF_CHECKED); + }else { - ::SetWindowPos(glfwGetWin32Window(g_eglView->getWindow()),HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); + ::SetWindowPos(g_eglView->getWin32Window(),HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); CheckMenuItem(viewControl, ID_CONTROL_TOP, MF_BYCOMMAND | MF_UNCHECKED); } int width = g_screenSize.width; @@ -194,7 +194,7 @@ void onViewZoomOut(int viewMenuID) default: break; } - g_eglView->setFrameZoomFactor(scale); + dynamic_cast(g_eglView)->setFrameZoomFactor(scale); updateView(); } @@ -212,12 +212,12 @@ void onViewChangeFrameSize(int viewMenuID) void onHelpAbout() { - DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_ABOUT), glfwGetWin32Window(g_eglView->getWindow()), AboutDialogCallback); + DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG_ABOUT), g_eglView->getWin32Window(), AboutDialogCallback); } void shutDownApp() { - HWND hWnd=glfwGetWin32Window(g_eglView->getWindow()); + HWND hWnd=g_eglView->getWin32Window(); ::SendMessage(hWnd,WM_CLOSE,NULL,NULL); } @@ -345,7 +345,7 @@ void createSimulator(const char* viewName, float width, float height, bool isLan auto director = Director::getInstance(); director->setOpenGLView(g_eglView); - HWND hWnd=glfwGetWin32Window(g_eglView->getWindow()); + HWND hWnd=g_eglView->getWin32Window(); HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MENU_COCOS)); HMENU hSysMenu = GetSystemMenu(hWnd, FALSE); HMENU hviewMenu = GetSubMenu(hMenu,1); @@ -366,4 +366,4 @@ void createSimulator(const char* viewName, float width, float height, bool isLan printf("SetWindowLong NewWndProc Error:%d\n",GetLastError()); } -} \ No newline at end of file +} diff --git a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/main.cpp b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/main.cpp index d6ec3ec120..3d29cafe63 100644 --- a/templates/js-template-runtime/frameworks/runtime-src/proj.win32/main.cpp +++ b/templates/js-template-runtime/frameworks/runtime-src/proj.win32/main.cpp @@ -25,8 +25,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, int iLen = 2*wcslen(szArgList[1]); char* chRtn = new char[iLen+1]; wcstombs(chRtn,szArgList[1],iLen+1); - extern std::string g_resourcePath; - g_resourcePath = chRtn; delete [] chRtn; } LocalFree(szArgList); diff --git a/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk b/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk old mode 100644 new mode 100755 index d51c7324e2..4293710e09 Binary files a/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk and b/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk differ diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Default-568h@2x.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Default-568h@2x.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Default.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Default.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Default@2x.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Default@2x.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-100.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-100.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-114.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-114.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-120.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-120.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-144.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-144.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-152.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-152.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-29.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-29.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-40.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-40.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-50.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-50.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-57.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-57.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-58.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-58.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-72.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-72.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-76.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-76.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-80.png b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Icon-80.png old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Info.plist b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Info.plist old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PkgInfo b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PkgInfo old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS index 6098190d33..2e7f077886 100755 Binary files a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS and b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS differ diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa old mode 100644 new mode 100755 index 3771267382..470fb73cd0 Binary files a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa and b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa differ diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist old mode 100644 new mode 100755 index a6d24c48e3..91a98d170d --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 14A389 + 13D65 CFBundleDevelopmentRegion en CFBundleExecutable diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac index 79d0393002..dddc2e3d70 100755 Binary files a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac and b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac differ diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/PkgInfo b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/PkgInfo old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/Icon.icns b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/Icon.icns old mode 100644 new mode 100755 diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib old mode 100644 new mode 100755 index ffab16c22f..92baef14f7 Binary files a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib and b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib differ diff --git a/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe b/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe old mode 100644 new mode 100755 index 16db3f7887..259cdff2b0 Binary files a/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe and b/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe differ diff --git a/templates/js-template-runtime/runtime/win32/libcocos2d.dll b/templates/js-template-runtime/runtime/win32/libcocos2d.dll old mode 100644 new mode 100755 index 27e8987b4c..f6aaae7c58 Binary files a/templates/js-template-runtime/runtime/win32/libcocos2d.dll and b/templates/js-template-runtime/runtime/win32/libcocos2d.dll differ diff --git a/tools/bindings-generator b/tools/bindings-generator index ca407f96ea..dcf8ffe02c 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit ca407f96ea08750152c5ee320c86b440feff4a71 +Subproject commit dcf8ffe02cad179bb1a78c92d53278a415d12299 diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 36153464b9..26b4f825e2 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 36153464b943d179a8d21ab294030c91c6e18ace +Subproject commit 26b4f825e2d56f8de83e784216f3da8e7cd96c63 diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 0e63994894..5351a19ac5 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -27,9 +27,9 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAu # 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 = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode +classes = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode GLProgramState -classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode +classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* # 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 @@ -38,7 +38,7 @@ classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint setColor], +skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint setColor pause resume], Sprite::[getQuad ^setPosition$], NodeGrid::[setGrid], SpriteBatchNode::[getDescendants], @@ -88,7 +88,8 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat Sequence::[create], Spawn::[create], RotateTo::[calculateAngles], - GLProgram::[getProgram setUniformLocationWith2f.* setUniformLocationWith1f.* setUniformLocationWith3f.* setUniformLocationWith4f.*], + GLProgram::[getProgram setUniformLocationWith(1|2|3|4)fv setUniformLocationWith(2|3|4)iv setUniformLocationWithMatrix(2|3|4)fv], + GLProgramState::[setUniformVec4], Grid3DAction::[create actionWith.* vertex originalVertex (g|s)etVertex getOriginalVertex], Grid3D::[vertex originalVertex (g|s)etVertex getOriginalVertex], TiledGrid3DAction::[create actionWith.* tile originalTile getOriginalTile (g|s)etTile], diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index 279eaad4a3..8bb67dbbc9 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.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 = AssetsManagerEx Manifest EventListenerAssetsManagerEx EventAssetsManagerEx Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ +classes = AssetsManagerEx Manifest EventListenerAssetsManagerEx EventAssetsManagerEx Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ # 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 @@ -69,9 +69,7 @@ base_classes_to_skip = Ref # Set is special and we will use a hand-written constructor abstract_classes = Manifest -classes_need_extend = ScrollView TableView TableViewCell Scale9Sprite - # 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 = no -classes_need_extend = ScrollView TableView TableViewCell Scale9Sprite ControlButton ControlStepper ControlSwitch ControlSlider ControlColourPicker ControlPotentiometer +classes_need_extend = ScrollView TableView TableViewCell ControlButton ControlStepper ControlSwitch ControlSlider ControlColourPicker ControlPotentiometer diff --git a/tools/tojs/cocos2dx_studio.ini b/tools/tojs/cocos2dx_studio.ini index 914df5e61b..1ec88a321c 100644 --- a/tools/tojs/cocos2dx_studio.ini +++ b/tools/tojs/cocos2dx_studio.ini @@ -55,7 +55,8 @@ skip = *::[createInstance ^visit$ copyWith.* onEnter.* onExit.* ^description$ ge ColliderDetector::[addContourData.* removeContourData], ColliderBody::[getContourData getCalculatedVertexList], SceneReader::[setTarget purgeSceneReader], - CSLoader::[nodeFromProtocolBuffers] + CSLoader::[nodeWithFlatBuffers nodeWithFlatBuffersForSimulator createNodeWithFlatBuffersFile nodeWithFlatBuffersFile createNodeWithFlatBuffersForSimulator], + ActionTimelineCache::[createActionWithFlatBuffersFile loadAnimationActionWithFlatBuffersFile createActionWithFlatBuffersForSimulator] rename_functions = Armature::[getBoundingBox=boundingBox] diff --git a/tools/tojs/cocos2dx_ui.ini b/tools/tojs/cocos2dx_ui.ini index 1521eeff77..40f43f4ca8 100644 --- a/tools/tojs/cocos2dx_ui.ini +++ b/tools/tojs/cocos2dx_ui.ini @@ -30,9 +30,9 @@ headers = %(cocosdir)s/cocos/ui/CocosGUI.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 = Helper Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField ScrollView PageView ListView LayoutParameter LinearLayoutParameter RelativeLayoutParameter VideoPlayer HBox VBox RelativeBox EditBox$ +classes = Helper Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField ScrollView PageView ListView LayoutParameter LinearLayoutParameter RelativeLayoutParameter VideoPlayer HBox VBox RelativeBox Scale9Sprite EditBox$ -classes_need_extend = Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField ScrollView PageView ListView VideoPlayer HBox VBox RelativeBox EditBox$ +classes_need_extend = Layout Widget Button CheckBox ImageView Text TextAtlas TextBMFont RichText RichElement RichElementText RichElementImage RichElementCustomNode LoadingBar Slider TextField ScrollView PageView ListView VideoPlayer HBox VBox RelativeBox Scale9Sprite EditBox$ # 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 diff --git a/tools/tojs/genbindings.py b/tools/tojs/genbindings.py index 02234a7844..c2f8c951fd 100755 --- a/tools/tojs/genbindings.py +++ b/tools/tojs/genbindings.py @@ -77,9 +77,15 @@ def main(): if platform == 'win32': x86_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.3/prebuilt', '%s' % cur_platform)) + if not os.path.exists(x86_llvm_path): + x86_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.4/prebuilt', '%s' % cur_platform)) else: x86_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.3/prebuilt', '%s-%s' % (cur_platform, 'x86'))) + if not os.path.exists(x86_llvm_path): + x86_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.4/prebuilt', '%s-%s' % (cur_platform, 'x86'))) x64_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.3/prebuilt', '%s-%s' % (cur_platform, 'x86_64'))) + if not os.path.exists(x86_llvm_path): + x64_llvm_path = os.path.abspath(os.path.join(ndk_root, 'toolchains/llvm-3.4/prebuilt', '%s-%s' % (cur_platform, 'x86_64'))) if os.path.isdir(x86_llvm_path): llvm_path = x86_llvm_path